blob: 708b2582fdc602f4b8778b852a802986ef531a57 [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 Ossman8f64ef72011-03-08 16:32:49 +000038# Compatibility variables for the migration from autotools
39add_definitions(-DPACKAGE_NAME="${CMAKE_PROJECT_NAME}")
40add_definitions(-DPACKAGE_VERSION="${VERSION}")
Pierre Ossman95e28f72012-03-27 10:24:53 +000041add_definitions(-DLOCALEDIR="${LOCALE_DIR}")
Pierre Ossman8f64ef72011-03-08 16:32:49 +000042
Pierre Ossmane8115162011-03-03 12:51:38 +000043if(MSVC)
DRC60d61582012-01-18 08:10:21 +000044 message(FATAL_ERROR "TigerVNC cannot be built with Visual Studio. Please use MinGW")
Pierre Ossmane8115162011-03-03 12:51:38 +000045endif()
46
DRCccc09692011-11-08 06:57:58 +000047set(BUILD "")
48execute_process(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE BUILD)
49
Pierre Ossmane8115162011-03-03 12:51:38 +000050if(NOT BUILD)
51 set(BUILD "")
52else()
53 string(REGEX REPLACE "\n" "" BUILD ${BUILD})
DRC180c0162010-10-27 07:20:27 +000054endif()
55
Pierre Ossman2c66a632011-03-03 12:52:59 +000056# Default to optimised builds instead of debug ones. Our code has no bugs ;)
57# (CMake makes it fairly easy to toggle this back to Debug if needed)
DRC180c0162010-10-27 07:20:27 +000058if(NOT CMAKE_BUILD_TYPE)
59 set(CMAKE_BUILD_TYPE Release)
60endif()
61
62message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
63
DRC180c0162010-10-27 07:20:27 +000064if(CMAKE_BUILD_TYPE STREQUAL "Debug")
65 set(BUILD "${BUILD}d")
66endif()
67
68message(STATUS "VERSION = ${VERSION}, BUILD = ${BUILD}")
DRCd8e93dc2011-07-28 22:13:40 +000069add_definitions(-D__BUILD__="${BUILD}")
DRC180c0162010-10-27 07:20:27 +000070
71if(NOT DEFINED BUILD_WINVNC)
DRC3080ec42011-10-12 20:00:55 +000072 set(BUILD_WINVNC 1)
DRC180c0162010-10-27 07:20:27 +000073endif()
74
Pierre Ossman9640f442011-03-08 13:12:33 +000075# Minimum version is Windows 2000 (5.0)
DRC2301beb2011-06-22 05:46:53 +000076if(WIN32)
77 if(NOT CMAKE_SIZEOF_VOID_P MATCHES 8)
78 add_definitions(-D_WIN32_IE=0x0500 -D_WIN32_WINNT=0x0500)
79 else()
DRC7cf9fbc2011-07-06 07:23:51 +000080 set(WIN64 1)
DRC2301beb2011-06-22 05:46:53 +000081 # Win64 doesn't like us requesting a Windows version that didn't have
82 # 64-bit support. Request XP (5.1) instead.
83 add_definitions(-D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501)
84 endif()
Pierre Ossman9640f442011-03-08 13:12:33 +000085endif()
86
Pierre Ossman69314c72011-03-08 12:18:13 +000087if(CMAKE_SIZEOF_VOID_P MATCHES 8)
DRC180c0162010-10-27 07:20:27 +000088 message(STATUS "64-bit build")
89else()
90 message(STATUS "32-bit build")
91endif()
92
DRC883f2d62011-07-28 09:58:24 +000093# This ensures that we don't depend on libstdc++ or libgcc
94if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE AND NOT CYGWIN)
95 option(BUILD_STATIC
96 "Link statically against libgcc and libstdc++, if possible" OFF)
97 if(BUILD_STATIC)
98 # For some reason, simply passing ${CMAKE_CXX_FLAGS} to the compiler in
99 # execute_process() doesn't work. Grrr...
DRCca917582011-08-08 03:22:15 +0000100 if(CMAKE_SIZEOF_VOID_P MATCHES 8)
DRC883f2d62011-07-28 09:58:24 +0000101 execute_process(COMMAND ${CMAKE_CXX_COMPILER} -m64
102 --print-file-name=libstdc++.a OUTPUT_VARIABLE LIBSTDCPLUSPLUS
103 RESULT_VARIABLE RESULT)
104 else()
105 execute_process(COMMAND ${CMAKE_CXX_COMPILER} -m32
106 --print-file-name=libstdc++.a OUTPUT_VARIABLE LIBSTDCPLUSPLUS
107 RESULT_VARIABLE RESULT)
108 endif()
109 string(REGEX REPLACE "\n" "" LIBSTDCPLUSPLUS ${LIBSTDCPLUSPLUS})
110 if(RESULT MATCHES 0 AND LIBSTDCPLUSPLUS)
111 message(STATUS "Linking with static libstdc++:\n ${LIBSTDCPLUSPLUS}")
112 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/staticlib)
113 execute_process(COMMAND ${CMAKE_COMMAND} -E remove
114 ${CMAKE_BINARY_DIR}/staticlib/libstdc++.a)
DRCe4e604f2011-10-01 17:54:36 +0000115 if(MINGW)
116 execute_process(COMMAND ${CMAKE_COMMAND} -E copy
117 ${LIBSTDCPLUSPLUS} ${CMAKE_BINARY_DIR}/staticlib/libstdc++.a)
118 else()
119 execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
120 ${LIBSTDCPLUSPLUS} ${CMAKE_BINARY_DIR}/staticlib/libstdc++.a)
121 endif()
DRC883f2d62011-07-28 09:58:24 +0000122 set(CMAKE_EXE_LINKER_FLAGS
123 "${CMAKE_EXE_LINKER_FLAGS} -L${CMAKE_BINARY_DIR}/staticlib")
124 set(CMAKE_SHARED_LINKER_FLAGS
125 "${CMAKE_SHARED_LINKER_FLAGS} -L${CMAKE_BINARY_DIR}/staticlib")
126 else()
DRCe4e604f2011-10-01 17:54:36 +0000127 message(WARNING Cannot find static libstdc++. TigerVNC will depend on dynamic libstdc++.)
DRC883f2d62011-07-28 09:58:24 +0000128 endif()
DRC7f2f25b2011-10-12 21:29:34 +0000129 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc")
DRC883f2d62011-07-28 09:58:24 +0000130 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc")
131 set(CMAKE_SHARED_LINKER_FLAGS
132 "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc")
133 endif()
134endif()
135
DRC180c0162010-10-27 07:20:27 +0000136# CMake doesn't properly support resource compilation with MinGW. Boo!
137if(MINGW)
138 if(NOT DEFINED RC)
139 set(CMAKE_RC_COMPILER_INIT windres)
140 else()
141 set(CMAKE_RC_COMPILER_INIT ${RC})
142 endif()
143 enable_language(RC)
144 message(STATUS "Resource compiler: ${CMAKE_RC_COMPILER}")
145 set(CMAKE_RC_COMPILE_OBJECT
146 "<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> -o <OBJECT> --output-format=coff <SOURCE>")
147endif()
148
DRC3080ec42011-10-12 20:00:55 +0000149# MinGW64 has header support but no library support for IActiveDesktop, so we
150# need to check for both the header and library and use our own implementation
DRCccc09692011-11-08 06:57:58 +0000151# in common/os if either doesn't exist.
DRC3080ec42011-10-12 20:00:55 +0000152if(WIN32)
153 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)
154 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)
155endif()
156
Pierre Ossman8f64ef72011-03-08 16:32:49 +0000157# X11 stuff. It's in a if() so that we can say REQUIRED
DRC1b7abb92011-06-23 19:12:08 +0000158if(UNIX AND NOT APPLE)
Pierre Ossman8f64ef72011-03-08 16:32:49 +0000159 find_package(X11 REQUIRED)
160endif()
161
Pierre Ossmana7769f22011-03-03 09:44:49 +0000162# Check for zlib
163find_package(ZLIB)
164option(USE_INCLUDED_ZLIB "Force use of the bundled zlib")
165if(NOT ZLIB_FOUND)
Pierre Ossmana7769f22011-03-03 09:44:49 +0000166 set(USE_INCLUDED_ZLIB 1)
167endif()
DRCf340e7c2011-08-23 20:26:11 +0000168if(USE_INCLUDED_ZLIB)
169 message(STATUS "Using included zlib library")
170endif()
Pierre Ossmana7769f22011-03-03 09:44:49 +0000171
Peter Åstrandbb445ef2011-04-28 09:29:13 +0000172# Check for gettext
173option(ENABLE_NLS "Enable translation of program messages" ON)
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000174if(ENABLE_NLS)
175 # Tools
DRC2690f7a2011-06-24 04:17:02 +0000176 find_package(Gettext)
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000177
178 # Gettext needs iconv
DRC2690f7a2011-06-24 04:17:02 +0000179 find_package(Iconv)
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000180
DRC2690f7a2011-06-24 04:17:02 +0000181 if(ICONV_FOUND)
182 # Headers and libraries (copied from licq)
183 set(GETTEXT_FOUND FALSE)
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000184
DRC2690f7a2011-06-24 04:17:02 +0000185 find_path(GETTEXT_INCLUDE_DIR libintl.h)
186 if(GETTEXT_INCLUDE_DIR)
187 set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
188 check_function_exists(dgettext LIBC_HAS_DGETTEXT)
189 if(LIBC_HAS_DGETTEXT)
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000190 set(GETTEXT_FOUND TRUE)
DRC2690f7a2011-06-24 04:17:02 +0000191 else()
192 find_library(LIBINTL_LIBRARY NAMES intl libintl)
193 check_library_exists(${LIBINTL_LIBRARY} "dgettext" "" LIBINTL_HAS_DGETTEXT)
194 if(LIBINTL_HAS_DGETTEXT)
195 set(GETTEXT_LIBRARIES ${LIBINTL_LIBRARY} ${ICONV_LIBRARIES})
196 set(GETTEXT_FOUND TRUE)
197 endif()
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000198 endif()
DRC2690f7a2011-06-24 04:17:02 +0000199 set(CMAKE_REQUIRED_LIBRARIES)
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000200 endif()
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000201 endif()
202
DRC37596dd2011-11-08 08:38:58 +0000203 if(NOT GETTEXT_FOUND OR NOT ICONV_FOUND)
DRC2690f7a2011-06-24 04:17:02 +0000204 message(WARNING "Gettext NOT found. Native Language Support disabled.")
205 set(ENABLE_NLS 0)
Pierre Ossmanb232b5f2011-04-28 14:38:04 +0000206 endif()
207endif()
Peter Åstrandbb445ef2011-04-28 09:29:13 +0000208
Pierre Ossman4c6bd4c2011-03-03 09:55:21 +0000209# Check for libjpeg
210find_package(JPEG REQUIRED)
211
Pierre Ossman6fa07492011-03-04 11:35:24 +0000212# Warn if it doesn't seem to be the accelerated libjpeg that's found
DRC63b40b72011-06-07 01:47:38 +0000213set(CMAKE_REQUIRED_LIBRARIES ${JPEG_LIBRARIES})
214set(CMAKE_REQUIRED_FLAGS -I${JPEG_INCLUDE_DIR})
DRCfe06e612011-06-07 01:55:12 +0000215
DRCcebb1ce2011-08-01 20:25:40 +0000216set(JPEG_TEST_SOURCE "\n
DRC4e326a02011-07-28 08:06:39 +0000217 #include <stdio.h>\n
218 #include <jpeglib.h>\n
219 int main(void) {\n
220 struct jpeg_compress_struct cinfo;\n
221 struct jpeg_error_mgr jerr;\n
222 cinfo.err=jpeg_std_error(&jerr);\n
223 jpeg_create_compress(&cinfo);\n
224 cinfo.input_components = 3;\n
225 jpeg_set_defaults(&cinfo);\n
226 cinfo.in_color_space = JCS_EXT_RGB;\n
227 jpeg_default_colorspace(&cinfo);\n
228 return 0;\n
DRCcebb1ce2011-08-01 20:25:40 +0000229 }")
230
231if(CMAKE_CROSSCOMPILING)
232 check_c_source_compiles("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO)
233else()
234 check_c_source_runs("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO)
235endif()
DRCfe06e612011-06-07 01:55:12 +0000236
237set(CMAKE_REQUIRED_LIBRARIES)
238set(CMAKE_REQUIRED_FLAGS)
DRC4e326a02011-07-28 08:06:39 +0000239set(CMAKE_REQUIRED_DEFINITIONS)
DRCfe06e612011-06-07 01:55:12 +0000240
DRC1953b512011-06-24 04:19:36 +0000241if(NOT FOUND_LIBJPEG_TURBO)
Pierre Ossman6fa07492011-03-04 11:35:24 +0000242 message(STATUS "WARNING: You are not using libjpeg-turbo. Performance will suffer.")
243endif()
244
DRC7636ad02011-10-04 04:03:34 +0000245option(BUILD_JAVA "Build Java version of the TigerVNC Viewer" FALSE)
246if(BUILD_JAVA)
DRCc19ab9e2011-10-07 05:38:00 +0000247 add_subdirectory(java)
DRC7636ad02011-10-04 04:03:34 +0000248endif()
249
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000250# Check for FLTK
DRC3591fa52011-11-03 19:01:18 +0000251set(FLTK_SKIP_FLUID TRUE)
252set(FLTK_SKIP_OPENGL TRUE)
253set(FLTK_SKIP_IMAGES TRUE)
254set(FLTK_SKIP_FORMS TRUE)
255find_package(FLTK)
Pierre Ossman89f868a2011-04-11 11:59:31 +0000256
DRC16457a22012-01-17 23:33:29 +0000257if(UNIX AND NOT APPLE)
DRC3591fa52011-11-03 19:01:18 +0000258 # No proper handling for extra X11 libs that FLTK might need...
259 if(X11_Xft_FOUND)
Pierre Ossmane43d1aa2012-03-27 10:29:50 +0000260 # Xft headers include references to fontconfig, so we need
261 # to link to that as well
262 find_library(FONTCONFIG_LIB fontconfig)
263 set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xft_LIB} ${FONTCONFIG_LIB})
Pierre Ossman835b4ef2011-06-08 17:02:36 +0000264 endif()
DRC3591fa52011-11-03 19:01:18 +0000265 if(X11_Xinerama_FOUND)
266 set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xinerama_LIB})
DRC2ff39b82011-07-28 08:38:59 +0000267 endif()
DRC3591fa52011-11-03 19:01:18 +0000268 if(X11_Xfixes_FOUND)
269 set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xfixes_LIB})
DRC2ff39b82011-07-28 08:38:59 +0000270 endif()
DRC3591fa52011-11-03 19:01:18 +0000271 if(X11_Xcursor_FOUND)
272 set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xcursor_LIB})
DRC2ff39b82011-07-28 08:38:59 +0000273 endif()
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000274endif()
275
DRC3591fa52011-11-03 19:01:18 +0000276if(FLTK_FOUND)
277 set(CMAKE_REQUIRED_INCLUDES ${FLTK_INCLUDE_DIR})
278 set(CMAKE_REQUIRED_LIBRARIES ${FLTK_LIBRARIES})
279
280 # FLTK STR #2599
281 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)
282
283 # FLTK STR #2636
284 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)
285
286 # FLTK STR #2638
287 check_cxx_source_compiles("#include <FL/Enumerations.H>\nint main(int c, char** v) { return FL_Volume_Down; }" HAVE_FLTK_MEDIAKEYS)
288
289 # FLTK STR #2641
290 check_cxx_source_compiles("#include <FL/Enumerations.H>\nint main(int c, char** v) { return FL_FULLSCREEN; }" HAVE_FLTK_FULLSCREEN)
291
292 # FLTK STR #2660
293 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)
294
295 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
303 OR NOT HAVE_FLTK_CURSOR)
304 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)
DRC3591fa52011-11-03 19:01:18 +0000328 set(FLTK_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/common/fltk)
329 set(FLTK_LIBRARIES)
330 if(APPLE)
331 set(FLTK_LIBRARIES "-framework Carbon -framework Cocoa -framework ApplicationServices")
332 elseif(NOT WIN32)
333 set(FLTK_LIBRARIES "-ldl")
334 endif()
335 message(STATUS "Using included FLTK library")
336endif()
DRC0141bd52012-01-17 22:33:45 +0000337
Adam Tkac125bd252011-01-19 14:20:34 +0000338# Check for GNUTLS library
Pierre Ossman95064202011-05-30 12:22:39 +0000339option(ENABLE_GNUTLS "Enable protocol encryption and advanced authentication" ON)
Pierre Ossman32c88c42011-05-27 11:50:58 +0000340if(ENABLE_GNUTLS)
Pierre Ossman95064202011-05-30 12:22:39 +0000341 find_package(GnuTLS)
342 if (GNUTLS_FOUND)
343 include_directories(${GNUTLS_INCLUDE_DIR})
344 add_definitions("-DHAVE_GNUTLS")
345 add_definitions(${GNUTLS_DEFINITIONS})
346
347 # Detect old version of GnuTLS
DRC17331b92011-06-07 04:07:20 +0000348 set(CMAKE_REQUIRED_FLAGS -I${GNUTLS_INCLUDE_DIR})
Pierre Ossman95064202011-05-30 12:22:39 +0000349 set(CMAKE_EXTRA_INCLUDE_FILES gnutls/gnutls.h)
DRC17331b92011-06-07 04:07:20 +0000350 set(CMAKE_REQUIRED_LIBRARIES ${GNUTLS_LIBRARIES})
DRC56e625c2011-06-24 03:19:28 +0000351 if(WIN32)
352 set(CMAKE_EXTRA_INCLUDE_FILES gcrypt.h ${CMAKE_EXTRA_INCLUDE_FILES})
353 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ws2_32 user32)
354 endif()
DRC17331b92011-06-07 04:07:20 +0000355 if(ZLIB_FOUND)
356 # When we build against the static version of GnuTLS, we also use the
357 # included version of Zlib, but it isn't built yet, so we have to use the
358 # system's version (if available) to perform this test.
359 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES};-lz)
360 endif()
Pierre Ossman95064202011-05-30 12:22:39 +0000361 check_function_exists(gnutls_transport_set_global_errno HAVE_OLD_GNUTLS)
362 check_function_exists(gnutls_x509_crt_print HAVE_GNUTLS_X509_CRT_PRINT)
363 check_type_size(gnutls_x509_crt_t GNUTLS_X509_CRT_T)
364 check_type_size(gnutls_datum_t GNUTLS_DATUM_T)
365 check_type_size(gnutls_pk_algorithm_t GNUTLS_PK_ALGORITHM_T)
366 check_type_size(gnutls_sign_algorithm_t GNUTLS_SIGN_ALGORITHM_T)
DRC17331b92011-06-07 04:07:20 +0000367 set(CMAKE_REQUIRED_FLAGS)
Pierre Ossman95064202011-05-30 12:22:39 +0000368 set(CMAKE_EXTRA_INCLUDE_FILES)
369 set(CMAKE_REQUIRED_LIBRARIES)
370 endif()
Adam Tkac125bd252011-01-19 14:20:34 +0000371endif()
372
DRC777290b2011-06-22 00:18:17 +0000373# Check for PAM library
374option(ENABLE_PAM "Enable PAM authentication support" ON)
375if(ENABLE_PAM)
376 check_include_files(security/pam_appl.h HAVE_PAM_H)
377 set(CMAKE_REQUIRED_LIBRARIES -lpam)
378 check_function_exists(pam_start HAVE_PAM_START)
379 set(CMAKE_REQUIRED_LIBRARIES)
380 if(HAVE_PAM_H AND HAVE_PAM_START)
381 set(PAM_LIBS pam)
382 else()
383 set(ENABLE_PAM 0)
384 endif()
385endif()
386set(HAVE_PAM ${ENABLE_PAM})
387
Pierre Ossmanee0e3622011-03-08 13:08:15 +0000388# Check for socket functions
Henrik Anderssone1fd8e12011-03-08 13:00:12 +0000389if(WIN32)
Pierre Ossman0153e232011-03-08 13:05:27 +0000390 set(CMAKE_EXTRA_INCLUDE_FILES winsock2.h ws2tcpip.h)
Henrik Anderssone1fd8e12011-03-08 13:00:12 +0000391 set(CMAKE_REQUIRED_LIBRARIES ws2_32)
Pierre Ossman0153e232011-03-08 13:05:27 +0000392else()
393 set(CMAKE_EXTRA_INCLUDE_FILES sys/socket.h)
Henrik Anderssone1fd8e12011-03-08 13:00:12 +0000394endif()
DRC63758092010-11-09 19:24:12 +0000395check_function_exists(inet_aton HAVE_INET_ATON)
396check_function_exists(inet_ntop HAVE_INET_NTOP)
Henrik Anderssone1fd8e12011-03-08 13:00:12 +0000397check_type_size(socklen_t SOCKLEN_T)
DRC63758092010-11-09 19:24:12 +0000398set(CMAKE_EXTRA_INCLUDE_FILES)
399set(CMAKE_REQUIRED_LIBRARIES)
Pierre Ossmanee0e3622011-03-08 13:08:15 +0000400
401# Check for the newer standard string functions
DRC63758092010-11-09 19:24:12 +0000402check_function_exists(snprintf HAVE_SNPRINTF)
403check_function_exists(strcasecmp HAVE_STRCASECMP)
404check_function_exists(strncasecmp HAVE_STRNCASECMP)
405check_function_exists(vsnprintf HAVE_VSNPRINTF)
Pierre Ossmanee0e3622011-03-08 13:08:15 +0000406
407# Generate config.h and make sure the source finds it
DRC1980dd52011-06-24 19:28:27 +0000408configure_file(config.h.in config.h)
DRC63758092010-11-09 19:24:12 +0000409add_definitions(-DHAVE_CONFIG_H)
410include_directories(${CMAKE_BINARY_DIR})
DRC180c0162010-10-27 07:20:27 +0000411
DRC180c0162010-10-27 07:20:27 +0000412add_subdirectory(common)
Pierre Ossman8f64ef72011-03-08 16:32:49 +0000413
414if(WIN32)
415 add_subdirectory(win)
416else()
Henrik Anderssona7a38a62011-06-10 13:05:09 +0000417 # No interest in building x related parts on Apple
418 if(NOT APPLE)
419 add_subdirectory(unix)
420 endif()
Pierre Ossman8f64ef72011-03-08 16:32:49 +0000421endif()
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000422
DRC3591fa52011-11-03 19:01:18 +0000423if(ENABLE_NLS)
424 add_subdirectory(po)
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000425endif()
Pierre Ossman64127702012-03-27 12:33:36 +0000426
DRC3591fa52011-11-03 19:01:18 +0000427add_subdirectory(vncviewer)
DRC1a184072011-06-24 06:55:18 +0000428
Pierre Ossman64127702012-03-27 12:33:36 +0000429add_subdirectory(media)
430
DRC1a184072011-06-24 06:55:18 +0000431include(cmake/BuildPackages.cmake)
DRCb7140022011-06-25 07:33:57 +0000432
433# uninstall
434configure_file("${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
435 "cmake_uninstall.cmake" IMMEDIATE @ONLY)
436
437add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P cmake_uninstall.cmake)