-
-
Notifications
You must be signed in to change notification settings - Fork 53
/
commons.cmake
222 lines (182 loc) · 5.56 KB
/
commons.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# akvirtualcamera, virtual camera for Mac and Windows.
# Copyright (C) 2021 Gonzalo Exequiel Pedone
#
# akvirtualcamera is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# akvirtualcamera is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>.
#
# Web-Site: http://webcamoid.github.io/
cmake_minimum_required(VERSION 3.5)
if (NOT APPLE AND NOT WIN32)
message(FATAL_ERROR "This driver only works in Mac an Windows. For Linux check 'akvcam' instead.")
endif ()
include(CheckCXXSourceCompiles)
set(COMMONS_APPNAME AkVirtualCamera)
string(TOLOWER ${COMMONS_APPNAME} COMMONS_TARGET)
set(VER_MAJ 9)
set(VER_MIN 1)
set(VER_PAT 3)
set(VERSION ${VER_MAJ}.${VER_MIN}.${VER_PAT})
set(DAILY_BUILD OFF CACHE BOOL "Mark this as a daily build")
add_definitions(-DCOMMONS_APPNAME="${COMMONS_APPNAME}"
-DCOMMONS_TARGET="${COMMONS_TARGET}"
-DCOMMONS_VER_MAJ="${VER_MAJ}"
-DCOMMONS_VERSION="${VERSION}"
-DPREFIX="${PREFIX}")
if (WIN32)
add_definitions(-DUNICODE -D_UNICODE)
endif ()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static -static-libgcc -static-libstdc++")
endif()
if (DAILY_BUILD)
add_definitions(-DDAILY_BUILD)
endif ()
set(GIT_COMMIT_HASH "" CACHE STRING "Set the alternative commit hash if not detected by git")
find_program(GIT_BIN git)
if (GIT_BIN)
execute_process(COMMAND ${GIT_BIN} rev-parse HEAD
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE GIT_COMMIT_HASH_RESULT
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
endif ()
if ("${GIT_COMMIT_HASH_RESULT}" STREQUAL "")
set(GIT_COMMIT_HASH_RESULT "${GIT_COMMIT_HASH}")
endif ()
if (NOT "${GIT_COMMIT_HASH_RESULT}" STREQUAL "")
add_definitions(-DGIT_COMMIT_HASH="${GIT_COMMIT_HASH_RESULT}")
endif ()
# NOTE for other developers: TARGET_ARCH is intended to be used as a reference
# for the deploy tool, so don't rush on adding new architectures unless you
# want to create a binary distributable for that architecture.
# Webcamoid build is not affected in anyway by the value of TARGET_ARCH, if the
# build fails its something else and totally unrelated to that variable.
if (WIN32)
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("
#include <windows.h>
#ifndef _M_X64
#error Not WIN64
#endif
int main()
{
return 0;
}" IS_WIN64_TARGET)
check_cxx_source_compiles("
#include <windows.h>
#ifndef _M_IX86
#error Not WIN32
#endif
int main()
{
return 0;
}" IS_WIN32_TARGET)
check_cxx_source_compiles("
#include <windows.h>
#ifndef _M_ARM64
#error Not ARM64
#endif
int main()
{
return 0;
}" IS_WIN64_ARM_TARGET)
check_cxx_source_compiles("
#include <windows.h>
#ifndef _M_ARM
#error Not ARM
#endif
int main()
{
return 0;
}" IS_WIN32_ARM_TARGET)
if (IS_WIN64_TARGET OR IS_WIN64_ARM_TARGET)
set(QTIFW_TARGET_DIR "\@ApplicationsDirX64\@/Webcamoid")
else ()
set(QTIFW_TARGET_DIR "\@ApplicationsDirX86\@/Webcamoid")
endif()
if (IS_WIN64_TARGET)
set(TARGET_ARCH win64)
set(WIN_TARGET_ARCH x64)
elseif (IS_WIN64_ARM_TARGET)
set(TARGET_ARCH win64_arm)
set(WIN_TARGET_ARCH arm64)
elseif (IS_WIN32_TARGET)
set(TARGET_ARCH win32)
set(WIN_TARGET_ARCH x86)
elseif (IS_WIN32_ARM_TARGET)
set(TARGET_ARCH win32_arm)
set(WIN_TARGET_ARCH arm32)
else ()
set(TARGET_ARCH unknown)
set(WIN_TARGET_ARCH unknown)
endif()
elseif (UNIX)
if (ANDROID)
set(TARGET_ARCH ${CMAKE_ANDROID_ARCH_ABI})
else ()
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("
#ifndef __x86_64__
#error Not x64
#endif
int main()
{
return 0;
}" IS_X86_64_TARGET)
check_cxx_source_compiles("
#ifndef __i386__
#error Not x86
#endif
int main()
{
return 0;
}" IS_I386_TARGET)
check_cxx_source_compiles("
#ifndef __aarch64__
#error Not ARM64
#endif
int main()
{
return 0;
}" IS_ARM64_TARGET)
check_cxx_source_compiles("
#ifndef __arm__
#error Not ARM
#endif
int main()
{
return 0;
}" IS_ARM_TARGET)
check_cxx_source_compiles("
#ifndef __riscv
#error Not RISC-V
#endif
int main()
{
return 0;
}" IS_RISCV_TARGET)
if (IS_X86_64_TARGET)
set(TARGET_ARCH x64)
elseif (IS_I386_TARGET)
set(TARGET_ARCH x86)
elseif (IS_ARM64_TARGET)
set(TARGET_ARCH arm64)
elseif (IS_ARM_TARGET)
set(TARGET_ARCH arm32)
elseif (IS_RISCV_TARGET)
set(TARGET_ARCH riscv)
else ()
set(TARGET_ARCH unknown)
endif ()
endif ()
endif ()