blob: c375314a3ab99fa13ef196c61b06f30022565361 [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)
DRC550a4df2012-02-12 22:10:01 +000021set(VERSION 1.2.80)
DRC180c0162010-10-27 07:20:27 +000022
23# The RC version must always be four comma-separated numbers
DRC550a4df2012-02-12 22:10:01 +000024set(RCVERSION 1,2,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
DRCccc09692011-11-08 06:57:58 +000042set(BUILD "")
43execute_process(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE BUILD)
44
Pierre Ossmane8115162011-03-03 12:51:38 +000045if(NOT BUILD)
46 set(BUILD "")
47else()
48 string(REGEX REPLACE "\n" "" BUILD ${BUILD})
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
DRC180c0162010-10-27 07:20:27 +000059if(CMAKE_BUILD_TYPE STREQUAL "Debug")
60 set(BUILD "${BUILD}d")
61endif()
62
63message(STATUS "VERSION = ${VERSION}, BUILD = ${BUILD}")
DRCd8e93dc2011-07-28 22:13:40 +000064add_definitions(-D__BUILD__="${BUILD}")
DRC180c0162010-10-27 07:20:27 +000065
66if(NOT DEFINED BUILD_WINVNC)
DRC3080ec42011-10-12 20:00:55 +000067 set(BUILD_WINVNC 1)
DRC180c0162010-10-27 07:20:27 +000068endif()
69
Pierre Ossman9640f442011-03-08 13:12:33 +000070# Minimum version is Windows 2000 (5.0)
DRC2301beb2011-06-22 05:46:53 +000071if(WIN32)
72 if(NOT CMAKE_SIZEOF_VOID_P MATCHES 8)
73 add_definitions(-D_WIN32_IE=0x0500 -D_WIN32_WINNT=0x0500)
74 else()
DRC7cf9fbc2011-07-06 07:23:51 +000075 set(WIN64 1)
DRC2301beb2011-06-22 05:46:53 +000076 # Win64 doesn't like us requesting a Windows version that didn't have
77 # 64-bit support. Request XP (5.1) instead.
78 add_definitions(-D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501)
79 endif()
Pierre Ossman9640f442011-03-08 13:12:33 +000080endif()
81
Pierre Ossman69314c72011-03-08 12:18:13 +000082if(CMAKE_SIZEOF_VOID_P MATCHES 8)
DRC180c0162010-10-27 07:20:27 +000083 message(STATUS "64-bit build")
84else()
85 message(STATUS "32-bit build")
86endif()
87
DRC883f2d62011-07-28 09:58:24 +000088# This ensures that we don't depend on libstdc++ or libgcc
89if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE AND NOT CYGWIN)
90 option(BUILD_STATIC
91 "Link statically against libgcc and libstdc++, if possible" OFF)
92 if(BUILD_STATIC)
93 # For some reason, simply passing ${CMAKE_CXX_FLAGS} to the compiler in
94 # execute_process() doesn't work. Grrr...
DRCca917582011-08-08 03:22:15 +000095 if(CMAKE_SIZEOF_VOID_P MATCHES 8)
DRC883f2d62011-07-28 09:58:24 +000096 execute_process(COMMAND ${CMAKE_CXX_COMPILER} -m64
97 --print-file-name=libstdc++.a OUTPUT_VARIABLE LIBSTDCPLUSPLUS
98 RESULT_VARIABLE RESULT)
99 else()
100 execute_process(COMMAND ${CMAKE_CXX_COMPILER} -m32
101 --print-file-name=libstdc++.a OUTPUT_VARIABLE LIBSTDCPLUSPLUS
102 RESULT_VARIABLE RESULT)
103 endif()
104 string(REGEX REPLACE "\n" "" LIBSTDCPLUSPLUS ${LIBSTDCPLUSPLUS})
105 if(RESULT MATCHES 0 AND LIBSTDCPLUSPLUS)
106 message(STATUS "Linking with static libstdc++:\n ${LIBSTDCPLUSPLUS}")
107 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/staticlib)
108 execute_process(COMMAND ${CMAKE_COMMAND} -E remove
109 ${CMAKE_BINARY_DIR}/staticlib/libstdc++.a)
DRCe4e604f2011-10-01 17:54:36 +0000110 if(MINGW)
111 execute_process(COMMAND ${CMAKE_COMMAND} -E copy
112 ${LIBSTDCPLUSPLUS} ${CMAKE_BINARY_DIR}/staticlib/libstdc++.a)
113 else()
114 execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
115 ${LIBSTDCPLUSPLUS} ${CMAKE_BINARY_DIR}/staticlib/libstdc++.a)
116 endif()
DRC883f2d62011-07-28 09:58:24 +0000117 set(CMAKE_EXE_LINKER_FLAGS
118 "${CMAKE_EXE_LINKER_FLAGS} -L${CMAKE_BINARY_DIR}/staticlib")
119 set(CMAKE_SHARED_LINKER_FLAGS
120 "${CMAKE_SHARED_LINKER_FLAGS} -L${CMAKE_BINARY_DIR}/staticlib")
121 else()
DRCe4e604f2011-10-01 17:54:36 +0000122 message(WARNING Cannot find static libstdc++. TigerVNC will depend on dynamic libstdc++.)
DRC883f2d62011-07-28 09:58:24 +0000123 endif()
DRC7f2f25b2011-10-12 21:29:34 +0000124 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc")
DRC883f2d62011-07-28 09:58:24 +0000125 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc")
126 set(CMAKE_SHARED_LINKER_FLAGS
127 "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc")
128 endif()
129endif()
130
DRC180c0162010-10-27 07:20:27 +0000131# CMake doesn't properly support resource compilation with MinGW. Boo!
132if(MINGW)
133 if(NOT DEFINED RC)
134 set(CMAKE_RC_COMPILER_INIT windres)
135 else()
136 set(CMAKE_RC_COMPILER_INIT ${RC})
137 endif()
138 enable_language(RC)
139 message(STATUS "Resource compiler: ${CMAKE_RC_COMPILER}")
140 set(CMAKE_RC_COMPILE_OBJECT
141 "<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> -o <OBJECT> --output-format=coff <SOURCE>")
142endif()
143
DRC3080ec42011-10-12 20:00:55 +0000144# MinGW64 has header support but no library support for IActiveDesktop, so we
145# need to check for both the header and library and use our own implementation
DRCccc09692011-11-08 06:57:58 +0000146# in common/os if either doesn't exist.
DRC3080ec42011-10-12 20:00:55 +0000147if(WIN32)
148 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)
149 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)
150endif()
151
Pierre Ossman8f64ef72011-03-08 16:32:49 +0000152# X11 stuff. It's in a if() so that we can say REQUIRED
DRC1b7abb92011-06-23 19:12:08 +0000153if(UNIX AND NOT APPLE)
Pierre Ossman8f64ef72011-03-08 16:32:49 +0000154 find_package(X11 REQUIRED)
155endif()
156
Pierre Ossmana7769f22011-03-03 09:44:49 +0000157# Check for zlib
158find_package(ZLIB)
159option(USE_INCLUDED_ZLIB "Force use of the bundled zlib")
160if(NOT ZLIB_FOUND)
Pierre Ossmana7769f22011-03-03 09:44:49 +0000161 set(USE_INCLUDED_ZLIB 1)
162endif()
DRCf340e7c2011-08-23 20:26:11 +0000163if(USE_INCLUDED_ZLIB)
164 message(STATUS "Using included zlib library")
165endif()
Pierre Ossmana7769f22011-03-03 09:44:49 +0000166
Peter Åstrandbb445ef2011-04-28 09:29:13 +0000167# Check for gettext
168option(ENABLE_NLS "Enable translation of program messages" ON)
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000169if(ENABLE_NLS)
170 # Tools
DRC2690f7a2011-06-24 04:17:02 +0000171 find_package(Gettext)
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000172
173 # Gettext needs iconv
DRC2690f7a2011-06-24 04:17:02 +0000174 find_package(Iconv)
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000175
DRC2690f7a2011-06-24 04:17:02 +0000176 if(ICONV_FOUND)
177 # Headers and libraries (copied from licq)
178 set(GETTEXT_FOUND FALSE)
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000179
DRC2690f7a2011-06-24 04:17:02 +0000180 find_path(GETTEXT_INCLUDE_DIR libintl.h)
181 if(GETTEXT_INCLUDE_DIR)
182 set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
183 check_function_exists(dgettext LIBC_HAS_DGETTEXT)
184 if(LIBC_HAS_DGETTEXT)
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000185 set(GETTEXT_FOUND TRUE)
DRC2690f7a2011-06-24 04:17:02 +0000186 else()
187 find_library(LIBINTL_LIBRARY NAMES intl libintl)
188 check_library_exists(${LIBINTL_LIBRARY} "dgettext" "" LIBINTL_HAS_DGETTEXT)
189 if(LIBINTL_HAS_DGETTEXT)
190 set(GETTEXT_LIBRARIES ${LIBINTL_LIBRARY} ${ICONV_LIBRARIES})
191 set(GETTEXT_FOUND TRUE)
192 endif()
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000193 endif()
DRC2690f7a2011-06-24 04:17:02 +0000194 set(CMAKE_REQUIRED_LIBRARIES)
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000195 endif()
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000196 endif()
197
DRC37596dd2011-11-08 08:38:58 +0000198 if(NOT GETTEXT_FOUND OR NOT ICONV_FOUND)
DRC2690f7a2011-06-24 04:17:02 +0000199 message(WARNING "Gettext NOT found. Native Language Support disabled.")
200 set(ENABLE_NLS 0)
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000201 endif()
202endif()
Peter Åstrandbb445ef2011-04-28 09:29:13 +0000203
Pierre Ossman4c6bd4c2011-03-03 09:55:21 +0000204# Check for libjpeg
205find_package(JPEG REQUIRED)
206
Pierre Ossman6fa07492011-03-04 11:35:24 +0000207# Warn if it doesn't seem to be the accelerated libjpeg that's found
DRC63b40b72011-06-07 01:47:38 +0000208set(CMAKE_REQUIRED_LIBRARIES ${JPEG_LIBRARIES})
209set(CMAKE_REQUIRED_FLAGS -I${JPEG_INCLUDE_DIR})
DRCfe06e612011-06-07 01:55:12 +0000210
DRCcebb1ce2011-08-01 20:25:40 +0000211set(JPEG_TEST_SOURCE "\n
DRC4e326a02011-07-28 08:06:39 +0000212 #include <stdio.h>\n
213 #include <jpeglib.h>\n
214 int main(void) {\n
215 struct jpeg_compress_struct cinfo;\n
216 struct jpeg_error_mgr jerr;\n
217 cinfo.err=jpeg_std_error(&jerr);\n
218 jpeg_create_compress(&cinfo);\n
219 cinfo.input_components = 3;\n
220 jpeg_set_defaults(&cinfo);\n
221 cinfo.in_color_space = JCS_EXT_RGB;\n
222 jpeg_default_colorspace(&cinfo);\n
223 return 0;\n
DRCcebb1ce2011-08-01 20:25:40 +0000224 }")
225
226if(CMAKE_CROSSCOMPILING)
227 check_c_source_compiles("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO)
228else()
229 check_c_source_runs("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO)
230endif()
DRCfe06e612011-06-07 01:55:12 +0000231
232set(CMAKE_REQUIRED_LIBRARIES)
233set(CMAKE_REQUIRED_FLAGS)
DRC4e326a02011-07-28 08:06:39 +0000234set(CMAKE_REQUIRED_DEFINITIONS)
DRCfe06e612011-06-07 01:55:12 +0000235
DRC1953b512011-06-24 04:19:36 +0000236if(NOT FOUND_LIBJPEG_TURBO)
Pierre Ossman6fa07492011-03-04 11:35:24 +0000237 message(STATUS "WARNING: You are not using libjpeg-turbo. Performance will suffer.")
238endif()
239
DRC7636ad02011-10-04 04:03:34 +0000240option(BUILD_JAVA "Build Java version of the TigerVNC Viewer" FALSE)
241if(BUILD_JAVA)
DRCc19ab9e2011-10-07 05:38:00 +0000242 add_subdirectory(java)
DRC7636ad02011-10-04 04:03:34 +0000243endif()
244
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000245# Check for FLTK
DRC3591fa52011-11-03 19:01:18 +0000246set(FLTK_SKIP_FLUID TRUE)
247set(FLTK_SKIP_OPENGL TRUE)
DRC3591fa52011-11-03 19:01:18 +0000248set(FLTK_SKIP_FORMS TRUE)
249find_package(FLTK)
Pierre Ossman89f868a2011-04-11 11:59:31 +0000250
DRC16457a22012-01-17 23:33:29 +0000251if(UNIX AND NOT APPLE)
DRC3591fa52011-11-03 19:01:18 +0000252 # No proper handling for extra X11 libs that FLTK might need...
253 if(X11_Xft_FOUND)
Pierre Ossmane43d1aa2012-03-27 10:29:50 +0000254 # Xft headers include references to fontconfig, so we need
255 # to link to that as well
256 find_library(FONTCONFIG_LIB fontconfig)
257 set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xft_LIB} ${FONTCONFIG_LIB})
Pierre Ossman835b4ef2011-06-08 17:02:36 +0000258 endif()
DRC3591fa52011-11-03 19:01:18 +0000259 if(X11_Xinerama_FOUND)
260 set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xinerama_LIB})
DRC2ff39b82011-07-28 08:38:59 +0000261 endif()
DRC3591fa52011-11-03 19:01:18 +0000262 if(X11_Xfixes_FOUND)
263 set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xfixes_LIB})
DRC2ff39b82011-07-28 08:38:59 +0000264 endif()
DRC3591fa52011-11-03 19:01:18 +0000265 if(X11_Xcursor_FOUND)
266 set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xcursor_LIB})
DRC2ff39b82011-07-28 08:38:59 +0000267 endif()
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000268endif()
269
DRC3591fa52011-11-03 19:01:18 +0000270if(FLTK_FOUND)
271 set(CMAKE_REQUIRED_INCLUDES ${FLTK_INCLUDE_DIR})
272 set(CMAKE_REQUIRED_LIBRARIES ${FLTK_LIBRARIES})
273
274 # FLTK STR #2599
275 check_cxx_source_compiles("#include <FL/Fl_Widget.H>\nint main(int c, char** v) { void (Fl_Widget::*foo)() = &Fl_Widget::set_simple_keyboard; return 0; }" HAVE_FLTK_DEAD_KEYS)
276
277 # FLTK STR #2636
278 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)
279
280 # FLTK STR #2638
281 check_cxx_source_compiles("#include <FL/Enumerations.H>\nint main(int c, char** v) { return FL_Volume_Down; }" HAVE_FLTK_MEDIAKEYS)
282
283 # FLTK STR #2641
284 check_cxx_source_compiles("#include <FL/Enumerations.H>\nint main(int c, char** v) { return FL_FULLSCREEN; }" HAVE_FLTK_FULLSCREEN)
285
286 # FLTK STR #2660
287 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)
288
Pierre Ossman8eb35082012-03-27 12:50:54 +0000289 # FLTK STR #2816
290 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)
291
Pierre Ossmanaae38912012-07-13 11:22:55 +0000292 # FLTK STR #2860
293 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)
294
DRC3591fa52011-11-03 19:01:18 +0000295 set(CMAKE_REQUIRED_INCLUDES)
296 set(CMAKE_REQUIRED_LIBRARIES)
297endif()
298
299option(USE_INCLUDED_FLTK
300 "Force the use of the FLTK library bundled with the TigerVNC source")
301if(NOT FLTK_FOUND OR NOT HAVE_FLTK_DEAD_KEYS OR NOT HAVE_FLTK_CLIPBOARD
302 OR NOT HAVE_FLTK_MEDIAKEYS OR NOT HAVE_FLTK_FULLSCREEN
Pierre Ossman8eb35082012-03-27 12:50:54 +0000303 OR NOT HAVE_FLTK_CURSOR OR NOT HAVE_FLTK_ICONS)
DRC3591fa52011-11-03 19:01:18 +0000304 set(USE_INCLUDED_FLTK 1)
305endif()
306if(USE_INCLUDED_FLTK)
Pierre Ossman2f4fd6b2012-01-23 15:43:42 +0000307 # Check that we have the proper dependencies
308 if(UNIX AND NOT APPLE)
309 if(NOT X11_Xft_FOUND)
310 message(FATAL_ERROR "Xft headers/libraries not found (needed by FLTK.)")
311 endif()
312 if(NOT X11_Xinerama_FOUND)
313 message(FATAL_ERROR "Xinerama headers/libraries not found (needed by FLTK.)")
314 endif()
315 if(NOT X11_Xfixes_FOUND)
316 message(FATAL_ERROR "Xfixes headers/libraries not found (needed by FLTK.)")
317 endif()
318 if(NOT X11_Xcursor_FOUND)
319 message(FATAL_ERROR "Xcursor headers/libraries not found (needed by FLTK.)")
320 endif()
321 endif()
322
DRC9462d6f2011-12-31 17:55:38 +0000323 set(HAVE_FLTK_DEAD_KEYS 1)
324 set(HAVE_FLTK_CLIPBOARD 1)
325 set(HAVE_FLTK_MEDIAKEYS 1)
326 set(HAVE_FLTK_FULLSCREEN 1)
327 set(HAVE_FLTK_CURSOR 1)
Pierre Ossman8eb35082012-03-27 12:50:54 +0000328 set(HAVE_FLTK_ICONS 1)
DRC3591fa52011-11-03 19:01:18 +0000329 set(FLTK_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/common/fltk)
330 set(FLTK_LIBRARIES)
331 if(APPLE)
332 set(FLTK_LIBRARIES "-framework Carbon -framework Cocoa -framework ApplicationServices")
333 elseif(NOT WIN32)
334 set(FLTK_LIBRARIES "-ldl")
335 endif()
336 message(STATUS "Using included FLTK library")
337endif()
DRC0141bd52012-01-17 22:33:45 +0000338
Adam Tkac125bd252011-01-19 14:20:34 +0000339# Check for GNUTLS library
Pierre Ossman95064202011-05-30 12:22:39 +0000340option(ENABLE_GNUTLS "Enable protocol encryption and advanced authentication" ON)
Pierre Ossman32c88c42011-05-27 11:50:58 +0000341if(ENABLE_GNUTLS)
Pierre Ossman95064202011-05-30 12:22:39 +0000342 find_package(GnuTLS)
343 if (GNUTLS_FOUND)
344 include_directories(${GNUTLS_INCLUDE_DIR})
345 add_definitions("-DHAVE_GNUTLS")
346 add_definitions(${GNUTLS_DEFINITIONS})
347
348 # Detect old version of GnuTLS
DRC17331b92011-06-07 04:07:20 +0000349 set(CMAKE_REQUIRED_FLAGS -I${GNUTLS_INCLUDE_DIR})
Pierre Ossman95064202011-05-30 12:22:39 +0000350 set(CMAKE_EXTRA_INCLUDE_FILES gnutls/gnutls.h)
DRC17331b92011-06-07 04:07:20 +0000351 set(CMAKE_REQUIRED_LIBRARIES ${GNUTLS_LIBRARIES})
DRC56e625c2011-06-24 03:19:28 +0000352 if(WIN32)
353 set(CMAKE_EXTRA_INCLUDE_FILES gcrypt.h ${CMAKE_EXTRA_INCLUDE_FILES})
354 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ws2_32 user32)
355 endif()
DRC17331b92011-06-07 04:07:20 +0000356 if(ZLIB_FOUND)
357 # When we build against the static version of GnuTLS, we also use the
358 # included version of Zlib, but it isn't built yet, so we have to use the
359 # system's version (if available) to perform this test.
360 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES};-lz)
361 endif()
Pierre Ossman2137f4f2012-07-03 14:52:26 +0000362 check_function_exists(gnutls_transport_set_errno HAVE_GNUTLS_SET_ERRNO)
363 check_function_exists(gnutls_transport_set_global_errno HAVE_GNUTLS_SET_GLOBAL_ERRNO)
Pierre Ossman95064202011-05-30 12:22:39 +0000364 check_function_exists(gnutls_x509_crt_print HAVE_GNUTLS_X509_CRT_PRINT)
365 check_type_size(gnutls_x509_crt_t GNUTLS_X509_CRT_T)
366 check_type_size(gnutls_datum_t GNUTLS_DATUM_T)
367 check_type_size(gnutls_pk_algorithm_t GNUTLS_PK_ALGORITHM_T)
368 check_type_size(gnutls_sign_algorithm_t GNUTLS_SIGN_ALGORITHM_T)
DRC17331b92011-06-07 04:07:20 +0000369 set(CMAKE_REQUIRED_FLAGS)
Pierre Ossman95064202011-05-30 12:22:39 +0000370 set(CMAKE_EXTRA_INCLUDE_FILES)
371 set(CMAKE_REQUIRED_LIBRARIES)
372 endif()
Adam Tkac125bd252011-01-19 14:20:34 +0000373endif()
374
DRC777290b2011-06-22 00:18:17 +0000375# Check for PAM library
376option(ENABLE_PAM "Enable PAM authentication support" ON)
377if(ENABLE_PAM)
378 check_include_files(security/pam_appl.h HAVE_PAM_H)
379 set(CMAKE_REQUIRED_LIBRARIES -lpam)
380 check_function_exists(pam_start HAVE_PAM_START)
381 set(CMAKE_REQUIRED_LIBRARIES)
382 if(HAVE_PAM_H AND HAVE_PAM_START)
383 set(PAM_LIBS pam)
384 else()
385 set(ENABLE_PAM 0)
386 endif()
387endif()
388set(HAVE_PAM ${ENABLE_PAM})
389
Pierre Ossmanee0e3622011-03-08 13:08:15 +0000390# Check for socket functions
Henrik Anderssone1fd8e12011-03-08 13:00:12 +0000391if(WIN32)
Pierre Ossman0153e232011-03-08 13:05:27 +0000392 set(CMAKE_EXTRA_INCLUDE_FILES winsock2.h ws2tcpip.h)
Henrik Anderssone1fd8e12011-03-08 13:00:12 +0000393 set(CMAKE_REQUIRED_LIBRARIES ws2_32)
Pierre Ossman0153e232011-03-08 13:05:27 +0000394else()
395 set(CMAKE_EXTRA_INCLUDE_FILES sys/socket.h)
Henrik Anderssone1fd8e12011-03-08 13:00:12 +0000396endif()
DRC63758092010-11-09 19:24:12 +0000397check_function_exists(inet_aton HAVE_INET_ATON)
398check_function_exists(inet_ntop HAVE_INET_NTOP)
Henrik Anderssone1fd8e12011-03-08 13:00:12 +0000399check_type_size(socklen_t SOCKLEN_T)
DRC63758092010-11-09 19:24:12 +0000400set(CMAKE_EXTRA_INCLUDE_FILES)
401set(CMAKE_REQUIRED_LIBRARIES)
Pierre Ossmanee0e3622011-03-08 13:08:15 +0000402
403# Check for the newer standard string functions
DRC63758092010-11-09 19:24:12 +0000404check_function_exists(snprintf HAVE_SNPRINTF)
405check_function_exists(strcasecmp HAVE_STRCASECMP)
406check_function_exists(strncasecmp HAVE_STRNCASECMP)
407check_function_exists(vsnprintf HAVE_VSNPRINTF)
Pierre Ossmanee0e3622011-03-08 13:08:15 +0000408
409# Generate config.h and make sure the source finds it
DRC1980dd52011-06-24 19:28:27 +0000410configure_file(config.h.in config.h)
DRC63758092010-11-09 19:24:12 +0000411add_definitions(-DHAVE_CONFIG_H)
412include_directories(${CMAKE_BINARY_DIR})
DRC180c0162010-10-27 07:20:27 +0000413
DRC180c0162010-10-27 07:20:27 +0000414add_subdirectory(common)
Pierre Ossman8f64ef72011-03-08 16:32:49 +0000415
416if(WIN32)
417 add_subdirectory(win)
418else()
Henrik Anderssona7a38a62011-06-10 13:05:09 +0000419 # No interest in building x related parts on Apple
420 if(NOT APPLE)
421 add_subdirectory(unix)
422 endif()
Pierre Ossman8f64ef72011-03-08 16:32:49 +0000423endif()
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000424
DRC3591fa52011-11-03 19:01:18 +0000425if(ENABLE_NLS)
426 add_subdirectory(po)
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000427endif()
Pierre Ossman64127702012-03-27 12:33:36 +0000428
DRC3591fa52011-11-03 19:01:18 +0000429add_subdirectory(vncviewer)
DRC1a184072011-06-24 06:55:18 +0000430
Pierre Ossman64127702012-03-27 12:33:36 +0000431add_subdirectory(media)
432
DRC1a184072011-06-24 06:55:18 +0000433include(cmake/BuildPackages.cmake)
DRCb7140022011-06-25 07:33:57 +0000434
435# uninstall
436configure_file("${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
437 "cmake_uninstall.cmake" IMMEDIATE @ONLY)
438
439add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P cmake_uninstall.cmake)