forked from veyon/veyon
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
326 lines (272 loc) · 10.7 KB
/
CMakeLists.txt
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0)
PROJECT(veyon)
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
SET(VEYON_DEBUG TRUE)
ELSEIF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE relwithdebinfo)
ENDIF()
IF(VEYON_DEBUG)
ADD_DEFINITIONS(-DVEYON_DEBUG)
ENDIF()
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
IF(COMMAND CMAKE_POLICY)
CMAKE_POLICY(SET CMP0009 NEW)
CMAKE_POLICY(SET CMP0020 NEW)
CMAKE_POLICY(SET CMP0063 NEW)
if(${CMAKE_VERSION} VERSION_GREATER "3.12.0")
cmake_policy(SET CMP0075 NEW)
endif()
ENDIF()
INCLUDE(AddFileDependencies)
INCLUDE(CheckCSourceCompiles)
INCLUDE(CheckIncludeFiles)
INCLUDE(CheckFunctionExists)
INCLUDE(CheckSymbolExists)
INCLUDE(CheckTypeSize)
INCLUDE(GNUInstallDirs)
INCLUDE(CotireVeyon)
INCLUDE(ConfigureFiles)
FIND_PACKAGE(Git)
IF(GIT_FOUND)
EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" describe --tags
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE VERSION_STRING)
STRING(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${VERSION_STRING}")
STRING(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${VERSION_STRING}")
STRING(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${VERSION_STRING}")
# determine build number to use in NSIS installer and resource files
EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" describe --tags
COMMAND cut -d "-" -f2
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE VERSION_BUILD)
IF(NOT VERSION_BUILD GREATER 0)
SET(VERSION_BUILD 0)
ENDIF()
# Get list of all committers from git history, ordered by number of commits.
# The CONTRIBUTORS file is used by AboutDialog. This information can be provided
# with -DCONTRIBUTORS=/path/to/CONTRIBUTORS instead. For instance, to generate
# this file for version 3.0.2, the command is:
# git shortlog -sne v3.0.2 | cut -c8-
SET(CONTRIBUTORS "${CMAKE_BINARY_DIR}/CONTRIBUTORS")
IF(NOT EXISTS "${CONTRIBUTORS}")
EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" shortlog -s d160d147165271516589c304cb1b8f5e48f8527d..HEAD
COMMAND cut -c8-
COMMAND sort -f
OUTPUT_FILE "${CONTRIBUTORS}"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
TIMEOUT 10)
ENDIF()
ENDIF()
# can't retrieve version information as not building from Git repository?
IF(NOT VERSION_STRING)
SET(VERSION_MAJOR 4)
SET(VERSION_MINOR 3)
SET(VERSION_PATCH 5)
SET(VERSION_BUILD 0)
SET(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
ELSE()
# remove leading character from tag name
STRING(REPLACE "v" "" VERSION_STRING "${VERSION_STRING}")
ENDIF()
# set up compiler version variable
STRING(REGEX REPLACE "\\.[0-9]$" "" COMPILER_VERSION_MAJOR_MINOR ${CMAKE_CXX_COMPILER_VERSION})
# set up basic platform variables
IF(WIN32)
SET(VEYON_BUILD_WIN32 1)
ENDIF()
IF(APPLE)
SET(VEYON_BUILD_APPLE 1)
ENDIF()
IF(UNIX AND NOT ANDROID)
SET(VEYON_BUILD_LINUX 1)
ENDIF()
IF(ANDROID)
SET(VEYON_BUILD_ANDROID 1)
ENDIF()
IF(WIN64)
SET(VEYON_BUILD_WIN64 TRUE)
ENDIF(WIN64)
# set up library and plugin path variables
IF(VEYON_BUILD_ANDROID)
SET(CMAKE_INSTALL_PREFIX "/")
SET(VEYON_LIB_DIR "libs/${ANDROID_ABI}")
SET(VEYON_INSTALL_PLUGIN_DIR "${VEYON_LIB_DIR}/veyon")
SET(VEYON_INSTALL_DATA_DIR "${CMAKE_INSTALL_DATADIR}/veyon")
SET(VEYON_PLUGIN_DIR "")
SET(VEYON_TRANSLATIONS_DIR "/translations")
ELSE()
IF(CMAKE_INSTALL_LIBDIR)
SET(VEYON_LIB_DIR "${CMAKE_INSTALL_LIBDIR}/veyon" CACHE INTERNAL "Veyon library directory")
ELSE()
SET(VEYON_LIB_DIR lib/veyon CACHE INTERNAL "Veyon library directory")
ENDIF()
SET(VEYON_INSTALL_PLUGIN_DIR "${VEYON_LIB_DIR}")
SET(VEYON_INSTALL_DATA_DIR "${CMAKE_INSTALL_DATADIR}/veyon")
IF(WIN32)
SET(VEYON_PLUGIN_DIR "plugins")
SET(VEYON_TRANSLATIONS_DIR "translations")
ELSE()
SET(VEYON_PLUGIN_DIR "../${VEYON_LIB_DIR}")
SET(VEYON_TRANSLATIONS_DIR "../share/veyon/translations")
ENDIF()
ENDIF()
SET(VEYON_CORE_INCLUDE_DIR core/include)
# find required Qt5 modules
FIND_PACKAGE(Qt5Core REQUIRED)
FIND_PACKAGE(Qt5Concurrent REQUIRED)
FIND_PACKAGE(Qt5Gui REQUIRED)
FIND_PACKAGE(Qt5Widgets REQUIRED)
FIND_PACKAGE(Qt5Network REQUIRED)
FIND_PACKAGE(Qt5LinguistTools REQUIRED)
IF(VEYON_DEBUG)
FIND_PACKAGE(Qt5Test REQUIRED)
SET(VEYON_DEBUG_LIBRARIES Qt5::Test)
ENDIF()
# find required libraries
FIND_PACKAGE(ZLIB REQUIRED)
FIND_PACKAGE(PNG REQUIRED)
FIND_PACKAGE(JPEG REQUIRED)
FIND_PACKAGE(LZO REQUIRED)
FIND_PACKAGE(QCA REQUIRED)
# FindOpenSSL.cmake in recent versions of CMake will only find the DLLs instead
# of the import libraries if CYGWIN is not set
SET(CYGWIN TRUE)
FIND_PACKAGE(OpenSSL REQUIRED)
UNSET(CYGWIN)
# find Linux-specific packages
IF(VEYON_BUILD_LINUX)
INCLUDE(XdgInstall)
ENDIF()
### BEGIN: libvncclient configuration
CHECK_INCLUDE_FILES(endian.h LIBVNCSERVER_HAVE_ENDIAN_H)
CHECK_INCLUDE_FILES(limits.h LIBVNCSERVER_HAVE_LIMITS_H)
CHECK_INCLUDE_FILES(time.h LIBVNCSERVER_HAVE_TIME_H)
CHECK_INCLUDE_FILES(unistd.h LIBVNCSERVER_HAVE_UNISTD_H)
CHECK_INCLUDE_FILES(ws2tcpip.h LIBVNCSERVER_HAVE_WS2TCPIP_H)
CHECK_INCLUDE_FILES(netinet/in.h LIBVNCSERVER_HAVE_NETINET_IN_H)
CHECK_INCLUDE_FILES(sys/endian.h LIBVNCSERVER_HAVE_SYS_ENDIAN_H)
CHECK_INCLUDE_FILES(sys/socket.h LIBVNCSERVER_HAVE_SYS_SOCKET_H)
CHECK_INCLUDE_FILES(sys/stat.h LIBVNCSERVER_HAVE_SYS_STAT_H)
CHECK_INCLUDE_FILES(sys/time.h LIBVNCSERVER_HAVE_SYS_TIME_H)
CHECK_INCLUDE_FILES(sys/timeb.h LIBVNCSERVER_HAVE_SYS_TIMEB_H)
CHECK_INCLUDE_FILES(sys/types.h LIBVNCSERVER_HAVE_SYS_TYPES_H)
IF(LIBVNCSERVER_HAVE_SYS_SOCKET_H)
LIST(APPEND CMAKE_EXTRA_INCLUDE_FILES "sys/socket.h")
ENDIF()
CHECK_TYPE_SIZE("pid_t" LIBVNCSERVER_PID_T)
CHECK_TYPE_SIZE("size_t" LIBVNCSERVER_SIZE_T)
CHECK_TYPE_SIZE("socklen_t" LIBVNCSERVER_SOCKLEN_T)
SET(_RFB_RFBCONFIG_H TRUE)
SET(LIBVNCSERVER_HAVE_LIBJPEG TRUE)
SET(LIBVNCSERVER_HAVE_LZO TRUE)
SET(LIBVNCSERVER_HAVE_LIBPNG TRUE)
SET(LIBVNCSERVER_HAVE_LIBZ TRUE)
SET(LIBVNCSERVER_HAVE_LIBSSL TRUE)
SET(LIBVNCSERVER_IPv6 TRUE)
IF(VEYON_BUILD_WIN32)
SET(LIBVNCSERVER_NEED_INADDR_T TRUE)
ENDIF()
FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${VEYON_CORE_INCLUDE_DIR}/rfb)
IF(NOT VEYON_BUILD_LINUX OR VEYON_X11VNC_EXTERNAL)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/3rdparty/libvncserver/rfb/rfbconfig.h.cmakein ${CMAKE_BINARY_DIR}/${VEYON_CORE_INCLUDE_DIR}/rfb/rfbconfig.h @ONLY)
ENDIF()
### END: libvncclient configuration
IF(SANITIZE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fsanitize=undefined")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread -fsanitize=undefined")
ENDIF()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-exceptions -std=c++11 -fstack-protector-strong ${CXXFLAGS}")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fstack-protector-strong ${CFLAGS}")
IF(NOT VEYON_BUILD_WIN32)
SET(SYS_INC SYSTEM)
ENDIF()
IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
MESSAGE(WARNING "Not using -fvisibility=hidden as it is broken with GCC < 6.0")
ELSE()
SET(CMAKE_C_VISIBILITY_PRESET hidden)
SET(CMAKE_CXX_VISIBILITY_PRESET hidden)
SET(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
IF(LTO)
SET(LTO_FLAGS "-flto=4")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LTO_FLAGS}")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LTO_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LTO_FLAGS}")
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${LTO_FLAGS}")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${LTO_FLAGS}")
ENDIF()
ENDIF()
add_definitions(-DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050e00 -D_FORTIFY_SOURCE=2 -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_KEYWORDS)
FILE(GLOB_RECURSE IN_FILES RELATIVE ${CMAKE_SOURCE_DIR} "*config.h.in" "*.rc.in" "*.desktop.in" "*.policy.in" "*.service.in" "*.manifest.in" "*.nsi.in")
CONFIGURE_FILES(${IN_FILES})
SET(CMAKE_AUTOMOC TRUE)
SET(CMAKE_AUTOUIC TRUE)
SET(CMAKE_AUTORCC TRUE)
SET(3rdparty_DIR ${CMAKE_SOURCE_DIR}/3rdparty)
SET(ultravnc_DIR ${3rdparty_DIR}/ultravnc)
SET(libvncserver_DIR ${3rdparty_DIR}/libvncserver)
SET(x11vnc_DIR ${3rdparty_DIR}/x11vnc)
SET(libfakekey_DIR ${3rdparty_DIR}/libfakekey)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/${VEYON_CORE_INCLUDE_DIR} ${CMAKE_BINARY_DIR}/${VEYON_CORE_INCLUDE_DIR} ${libvncserver_DIR})
INCLUDE_DIRECTORIES(${SYS_INC} ${ZLIB_INCLUDE_DIR} ${JPEG_INCLUDE_DIR} ${PNG_INCLUDE_DIR} ${QCA_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} ${LZO_INCLUDE_DIR})
LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/core)
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${VEYON_LIB_DIR}")
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# make sub-directories
ADD_SUBDIRECTORY(core)
ADD_SUBDIRECTORY(server)
ADD_SUBDIRECTORY(service)
ADD_SUBDIRECTORY(master)
ADD_SUBDIRECTORY(configurator)
ADD_SUBDIRECTORY(cli)
ADD_SUBDIRECTORY(worker)
ADD_SUBDIRECTORY(plugins)
ADD_SUBDIRECTORY(translations)
#
# add Windows installer related targets
#
if(WIN32)
include(WindowsInstaller)
endif()
#
# package generation
#
INCLUDE(cmake/CPackDefinitions.cmake)
#
# display configuration information
#
MESSAGE("\n"
"Veyon build summary\n"
"--------------------\n"
"* Version : ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_BUILD} (${VERSION_STRING})\n"
"* Install prefix : ${CMAKE_INSTALL_PREFIX}\n"
"* Library directory : ${CMAKE_INSTALL_PREFIX}/${VEYON_LIB_DIR}\n"
"* Plugin directory : ${CMAKE_INSTALL_PREFIX}/${VEYON_INSTALL_PLUGIN_DIR}\n"
"* Build type : ${CMAKE_BUILD_TYPE}\n"
"* Build platform : ${CMAKE_SYSTEM_PROCESSOR}\n"
"* Compile flags : ${CMAKE_C_FLAGS} (CXX: ${CMAKE_CXX_FLAGS})\n"
)
IF(VEYON_BUILD_ANDROID)
INCLUDE(AndroidDeployQt)
SET(CMAKE_ANDROID_DIR "${CMAKE_SOURCE_DIR}/android")
SET(_CMAKE_ANDROID_DIR "${CMAKE_ANDROID_DIR}")
SET(ANDROID_INSTALL_DIR "${CMAKE_BINARY_DIR}/install")
SET(ANDROID_EXTRA_PLUGINS ${ANDROID_INSTALL_DIR}/${VEYON_LIB_DIR}/veyon/ ${QT_DIR}/lib/qca-qt5/crypto)
FILE(GLOB ANDROID_EXTRA_LIBS ${ANDROID_INSTALL_DIR}/${VEYON_LIB_DIR}/*.so)
LIST(APPEND ANDROID_EXTRA_LIBS "${ANDROID_SYSROOT_GENERIC}/libc++_shared.so")
LIST(APPEND ANDROID_EXTRA_LIBS "${QT_DIR}/lib/libldap.so"
"${QT_DIR}/lib/liblber.so"
"${QT_DIR}/lib/libsasl2.so")
androiddeployqt("veyon-master" "${ANDROID_ADDITIONAL_FIND_ROOT_PATH};${CMAKE_BINARY_DIR}/core")
SET_TARGET_PROPERTIES(create-apk-veyon-master PROPERTIES ANDROID_APK_DIR "${CMAKE_ANDROID_DIR}")
add_custom_target(prepare-apk
COMMAND rm -rf ${ANDROID_INSTALL_DIR}
COMMAND cd ${CMAKE_BINARY_DIR}/core && make DESTDIR=${ANDROID_INSTALL_DIR} install
COMMAND cd ${CMAKE_BINARY_DIR}/plugins && make DESTDIR=${ANDROID_INSTALL_DIR} install
)
add_dependencies(create-apk-veyon-master prepare-apk)
ENDIF()