-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
217 lines (185 loc) · 6.75 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
###############################################################################
# SETUP
###############################################################################
cmake_minimum_required(VERSION 2.8.11)
# Shut up CMake 3.1 and later
if(POLICY CMP0053)
cmake_policy(SET CMP0053 NEW)
endif()
# Shut up CMake 3.0 and later
if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif()
project(TurboVNC NONE)
string(TOLOWER ${CMAKE_PROJECT_NAME} CMAKE_PROJECT_NAME_LC)
set(VERSION 2.2.6)
set(DOCVERSION 2.2.6)
set(RCVERSION 2,2,6,0)
set(COPYRIGHT_YEAR "1999-2020")
set(COPYRIGHT "The VirtualGL Project and many others (see README.txt)")
set(URLTEXT "Visit http://www.TurboVNC.org for more information on TurboVNC")
set(USEC 0)
macro(boolean_number var)
if(${var})
set(${var} 1 ${ARGN})
else()
set(${var} 0 ${ARGN})
endif()
endmacro()
macro(report_option var desc)
if(${var})
message(STATUS "${desc} enabled (${var} = ${${var}})")
else()
message(STATUS "${desc} disabled (${var} = ${${var}})")
endif()
endmacro()
set(DEFAULT_TVNC_BUILDNATIVE 1)
if(WIN32)
set(TVNC_BUILDNATIVEDESC "Build the Windows (native) TurboVNC Viewer and the TurboVNC Helper library for the Windows/Java TurboVNC Viewer (to enable keyboard grabbing)")
elseif(APPLE)
set(TVNC_BUILDNATIVEDESC "Build the TurboVNC Helper library for the Mac/Java TurboVNC Viewer (to enable drawing tablet support)")
else()
set(TVNC_BUILDNATIVEDESC "Build the TurboVNC Helper library for the Un*x/Java TurboVNC Viewer (to enable extended input device support, keyboard grabbing, and full-screen multi-screen spanning)")
endif()
option(TVNC_BUILDNATIVE ${TVNC_BUILDNATIVEDESC} ${DEFAULT_TVNC_BUILDNATIVE})
boolean_number(TVNC_BUILDNATIVE)
report_option(TVNC_BUILDNATIVE "Java/Native Hybrid TurboVNC Viewer")
if(WIN32)
report_option(TVNC_BUILDNATIVE "Native TurboVNC Viewer")
endif()
set(DEFAULT_TVNC_BUILDJAVA 1)
option(TVNC_BUILDJAVA "Build Java version of the TurboVNC Viewer"
${DEFAULT_TVNC_BUILDJAVA})
boolean_number(TVNC_BUILDJAVA)
report_option(TVNC_BUILDJAVA "Java TurboVNC Viewer")
set(DEFAULT_TVNC_BUILDSERVER 0)
if(UNIX AND NOT APPLE AND NOT CYGWIN)
set(DEFAULT_TVNC_BUILDSERVER 1)
endif()
option(TVNC_BUILDSERVER "Build TurboVNC server components"
${DEFAULT_TVNC_BUILDSERVER})
boolean_number(TVNC_BUILDSERVER)
report_option(TVNC_BUILDSERVER "TurboVNC Server")
if(TVNC_BUILDNATIVE OR TVNC_BUILDSERVER)
set(USEC 1)
endif()
if(USEC)
enable_language(C)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
function(disable_compiler_warnings)
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w" PARENT_SCOPE)
endif()
if(CMAKE_C_COMPILER_ID MATCHES SunPro)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -erroff" PARENT_SCOPE)
endif()
endfunction()
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
if(UNIX OR (WIN32 AND NOT MINGW))
string(TIMESTAMP DEFAULT_BUILD "%Y%m%d")
set(BUILD ${DEFAULT_BUILD} CACHE STRING "Build string (default: ${DEFAULT_BUILD})")
else()
message(FATAL_ERROR "Platform not supported.")
endif()
message(STATUS "VERSION = ${VERSION}, BUILD = ${BUILD}")
if(UNIX)
set(CMAKE_INSTALL_DEFAULT_PREFIX /opt/${CMAKE_PROJECT_NAME})
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_DEFAULT_PREFIX}" CACHE PATH
"Directory into which to install ${CMAKE_PROJECT_NAME} (default: ${CMAKE_INSTALL_DEFAULT_PREFIX})"
FORCE)
endif()
endif()
message(STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}")
# When the prefix is /opt/${CMAKE_PROJECT_NAME}, we assume that an "official"
# build is being created, and thus we install things into specific locations.
if((UNIX AND CMAKE_INSTALL_PREFIX STREQUAL "${CMAKE_INSTALL_DEFAULT_PREFIX}")
OR WIN32)
set(CMAKE_INSTALL_DEFAULT_DATAROOTDIR "")
set(CMAKE_INSTALL_DEFAULT_DOCDIR "<CMAKE_INSTALL_DATAROOTDIR>/doc")
set(CMAKE_INSTALL_DEFAULT_SYSCONFDIR "${CMAKE_INSTALL_PREFIX}/etc")
endif()
if(WIN32)
set(CMAKE_INSTALL_DEFAULT_BINDIR ".")
endif()
include(cmakescripts/GNUInstallDirs.cmake)
macro(report_directory var)
if(CMAKE_INSTALL_${var} STREQUAL CMAKE_INSTALL_FULL_${var})
message(STATUS "CMAKE_INSTALL_${var} = ${CMAKE_INSTALL_${var}}")
else()
message(STATUS "CMAKE_INSTALL_${var} = ${CMAKE_INSTALL_${var}} (${CMAKE_INSTALL_FULL_${var}})")
endif()
mark_as_advanced(CLEAR CMAKE_INSTALL_${var})
endmacro()
set(DIRLIST "BINDIR;DATAROOTDIR;DATADIR;DOCDIR")
if(UNIX AND (TVNC_BUILDNATIVE OR TVNC_BUILDSERVER))
list(APPEND DIRLIST "MANDIR")
if(TVNC_BUILDSERVER)
list(APPEND DIRLIST "SYSCONFDIR")
endif()
endif()
foreach(dir ${DIRLIST})
report_directory(${dir})
endforeach()
# Detect CPU type and word size
if(USEC)
if(CMAKE_OSX_ARCHITECTURES MATCHES "ppc")
set(CMAKE_SYSTEM_PROCESSOR ppc)
endif()
math(EXPR BITS "${CMAKE_SIZEOF_VOID_P} * 8")
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} CMAKE_SYSTEM_PROCESSOR_LC)
if(CMAKE_SYSTEM_PROCESSOR_LC MATCHES "x86_64" OR
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "amd64" OR
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "i[0-9]86" OR
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "x86" OR
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "ia32")
if(BITS EQUAL 64)
set(CPU_TYPE x86_64)
else()
set(CPU_TYPE i386)
endif()
if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL ${CPU_TYPE})
set(CMAKE_SYSTEM_PROCESSOR ${CPU_TYPE})
endif()
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64" AND BITS EQUAL 32)
set(CPU_TYPE ppc)
set(CMAKE_SYSTEM_PROCESSOR ${CPU_TYPE})
else()
set(CPU_TYPE ${CMAKE_SYSTEM_PROCESSOR_LC})
endif()
message(STATUS "${BITS}-bit build (${CPU_TYPE})")
endif()
if((WIN32 AND TVNC_BUILDNATIVE) OR TVNC_BUILDSERVER)
include(cmakescripts/FindTurboJPEG.cmake)
endif()
###############################################################################
# BUILD
###############################################################################
if(TVNC_BUILDJAVA)
add_subdirectory(java)
endif()
if(WIN32 AND TVNC_BUILDNATIVE)
add_subdirectory(win)
endif()
if(UNIX AND (TVNC_BUILDNATIVE OR TVNC_BUILDSERVER))
add_subdirectory(unix)
endif()
add_subdirectory(doc)
###############################################################################
# INSTALLATION AND PACKAGING
###############################################################################
include(cmakescripts/BuildPackages.cmake)
configure_file("${CMAKE_SOURCE_DIR}/cmakescripts/cmake_uninstall.cmake.in"
"cmake_uninstall.cmake" IMMEDIATE @ONLY)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P cmake_uninstall.cmake)
if(CMAKE_INSTALL_PREFIX STREQUAL "${CMAKE_INSTALL_DEFAULT_PREFIX}" OR WIN32)
install(FILES README.txt DESTINATION .)
else()
install(FILES README.txt DESTINATION ${CMAKE_INSTALL_DOCDIR})
endif()