blob: 407bf67e58a3481e2d7c4c23c7359958363a99db [file] [log] [blame]
DRC180c0162010-10-27 07:20:27 +00001#
2# Setup
3#
4
DRCaeff3312011-06-07 04:51:57 +00005cmake_minimum_required(VERSION 2.8)
DRC180c0162010-10-27 07:20:27 +00006
Pierre Ossmanb232b5f2011-04-28 14:38:04 +00007# Internal cmake modules
8set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
9
Pierre Ossman7f443262011-03-08 13:06:46 +000010include(CheckIncludeFiles)
11include(CheckFunctionExists)
Pierre Ossmanb232b5f2011-04-28 14:38:04 +000012include(CheckLibraryExists)
Pierre Ossman7f443262011-03-08 13:06:46 +000013include(CheckTypeSize)
14include(CheckCSourceCompiles)
Pierre Ossman89f868a2011-04-11 11:59:31 +000015include(CheckCXXSourceCompiles)
DRC4e326a02011-07-28 08:06:39 +000016include(CheckCSourceRuns)
Pierre Ossman7f443262011-03-08 13:06:46 +000017
Henrik Andersson23029cc2011-06-09 09:13:23 +000018include(CMakeMacroLibtoolFile)
19
Peter Åstrandbb445ef2011-04-28 09:29:13 +000020project(tigervnc)
Pierre Ossman532e4e32014-11-19 14:19:30 +010021set(VERSION 1.4.80)
DRC180c0162010-10-27 07:20:27 +000022
23# The RC version must always be four comma-separated numbers
Pierre Ossman532e4e32014-11-19 14:19:30 +010024set(RCVERSION 1,4,80,0)
DRC180c0162010-10-27 07:20:27 +000025
Pierre Ossman95e28f72012-03-27 10:24:53 +000026# Installation paths
27set(BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin")
28set(DATA_DIR "${CMAKE_INSTALL_PREFIX}/share")
29set(MAN_DIR "${DATA_DIR}/man")
30set(LOCALE_DIR "${DATA_DIR}/locale")
31set(DOC_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/${CMAKE_PROJECT_NAME}-${VERSION}")
32
33if(WIN32)
34set(BIN_DIR "${CMAKE_INSTALL_PREFIX}")
35set(DOC_DIR "${CMAKE_INSTALL_PREFIX}")
36endif()
37
Pierre Ossmane8115162011-03-03 12:51:38 +000038if(MSVC)
DRC60d61582012-01-18 08:10:21 +000039 message(FATAL_ERROR "TigerVNC cannot be built with Visual Studio. Please use MinGW")
Pierre Ossmane8115162011-03-03 12:51:38 +000040endif()
41
Pierre Ossman5945d732014-09-22 13:13:15 +020042set(BUILD_TIMESTAMP "")
43execute_process(COMMAND "date" "+%Y-%m-%d %H:%M" OUTPUT_VARIABLE BUILD_TIMESTAMP)
DRCccc09692011-11-08 06:57:58 +000044
Pierre Ossman5945d732014-09-22 13:13:15 +020045if(NOT BUILD_TIMESTAMP)
46 set(BUILD_TIMESTAMP "")
Pierre Ossmane8115162011-03-03 12:51:38 +000047else()
Pierre Ossman5945d732014-09-22 13:13:15 +020048 string(REGEX REPLACE "\n" "" BUILD_TIMESTAMP ${BUILD_TIMESTAMP})
DRC180c0162010-10-27 07:20:27 +000049endif()
50
Pierre Ossman2c66a632011-03-03 12:52:59 +000051# Default to optimised builds instead of debug ones. Our code has no bugs ;)
52# (CMake makes it fairly easy to toggle this back to Debug if needed)
DRC180c0162010-10-27 07:20:27 +000053if(NOT CMAKE_BUILD_TYPE)
54 set(CMAKE_BUILD_TYPE Release)
55endif()
56
57message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
58
Pierre Ossman5945d732014-09-22 13:13:15 +020059message(STATUS "VERSION = ${VERSION}")
60add_definitions(-DBUILD_TIMESTAMP="${BUILD_TIMESTAMP}")
DRC180c0162010-10-27 07:20:27 +000061
Pierre Ossman8eaa1902014-03-19 12:43:51 +000062# We want to keep our asserts even in release builds so remove NDEBUG
63set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -UNDEBUG")
64set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -UNDEBUG")
65set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -UNDEBUG")
66set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -UNDEBUG")
67set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -UNDEBUG")
68set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -UNDEBUG")
69
Pierre Ossman7ca879f2015-03-03 16:02:03 +010070# Tell the compiler to be stringent
71set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wformat=2")
72set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wformat=2")
Pierre Ossman123d59c2015-03-03 16:50:47 +010073# Make sure we catch these issues whilst developing
74IF(CMAKE_BUILD_TYPE MATCHES Debug)
75 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
76 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
77 # We have a lot of old GnuTLS crud we need to ignore for now
78 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=deprecated-declarations")
79 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=deprecated-declarations")
80ENDIF()
Pierre Ossman7ca879f2015-03-03 16:02:03 +010081
DRC180c0162010-10-27 07:20:27 +000082if(NOT DEFINED BUILD_WINVNC)
DRC3080ec42011-10-12 20:00:55 +000083 set(BUILD_WINVNC 1)
DRC180c0162010-10-27 07:20:27 +000084endif()
85
Pierre Ossman9640f442011-03-08 13:12:33 +000086# Minimum version is Windows 2000 (5.0)
DRC2301beb2011-06-22 05:46:53 +000087if(WIN32)
88 if(NOT CMAKE_SIZEOF_VOID_P MATCHES 8)
89 add_definitions(-D_WIN32_IE=0x0500 -D_WIN32_WINNT=0x0500)
90 else()
DRC7cf9fbc2011-07-06 07:23:51 +000091 set(WIN64 1)
DRC2301beb2011-06-22 05:46:53 +000092 # Win64 doesn't like us requesting a Windows version that didn't have
93 # 64-bit support. Request XP (5.1) instead.
94 add_definitions(-D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501)
95 endif()
Pierre Ossman9640f442011-03-08 13:12:33 +000096endif()
97
Pierre Ossman69314c72011-03-08 12:18:13 +000098if(CMAKE_SIZEOF_VOID_P MATCHES 8)
DRC180c0162010-10-27 07:20:27 +000099 message(STATUS "64-bit build")
100else()
101 message(STATUS "32-bit build")
102endif()
103
104# CMake doesn't properly support resource compilation with MinGW. Boo!
105if(MINGW)
106 if(NOT DEFINED RC)
107 set(CMAKE_RC_COMPILER_INIT windres)
108 else()
109 set(CMAKE_RC_COMPILER_INIT ${RC})
110 endif()
111 enable_language(RC)
112 message(STATUS "Resource compiler: ${CMAKE_RC_COMPILER}")
113 set(CMAKE_RC_COMPILE_OBJECT
114 "<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> -o <OBJECT> --output-format=coff <SOURCE>")
115endif()
116
DRC3080ec42011-10-12 20:00:55 +0000117# MinGW64 has header support but no library support for IActiveDesktop, so we
118# need to check for both the header and library and use our own implementation
DRCccc09692011-11-08 06:57:58 +0000119# in common/os if either doesn't exist.
DRC3080ec42011-10-12 20:00:55 +0000120if(WIN32)
121 check_c_source_compiles("#include <windows.h>\n#include <wininet.h>\n#include <shlobj.h>\nint main(int c, char** v) {IActiveDesktop iad; return 0;}" HAVE_ACTIVE_DESKTOP_H)
122 check_c_source_compiles("#include <windows.h>\n#include <wininet.h>\n#include <shlobj.h>\nint main(int c, char** v) {GUID i = CLSID_ActiveDesktop; return 0;}" HAVE_ACTIVE_DESKTOP_L)
123endif()
124
Pierre Ossman8f64ef72011-03-08 16:32:49 +0000125# X11 stuff. It's in a if() so that we can say REQUIRED
DRC1b7abb92011-06-23 19:12:08 +0000126if(UNIX AND NOT APPLE)
Pierre Ossman8f64ef72011-03-08 16:32:49 +0000127 find_package(X11 REQUIRED)
128endif()
129
Pierre Ossmana7769f22011-03-03 09:44:49 +0000130# Check for zlib
131find_package(ZLIB)
132option(USE_INCLUDED_ZLIB "Force use of the bundled zlib")
133if(NOT ZLIB_FOUND)
Pierre Ossmana7769f22011-03-03 09:44:49 +0000134 set(USE_INCLUDED_ZLIB 1)
135endif()
DRCf340e7c2011-08-23 20:26:11 +0000136if(USE_INCLUDED_ZLIB)
137 message(STATUS "Using included zlib library")
138endif()
Pierre Ossmana7769f22011-03-03 09:44:49 +0000139
Peter Åstrandbb445ef2011-04-28 09:29:13 +0000140# Check for gettext
141option(ENABLE_NLS "Enable translation of program messages" ON)
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000142if(ENABLE_NLS)
143 # Tools
DRC2690f7a2011-06-24 04:17:02 +0000144 find_package(Gettext)
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000145
146 # Gettext needs iconv
DRC2690f7a2011-06-24 04:17:02 +0000147 find_package(Iconv)
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000148
DRC2690f7a2011-06-24 04:17:02 +0000149 if(ICONV_FOUND)
150 # Headers and libraries (copied from licq)
151 set(GETTEXT_FOUND FALSE)
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000152
DRC2690f7a2011-06-24 04:17:02 +0000153 find_path(GETTEXT_INCLUDE_DIR libintl.h)
154 if(GETTEXT_INCLUDE_DIR)
155 set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
156 check_function_exists(dgettext LIBC_HAS_DGETTEXT)
157 if(LIBC_HAS_DGETTEXT)
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000158 set(GETTEXT_FOUND TRUE)
DRC2690f7a2011-06-24 04:17:02 +0000159 else()
160 find_library(LIBINTL_LIBRARY NAMES intl libintl)
161 check_library_exists(${LIBINTL_LIBRARY} "dgettext" "" LIBINTL_HAS_DGETTEXT)
162 if(LIBINTL_HAS_DGETTEXT)
163 set(GETTEXT_LIBRARIES ${LIBINTL_LIBRARY} ${ICONV_LIBRARIES})
164 set(GETTEXT_FOUND TRUE)
165 endif()
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000166 endif()
DRC2690f7a2011-06-24 04:17:02 +0000167 set(CMAKE_REQUIRED_LIBRARIES)
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000168 endif()
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000169 endif()
170
DRC37596dd2011-11-08 08:38:58 +0000171 if(NOT GETTEXT_FOUND OR NOT ICONV_FOUND)
DRC2690f7a2011-06-24 04:17:02 +0000172 message(WARNING "Gettext NOT found. Native Language Support disabled.")
173 set(ENABLE_NLS 0)
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000174 endif()
175endif()
Peter Åstrandbb445ef2011-04-28 09:29:13 +0000176
Pierre Ossman4c6bd4c2011-03-03 09:55:21 +0000177# Check for libjpeg
178find_package(JPEG REQUIRED)
179
Pierre Ossman6fa07492011-03-04 11:35:24 +0000180# Warn if it doesn't seem to be the accelerated libjpeg that's found
DRC63b40b72011-06-07 01:47:38 +0000181set(CMAKE_REQUIRED_LIBRARIES ${JPEG_LIBRARIES})
182set(CMAKE_REQUIRED_FLAGS -I${JPEG_INCLUDE_DIR})
DRCfe06e612011-06-07 01:55:12 +0000183
DRCcebb1ce2011-08-01 20:25:40 +0000184set(JPEG_TEST_SOURCE "\n
DRC4e326a02011-07-28 08:06:39 +0000185 #include <stdio.h>\n
186 #include <jpeglib.h>\n
187 int main(void) {\n
188 struct jpeg_compress_struct cinfo;\n
189 struct jpeg_error_mgr jerr;\n
190 cinfo.err=jpeg_std_error(&jerr);\n
191 jpeg_create_compress(&cinfo);\n
192 cinfo.input_components = 3;\n
193 jpeg_set_defaults(&cinfo);\n
194 cinfo.in_color_space = JCS_EXT_RGB;\n
195 jpeg_default_colorspace(&cinfo);\n
196 return 0;\n
DRCcebb1ce2011-08-01 20:25:40 +0000197 }")
198
199if(CMAKE_CROSSCOMPILING)
200 check_c_source_compiles("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO)
201else()
202 check_c_source_runs("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO)
203endif()
DRCfe06e612011-06-07 01:55:12 +0000204
205set(CMAKE_REQUIRED_LIBRARIES)
206set(CMAKE_REQUIRED_FLAGS)
DRC4e326a02011-07-28 08:06:39 +0000207set(CMAKE_REQUIRED_DEFINITIONS)
DRCfe06e612011-06-07 01:55:12 +0000208
DRC1953b512011-06-24 04:19:36 +0000209if(NOT FOUND_LIBJPEG_TURBO)
Pierre Ossman6fa07492011-03-04 11:35:24 +0000210 message(STATUS "WARNING: You are not using libjpeg-turbo. Performance will suffer.")
211endif()
212
DRC7636ad02011-10-04 04:03:34 +0000213option(BUILD_JAVA "Build Java version of the TigerVNC Viewer" FALSE)
214if(BUILD_JAVA)
DRCc19ab9e2011-10-07 05:38:00 +0000215 add_subdirectory(java)
DRC7636ad02011-10-04 04:03:34 +0000216endif()
217
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000218# Check for FLTK
DRC3591fa52011-11-03 19:01:18 +0000219set(FLTK_SKIP_FLUID TRUE)
220set(FLTK_SKIP_OPENGL TRUE)
DRC3591fa52011-11-03 19:01:18 +0000221set(FLTK_SKIP_FORMS TRUE)
222find_package(FLTK)
Pierre Ossman89f868a2011-04-11 11:59:31 +0000223
DRC16457a22012-01-17 23:33:29 +0000224if(UNIX AND NOT APPLE)
DRC3591fa52011-11-03 19:01:18 +0000225 # No proper handling for extra X11 libs that FLTK might need...
226 if(X11_Xft_FOUND)
Pierre Ossmane43d1aa2012-03-27 10:29:50 +0000227 # Xft headers include references to fontconfig, so we need
228 # to link to that as well
229 find_library(FONTCONFIG_LIB fontconfig)
230 set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xft_LIB} ${FONTCONFIG_LIB})
Pierre Ossman835b4ef2011-06-08 17:02:36 +0000231 endif()
DRC3591fa52011-11-03 19:01:18 +0000232 if(X11_Xinerama_FOUND)
233 set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xinerama_LIB})
DRC2ff39b82011-07-28 08:38:59 +0000234 endif()
DRC3591fa52011-11-03 19:01:18 +0000235 if(X11_Xfixes_FOUND)
236 set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xfixes_LIB})
DRC2ff39b82011-07-28 08:38:59 +0000237 endif()
DRC3591fa52011-11-03 19:01:18 +0000238 if(X11_Xcursor_FOUND)
239 set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xcursor_LIB})
DRC2ff39b82011-07-28 08:38:59 +0000240 endif()
Peter Åstrand (astrand)c4bc5a82015-02-10 12:21:05 +0100241 if(X11_Xrender_FOUND)
242 set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xrender_LIB})
243 endif()
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000244endif()
245
DRC3591fa52011-11-03 19:01:18 +0000246if(FLTK_FOUND)
247 set(CMAKE_REQUIRED_INCLUDES ${FLTK_INCLUDE_DIR})
248 set(CMAKE_REQUIRED_LIBRARIES ${FLTK_LIBRARIES})
249
DRC3591fa52011-11-03 19:01:18 +0000250 # FLTK STR #2636
251 check_cxx_source_compiles("#include <FL/Fl.H>\nint main(int c, char** v) { Fl::add_clipboard_notify(NULL, NULL); return 0; }" HAVE_FLTK_CLIPBOARD)
252
253 # FLTK STR #2638
254 check_cxx_source_compiles("#include <FL/Enumerations.H>\nint main(int c, char** v) { return FL_Volume_Down; }" HAVE_FLTK_MEDIAKEYS)
255
256 # FLTK STR #2641
257 check_cxx_source_compiles("#include <FL/Enumerations.H>\nint main(int c, char** v) { return FL_FULLSCREEN; }" HAVE_FLTK_FULLSCREEN)
258
259 # FLTK STR #2660
260 check_cxx_source_compiles("#include <FL/Fl_Window.H>\nint main(int c, char** v) { void (Fl_Window::*foo)(const Fl_RGB_Image*,int,int) = &Fl_Window::cursor; return 0; }" HAVE_FLTK_CURSOR)
261
Pierre Ossman208b2ea2012-10-24 08:28:18 +0000262 # FLTK STR #2697
263 check_cxx_source_compiles("#include <FL/Fl.H>\nint main(int c, char** v) { int X, Y, W, H; Fl::screen_work_area(X, Y, W, H); return 0; }" HAVE_FLTK_WORK_AREA)
264
Pierre Ossman8eb35082012-03-27 12:50:54 +0000265 # FLTK STR #2816
266 check_cxx_source_compiles("#include <FL/Fl_Window.H>\nint main(int c, char** v) { Fl_Window::default_icons(0, 0); return 0; }" HAVE_FLTK_ICONS)
267
Pierre Ossmanaae38912012-07-13 11:22:55 +0000268 # FLTK STR #2860
269 check_cxx_source_compiles("#include <FL/Fl_Window.H>\nint main(int c, char** v) { void (Fl_Window::*foo)(int,int,int,int) = &Fl_Window::fullscreen_screens; return 0; }" HAVE_FLTK_FULLSCREEN_SCREENS)
270
Pierre Ossman4f3ac692014-08-22 15:10:22 +0200271 # FLTK STR #xxxx
Pierre Ossman64ff1ca2014-09-11 10:48:29 +0200272 check_cxx_source_compiles("#include <FL/Fl.H>\nint main(int c, char** v) { Fl::add_system_handler(NULL, NULL); return 0; }" HAVE_FLTK_XHANDLERS)
Pierre Ossman4f3ac692014-08-22 15:10:22 +0200273
Pierre Ossman6d66d6d2014-09-11 10:46:12 +0200274 # FLTK STR #xxxx
275 check_cxx_source_compiles("#include <FL/Fl.H>\nint main(int c, char** v) { Fl::disable_im(); return 0; }" HAVE_FLTK_IM)
276
DRC3591fa52011-11-03 19:01:18 +0000277 set(CMAKE_REQUIRED_INCLUDES)
278 set(CMAKE_REQUIRED_LIBRARIES)
279endif()
280
Adam Tkac125bd252011-01-19 14:20:34 +0000281# Check for GNUTLS library
Pierre Ossman95064202011-05-30 12:22:39 +0000282option(ENABLE_GNUTLS "Enable protocol encryption and advanced authentication" ON)
Pierre Ossman32c88c42011-05-27 11:50:58 +0000283if(ENABLE_GNUTLS)
Pierre Ossman95064202011-05-30 12:22:39 +0000284 find_package(GnuTLS)
285 if (GNUTLS_FOUND)
286 include_directories(${GNUTLS_INCLUDE_DIR})
287 add_definitions("-DHAVE_GNUTLS")
288 add_definitions(${GNUTLS_DEFINITIONS})
289
290 # Detect old version of GnuTLS
DRC17331b92011-06-07 04:07:20 +0000291 set(CMAKE_REQUIRED_FLAGS -I${GNUTLS_INCLUDE_DIR})
Pierre Ossman95064202011-05-30 12:22:39 +0000292 set(CMAKE_EXTRA_INCLUDE_FILES gnutls/gnutls.h)
DRC17331b92011-06-07 04:07:20 +0000293 set(CMAKE_REQUIRED_LIBRARIES ${GNUTLS_LIBRARIES})
DRC56e625c2011-06-24 03:19:28 +0000294 if(WIN32)
DRC56e625c2011-06-24 03:19:28 +0000295 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ws2_32 user32)
296 endif()
DRC17331b92011-06-07 04:07:20 +0000297 if(ZLIB_FOUND)
298 # When we build against the static version of GnuTLS, we also use the
299 # included version of Zlib, but it isn't built yet, so we have to use the
300 # system's version (if available) to perform this test.
301 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES};-lz)
302 endif()
Pierre Ossman2137f4f2012-07-03 14:52:26 +0000303 check_function_exists(gnutls_transport_set_errno HAVE_GNUTLS_SET_ERRNO)
304 check_function_exists(gnutls_transport_set_global_errno HAVE_GNUTLS_SET_GLOBAL_ERRNO)
Pierre Ossman95064202011-05-30 12:22:39 +0000305 check_function_exists(gnutls_x509_crt_print HAVE_GNUTLS_X509_CRT_PRINT)
306 check_type_size(gnutls_x509_crt_t GNUTLS_X509_CRT_T)
307 check_type_size(gnutls_datum_t GNUTLS_DATUM_T)
308 check_type_size(gnutls_pk_algorithm_t GNUTLS_PK_ALGORITHM_T)
309 check_type_size(gnutls_sign_algorithm_t GNUTLS_SIGN_ALGORITHM_T)
DRC17331b92011-06-07 04:07:20 +0000310 set(CMAKE_REQUIRED_FLAGS)
Pierre Ossman95064202011-05-30 12:22:39 +0000311 set(CMAKE_EXTRA_INCLUDE_FILES)
312 set(CMAKE_REQUIRED_LIBRARIES)
313 endif()
Adam Tkac125bd252011-01-19 14:20:34 +0000314endif()
315
DRC777290b2011-06-22 00:18:17 +0000316# Check for PAM library
317option(ENABLE_PAM "Enable PAM authentication support" ON)
318if(ENABLE_PAM)
319 check_include_files(security/pam_appl.h HAVE_PAM_H)
320 set(CMAKE_REQUIRED_LIBRARIES -lpam)
321 check_function_exists(pam_start HAVE_PAM_START)
322 set(CMAKE_REQUIRED_LIBRARIES)
323 if(HAVE_PAM_H AND HAVE_PAM_START)
324 set(PAM_LIBS pam)
325 else()
326 set(ENABLE_PAM 0)
327 endif()
328endif()
329set(HAVE_PAM ${ENABLE_PAM})
330
Pierre Ossmanee0e3622011-03-08 13:08:15 +0000331# Check for socket functions
Henrik Anderssone1fd8e12011-03-08 13:00:12 +0000332if(WIN32)
Pierre Ossman0153e232011-03-08 13:05:27 +0000333 set(CMAKE_EXTRA_INCLUDE_FILES winsock2.h ws2tcpip.h)
Henrik Anderssone1fd8e12011-03-08 13:00:12 +0000334 set(CMAKE_REQUIRED_LIBRARIES ws2_32)
Pierre Ossman0153e232011-03-08 13:05:27 +0000335else()
336 set(CMAKE_EXTRA_INCLUDE_FILES sys/socket.h)
Henrik Anderssone1fd8e12011-03-08 13:00:12 +0000337endif()
DRC63758092010-11-09 19:24:12 +0000338check_function_exists(inet_aton HAVE_INET_ATON)
Pierre Ossman820c0ce2014-11-19 14:16:00 +0100339# This might give a false positive on Windows as it is also guarded by
340# a version check that we do not satisfy (requires Vista, but we target
341# Windows 2000).
342if(NOT WIN32)
Tim Waugh6abf3f42014-11-12 12:31:51 +0000343check_function_exists(inet_pton HAVE_INET_PTON)
Pierre Ossman820c0ce2014-11-19 14:16:00 +0100344endif()
Pierre Ossman32c46222012-12-13 13:56:28 +0000345check_function_exists(getaddrinfo HAVE_GETADDRINFO)
DRC63758092010-11-09 19:24:12 +0000346set(CMAKE_EXTRA_INCLUDE_FILES)
347set(CMAKE_REQUIRED_LIBRARIES)
Pierre Ossmanee0e3622011-03-08 13:08:15 +0000348
Pierre Ossmanee0e3622011-03-08 13:08:15 +0000349# Generate config.h and make sure the source finds it
DRC1980dd52011-06-24 19:28:27 +0000350configure_file(config.h.in config.h)
DRC63758092010-11-09 19:24:12 +0000351add_definitions(-DHAVE_CONFIG_H)
352include_directories(${CMAKE_BINARY_DIR})
DRC180c0162010-10-27 07:20:27 +0000353
Pierre Ossmanf95272d2014-10-17 13:59:35 +0200354include(cmake/StaticBuild.cmake)
355
DRC180c0162010-10-27 07:20:27 +0000356add_subdirectory(common)
Pierre Ossman8f64ef72011-03-08 16:32:49 +0000357
358if(WIN32)
359 add_subdirectory(win)
360else()
Henrik Anderssona7a38a62011-06-10 13:05:09 +0000361 # No interest in building x related parts on Apple
362 if(NOT APPLE)
363 add_subdirectory(unix)
364 endif()
Pierre Ossman8f64ef72011-03-08 16:32:49 +0000365endif()
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000366
DRC3591fa52011-11-03 19:01:18 +0000367if(ENABLE_NLS)
368 add_subdirectory(po)
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000369endif()
Pierre Ossman64127702012-03-27 12:33:36 +0000370
Peter Åstrand889b4892014-02-20 08:04:17 +0000371option(BUILD_VIEWER "Build TigerVNC viewer" ON)
372if(BUILD_VIEWER)
373 add_subdirectory(vncviewer)
374 add_subdirectory(media)
375endif()
DRC1a184072011-06-24 06:55:18 +0000376
Pierre Ossman236c03c2014-07-04 14:12:49 +0200377add_subdirectory(tests)
378
Pierre Ossman64127702012-03-27 12:33:36 +0000379
DRC1a184072011-06-24 06:55:18 +0000380include(cmake/BuildPackages.cmake)
DRCb7140022011-06-25 07:33:57 +0000381
382# uninstall
383configure_file("${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
384 "cmake_uninstall.cmake" IMMEDIATE @ONLY)
385
386add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P cmake_uninstall.cmake)