commons.cmake
7.8 KB
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# 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)
# Allow to build the virtual camera in Linux and other POSIX systems as if you
# were building it for APPLE
# NOTE: No, this option isn't for cross compile, the resulting binaries are not
# compatible with Mac, this option allows to test the virtual camera outside
# Mac.
set(FAKE_APPLE OFF CACHE BOOL "Virtual camera in Linux and other POSIX systems as if you were building it for APPLE")
if (NOT (APPLE OR FAKE_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 2)
set(VER_PAT 0)
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}")
set(AKVCAM_PLUGIN_NAME AkVirtualCamera)
set(AKVCAM_SERVICE_NAME AkVCamAssistant)
set(AKVCAM_MANAGER_NAME AkVCamManager)
set(AKVCAM_BRIDGE_NAME AkVCamBridge)
set(AKVCAM_DEVICE_PREFIX AkVCamVideoDevice)
set(AKVCAM_SERVICEPORT "8226" CACHE STRING "Virtual camera service port")
add_definitions(-DAKVCAM_PLUGIN_NAME="${AKVCAM_PLUGIN_NAME}"
-DAKVCAM_SERVICE_NAME="${AKVCAM_SERVICE_NAME}"
-DAKVCAM_MANAGER_NAME="${AKVCAM_MANAGER_NAME}"
-DAKVCAM_DEVICE_PREFIX="${AKVCAM_DEVICE_PREFIX}")
if (WIN32)
add_definitions(-DUNICODE -D_UNICODE)
endif ()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT FAKE_APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static -static-libgcc -static-libstdc++")
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
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.
# AkVirtualCamera 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\@/${AKVCAM_PLUGIN_NAME}")
else ()
set(QTIFW_TARGET_DIR "\@ApplicationsDirX86\@/${AKVCAM_PLUGIN_NAME}")
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 ()
if (APPLE OR FAKE_APPLE)
set(BUILDDIR build)
set(EXECPREFIX ${AKVCAM_PLUGIN_NAME}.plugin/Contents)
set(BINDIR ${EXECPREFIX}/MacOS)
set(LIBDIR ${EXECPREFIX}/Frameworks)
set(DATAROOTDIR ${EXECPREFIX}/Resources)
set(LICENSEDIR ${DATAROOTDIR})
elseif (WIN32)
include(GNUInstallDirs)
set(BUILDDIR build)
set(EXECPREFIX "")
set(BINDIR ${WIN_TARGET_ARCH})
set(LIBDIR ${CMAKE_INSTALL_LIBDIR}/${WIN_TARGET_ARCH})
set(DATAROOTDIR ${CMAKE_INSTALL_DATAROOTDIR})
set(LICENSEDIR ${DATAROOTDIR}/licenses/${AKVCAM_PLUGIN_NAME})
endif ()
if (APPLE OR FAKE_APPLE)
set(TARGET_PLATFORM mac)
set(BUILD_INFO_FILE ${DATAROOTDIR}/build-info.txt)
set(APP_LIBDIR ${LIBDIR})
set(MAIN_EXECUTABLE ${BINDIR}/${AKVCAM_PLUGIN_NAME})
set(PACKET_HIDE_ARCH false)
set(QTIFW_TARGET_DIR "\@ApplicationsDir\@/${AKVCAM_PLUGIN_NAME}")
set(OUTPUT_FORMATS "MacPkg")
elseif (WIN32)
set(TARGET_PLATFORM windows)
set(BUILD_INFO_FILE ${DATAROOTDIR}/build-info.txt)
set(MAIN_EXECUTABLE ${BINDIR}/${AKVCAM_MANAGER_NAME}.exe)
set(APP_LIBDIR ${WIN_TARGET_ARCH})
set(PACKET_HIDE_ARCH true)
set(OUTPUT_FORMATS "Nsis")
endif ()
set(BUILD_BRIDGE OFF CACHE BOOL "Build the bridge shared library (very experimental and unestable API)")