DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 1 | # |
| 2 | # Setup |
| 3 | # |
| 4 | |
DRC | aeff331 | 2011-06-07 04:51:57 +0000 | [diff] [blame] | 5 | cmake_minimum_required(VERSION 2.8) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 6 | |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 7 | # Internal cmake modules |
| 8 | set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) |
| 9 | |
Pierre Ossman | 7f44326 | 2011-03-08 13:06:46 +0000 | [diff] [blame] | 10 | include(CheckIncludeFiles) |
| 11 | include(CheckFunctionExists) |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 12 | include(CheckLibraryExists) |
Pierre Ossman | 7f44326 | 2011-03-08 13:06:46 +0000 | [diff] [blame] | 13 | include(CheckTypeSize) |
| 14 | include(CheckCSourceCompiles) |
Pierre Ossman | 89f868a | 2011-04-11 11:59:31 +0000 | [diff] [blame] | 15 | include(CheckCXXSourceCompiles) |
DRC | 4e326a0 | 2011-07-28 08:06:39 +0000 | [diff] [blame] | 16 | include(CheckCSourceRuns) |
Pierre Ossman | 7f44326 | 2011-03-08 13:06:46 +0000 | [diff] [blame] | 17 | |
Henrik Andersson | 23029cc | 2011-06-09 09:13:23 +0000 | [diff] [blame] | 18 | include(CMakeMacroLibtoolFile) |
| 19 | |
Peter Åstrand | bb445ef | 2011-04-28 09:29:13 +0000 | [diff] [blame] | 20 | project(tigervnc) |
Pierre Ossman | 607c9d0 | 2013-04-25 07:51:47 +0000 | [diff] [blame] | 21 | set(VERSION 1.3.80) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 22 | |
| 23 | # The RC version must always be four comma-separated numbers |
Pierre Ossman | 607c9d0 | 2013-04-25 07:51:47 +0000 | [diff] [blame] | 24 | set(RCVERSION 1,3,80,0) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 25 | |
Pierre Ossman | 95e28f7 | 2012-03-27 10:24:53 +0000 | [diff] [blame] | 26 | # Installation paths |
| 27 | set(BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin") |
| 28 | set(DATA_DIR "${CMAKE_INSTALL_PREFIX}/share") |
| 29 | set(MAN_DIR "${DATA_DIR}/man") |
| 30 | set(LOCALE_DIR "${DATA_DIR}/locale") |
| 31 | set(DOC_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/${CMAKE_PROJECT_NAME}-${VERSION}") |
| 32 | |
| 33 | if(WIN32) |
| 34 | set(BIN_DIR "${CMAKE_INSTALL_PREFIX}") |
| 35 | set(DOC_DIR "${CMAKE_INSTALL_PREFIX}") |
| 36 | endif() |
| 37 | |
Pierre Ossman | e811516 | 2011-03-03 12:51:38 +0000 | [diff] [blame] | 38 | if(MSVC) |
DRC | 60d6158 | 2012-01-18 08:10:21 +0000 | [diff] [blame] | 39 | message(FATAL_ERROR "TigerVNC cannot be built with Visual Studio. Please use MinGW") |
Pierre Ossman | e811516 | 2011-03-03 12:51:38 +0000 | [diff] [blame] | 40 | endif() |
| 41 | |
Pierre Ossman | 5945d73 | 2014-09-22 13:13:15 +0200 | [diff] [blame] | 42 | set(BUILD_TIMESTAMP "") |
| 43 | execute_process(COMMAND "date" "+%Y-%m-%d %H:%M" OUTPUT_VARIABLE BUILD_TIMESTAMP) |
DRC | ccc0969 | 2011-11-08 06:57:58 +0000 | [diff] [blame] | 44 | |
Pierre Ossman | 5945d73 | 2014-09-22 13:13:15 +0200 | [diff] [blame] | 45 | if(NOT BUILD_TIMESTAMP) |
| 46 | set(BUILD_TIMESTAMP "") |
Pierre Ossman | e811516 | 2011-03-03 12:51:38 +0000 | [diff] [blame] | 47 | else() |
Pierre Ossman | 5945d73 | 2014-09-22 13:13:15 +0200 | [diff] [blame] | 48 | string(REGEX REPLACE "\n" "" BUILD_TIMESTAMP ${BUILD_TIMESTAMP}) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 49 | endif() |
| 50 | |
Pierre Ossman | 2c66a63 | 2011-03-03 12:52:59 +0000 | [diff] [blame] | 51 | # 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) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 53 | if(NOT CMAKE_BUILD_TYPE) |
| 54 | set(CMAKE_BUILD_TYPE Release) |
| 55 | endif() |
| 56 | |
| 57 | message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}") |
| 58 | |
Pierre Ossman | 5945d73 | 2014-09-22 13:13:15 +0200 | [diff] [blame] | 59 | message(STATUS "VERSION = ${VERSION}") |
| 60 | add_definitions(-DBUILD_TIMESTAMP="${BUILD_TIMESTAMP}") |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 61 | |
Pierre Ossman | 8eaa190 | 2014-03-19 12:43:51 +0000 | [diff] [blame] | 62 | # We want to keep our asserts even in release builds so remove NDEBUG |
| 63 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -UNDEBUG") |
| 64 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -UNDEBUG") |
| 65 | set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -UNDEBUG") |
| 66 | set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -UNDEBUG") |
| 67 | set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -UNDEBUG") |
| 68 | set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -UNDEBUG") |
| 69 | |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 70 | if(NOT DEFINED BUILD_WINVNC) |
DRC | 3080ec4 | 2011-10-12 20:00:55 +0000 | [diff] [blame] | 71 | set(BUILD_WINVNC 1) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 72 | endif() |
| 73 | |
Pierre Ossman | 9640f44 | 2011-03-08 13:12:33 +0000 | [diff] [blame] | 74 | # Minimum version is Windows 2000 (5.0) |
DRC | 2301beb | 2011-06-22 05:46:53 +0000 | [diff] [blame] | 75 | if(WIN32) |
| 76 | if(NOT CMAKE_SIZEOF_VOID_P MATCHES 8) |
| 77 | add_definitions(-D_WIN32_IE=0x0500 -D_WIN32_WINNT=0x0500) |
| 78 | else() |
DRC | 7cf9fbc | 2011-07-06 07:23:51 +0000 | [diff] [blame] | 79 | set(WIN64 1) |
DRC | 2301beb | 2011-06-22 05:46:53 +0000 | [diff] [blame] | 80 | # Win64 doesn't like us requesting a Windows version that didn't have |
| 81 | # 64-bit support. Request XP (5.1) instead. |
| 82 | add_definitions(-D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501) |
| 83 | endif() |
Pierre Ossman | 9640f44 | 2011-03-08 13:12:33 +0000 | [diff] [blame] | 84 | endif() |
| 85 | |
Pierre Ossman | 69314c7 | 2011-03-08 12:18:13 +0000 | [diff] [blame] | 86 | if(CMAKE_SIZEOF_VOID_P MATCHES 8) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 87 | message(STATUS "64-bit build") |
| 88 | else() |
| 89 | message(STATUS "32-bit build") |
| 90 | endif() |
| 91 | |
| 92 | # CMake doesn't properly support resource compilation with MinGW. Boo! |
| 93 | if(MINGW) |
| 94 | if(NOT DEFINED RC) |
| 95 | set(CMAKE_RC_COMPILER_INIT windres) |
| 96 | else() |
| 97 | set(CMAKE_RC_COMPILER_INIT ${RC}) |
| 98 | endif() |
| 99 | enable_language(RC) |
| 100 | message(STATUS "Resource compiler: ${CMAKE_RC_COMPILER}") |
| 101 | set(CMAKE_RC_COMPILE_OBJECT |
| 102 | "<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> -o <OBJECT> --output-format=coff <SOURCE>") |
| 103 | endif() |
| 104 | |
DRC | 3080ec4 | 2011-10-12 20:00:55 +0000 | [diff] [blame] | 105 | # MinGW64 has header support but no library support for IActiveDesktop, so we |
| 106 | # need to check for both the header and library and use our own implementation |
DRC | ccc0969 | 2011-11-08 06:57:58 +0000 | [diff] [blame] | 107 | # in common/os if either doesn't exist. |
DRC | 3080ec4 | 2011-10-12 20:00:55 +0000 | [diff] [blame] | 108 | if(WIN32) |
| 109 | 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) |
| 110 | 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) |
| 111 | endif() |
| 112 | |
Pierre Ossman | 8f64ef7 | 2011-03-08 16:32:49 +0000 | [diff] [blame] | 113 | # X11 stuff. It's in a if() so that we can say REQUIRED |
DRC | 1b7abb9 | 2011-06-23 19:12:08 +0000 | [diff] [blame] | 114 | if(UNIX AND NOT APPLE) |
Pierre Ossman | 8f64ef7 | 2011-03-08 16:32:49 +0000 | [diff] [blame] | 115 | find_package(X11 REQUIRED) |
| 116 | endif() |
| 117 | |
Pierre Ossman | a7769f2 | 2011-03-03 09:44:49 +0000 | [diff] [blame] | 118 | # Check for zlib |
| 119 | find_package(ZLIB) |
| 120 | option(USE_INCLUDED_ZLIB "Force use of the bundled zlib") |
| 121 | if(NOT ZLIB_FOUND) |
Pierre Ossman | a7769f2 | 2011-03-03 09:44:49 +0000 | [diff] [blame] | 122 | set(USE_INCLUDED_ZLIB 1) |
| 123 | endif() |
DRC | f340e7c | 2011-08-23 20:26:11 +0000 | [diff] [blame] | 124 | if(USE_INCLUDED_ZLIB) |
| 125 | message(STATUS "Using included zlib library") |
| 126 | endif() |
Pierre Ossman | a7769f2 | 2011-03-03 09:44:49 +0000 | [diff] [blame] | 127 | |
Peter Åstrand | bb445ef | 2011-04-28 09:29:13 +0000 | [diff] [blame] | 128 | # Check for gettext |
| 129 | option(ENABLE_NLS "Enable translation of program messages" ON) |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 130 | if(ENABLE_NLS) |
| 131 | # Tools |
DRC | 2690f7a | 2011-06-24 04:17:02 +0000 | [diff] [blame] | 132 | find_package(Gettext) |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 133 | |
| 134 | # Gettext needs iconv |
DRC | 2690f7a | 2011-06-24 04:17:02 +0000 | [diff] [blame] | 135 | find_package(Iconv) |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 136 | |
DRC | 2690f7a | 2011-06-24 04:17:02 +0000 | [diff] [blame] | 137 | if(ICONV_FOUND) |
| 138 | # Headers and libraries (copied from licq) |
| 139 | set(GETTEXT_FOUND FALSE) |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 140 | |
DRC | 2690f7a | 2011-06-24 04:17:02 +0000 | [diff] [blame] | 141 | find_path(GETTEXT_INCLUDE_DIR libintl.h) |
| 142 | if(GETTEXT_INCLUDE_DIR) |
| 143 | set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES}) |
| 144 | check_function_exists(dgettext LIBC_HAS_DGETTEXT) |
| 145 | if(LIBC_HAS_DGETTEXT) |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 146 | set(GETTEXT_FOUND TRUE) |
DRC | 2690f7a | 2011-06-24 04:17:02 +0000 | [diff] [blame] | 147 | else() |
| 148 | find_library(LIBINTL_LIBRARY NAMES intl libintl) |
| 149 | check_library_exists(${LIBINTL_LIBRARY} "dgettext" "" LIBINTL_HAS_DGETTEXT) |
| 150 | if(LIBINTL_HAS_DGETTEXT) |
| 151 | set(GETTEXT_LIBRARIES ${LIBINTL_LIBRARY} ${ICONV_LIBRARIES}) |
| 152 | set(GETTEXT_FOUND TRUE) |
| 153 | endif() |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 154 | endif() |
DRC | 2690f7a | 2011-06-24 04:17:02 +0000 | [diff] [blame] | 155 | set(CMAKE_REQUIRED_LIBRARIES) |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 156 | endif() |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 157 | endif() |
| 158 | |
DRC | 37596dd | 2011-11-08 08:38:58 +0000 | [diff] [blame] | 159 | if(NOT GETTEXT_FOUND OR NOT ICONV_FOUND) |
DRC | 2690f7a | 2011-06-24 04:17:02 +0000 | [diff] [blame] | 160 | message(WARNING "Gettext NOT found. Native Language Support disabled.") |
| 161 | set(ENABLE_NLS 0) |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 162 | endif() |
| 163 | endif() |
Peter Åstrand | bb445ef | 2011-04-28 09:29:13 +0000 | [diff] [blame] | 164 | |
Pierre Ossman | 4c6bd4c | 2011-03-03 09:55:21 +0000 | [diff] [blame] | 165 | # Check for libjpeg |
| 166 | find_package(JPEG REQUIRED) |
| 167 | |
Pierre Ossman | 6fa0749 | 2011-03-04 11:35:24 +0000 | [diff] [blame] | 168 | # Warn if it doesn't seem to be the accelerated libjpeg that's found |
DRC | 63b40b7 | 2011-06-07 01:47:38 +0000 | [diff] [blame] | 169 | set(CMAKE_REQUIRED_LIBRARIES ${JPEG_LIBRARIES}) |
| 170 | set(CMAKE_REQUIRED_FLAGS -I${JPEG_INCLUDE_DIR}) |
DRC | fe06e61 | 2011-06-07 01:55:12 +0000 | [diff] [blame] | 171 | |
DRC | cebb1ce | 2011-08-01 20:25:40 +0000 | [diff] [blame] | 172 | set(JPEG_TEST_SOURCE "\n |
DRC | 4e326a0 | 2011-07-28 08:06:39 +0000 | [diff] [blame] | 173 | #include <stdio.h>\n |
| 174 | #include <jpeglib.h>\n |
| 175 | int main(void) {\n |
| 176 | struct jpeg_compress_struct cinfo;\n |
| 177 | struct jpeg_error_mgr jerr;\n |
| 178 | cinfo.err=jpeg_std_error(&jerr);\n |
| 179 | jpeg_create_compress(&cinfo);\n |
| 180 | cinfo.input_components = 3;\n |
| 181 | jpeg_set_defaults(&cinfo);\n |
| 182 | cinfo.in_color_space = JCS_EXT_RGB;\n |
| 183 | jpeg_default_colorspace(&cinfo);\n |
| 184 | return 0;\n |
DRC | cebb1ce | 2011-08-01 20:25:40 +0000 | [diff] [blame] | 185 | }") |
| 186 | |
| 187 | if(CMAKE_CROSSCOMPILING) |
| 188 | check_c_source_compiles("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO) |
| 189 | else() |
| 190 | check_c_source_runs("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO) |
| 191 | endif() |
DRC | fe06e61 | 2011-06-07 01:55:12 +0000 | [diff] [blame] | 192 | |
| 193 | set(CMAKE_REQUIRED_LIBRARIES) |
| 194 | set(CMAKE_REQUIRED_FLAGS) |
DRC | 4e326a0 | 2011-07-28 08:06:39 +0000 | [diff] [blame] | 195 | set(CMAKE_REQUIRED_DEFINITIONS) |
DRC | fe06e61 | 2011-06-07 01:55:12 +0000 | [diff] [blame] | 196 | |
DRC | 1953b51 | 2011-06-24 04:19:36 +0000 | [diff] [blame] | 197 | if(NOT FOUND_LIBJPEG_TURBO) |
Pierre Ossman | 6fa0749 | 2011-03-04 11:35:24 +0000 | [diff] [blame] | 198 | message(STATUS "WARNING: You are not using libjpeg-turbo. Performance will suffer.") |
| 199 | endif() |
| 200 | |
DRC | 7636ad0 | 2011-10-04 04:03:34 +0000 | [diff] [blame] | 201 | option(BUILD_JAVA "Build Java version of the TigerVNC Viewer" FALSE) |
| 202 | if(BUILD_JAVA) |
DRC | c19ab9e | 2011-10-07 05:38:00 +0000 | [diff] [blame] | 203 | add_subdirectory(java) |
DRC | 7636ad0 | 2011-10-04 04:03:34 +0000 | [diff] [blame] | 204 | endif() |
| 205 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 206 | # Check for FLTK |
DRC | 3591fa5 | 2011-11-03 19:01:18 +0000 | [diff] [blame] | 207 | set(FLTK_SKIP_FLUID TRUE) |
| 208 | set(FLTK_SKIP_OPENGL TRUE) |
DRC | 3591fa5 | 2011-11-03 19:01:18 +0000 | [diff] [blame] | 209 | set(FLTK_SKIP_FORMS TRUE) |
| 210 | find_package(FLTK) |
Pierre Ossman | 89f868a | 2011-04-11 11:59:31 +0000 | [diff] [blame] | 211 | |
DRC | 16457a2 | 2012-01-17 23:33:29 +0000 | [diff] [blame] | 212 | if(UNIX AND NOT APPLE) |
DRC | 3591fa5 | 2011-11-03 19:01:18 +0000 | [diff] [blame] | 213 | # No proper handling for extra X11 libs that FLTK might need... |
| 214 | if(X11_Xft_FOUND) |
Pierre Ossman | e43d1aa | 2012-03-27 10:29:50 +0000 | [diff] [blame] | 215 | # Xft headers include references to fontconfig, so we need |
| 216 | # to link to that as well |
| 217 | find_library(FONTCONFIG_LIB fontconfig) |
| 218 | set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xft_LIB} ${FONTCONFIG_LIB}) |
Pierre Ossman | 835b4ef | 2011-06-08 17:02:36 +0000 | [diff] [blame] | 219 | endif() |
DRC | 3591fa5 | 2011-11-03 19:01:18 +0000 | [diff] [blame] | 220 | if(X11_Xinerama_FOUND) |
| 221 | set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xinerama_LIB}) |
DRC | 2ff39b8 | 2011-07-28 08:38:59 +0000 | [diff] [blame] | 222 | endif() |
DRC | 3591fa5 | 2011-11-03 19:01:18 +0000 | [diff] [blame] | 223 | if(X11_Xfixes_FOUND) |
| 224 | set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xfixes_LIB}) |
DRC | 2ff39b8 | 2011-07-28 08:38:59 +0000 | [diff] [blame] | 225 | endif() |
DRC | 3591fa5 | 2011-11-03 19:01:18 +0000 | [diff] [blame] | 226 | if(X11_Xcursor_FOUND) |
| 227 | set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xcursor_LIB}) |
DRC | 2ff39b8 | 2011-07-28 08:38:59 +0000 | [diff] [blame] | 228 | endif() |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 229 | endif() |
| 230 | |
DRC | 3591fa5 | 2011-11-03 19:01:18 +0000 | [diff] [blame] | 231 | if(FLTK_FOUND) |
| 232 | set(CMAKE_REQUIRED_INCLUDES ${FLTK_INCLUDE_DIR}) |
| 233 | set(CMAKE_REQUIRED_LIBRARIES ${FLTK_LIBRARIES}) |
| 234 | |
DRC | 3591fa5 | 2011-11-03 19:01:18 +0000 | [diff] [blame] | 235 | # FLTK STR #2636 |
| 236 | 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) |
| 237 | |
| 238 | # FLTK STR #2638 |
| 239 | check_cxx_source_compiles("#include <FL/Enumerations.H>\nint main(int c, char** v) { return FL_Volume_Down; }" HAVE_FLTK_MEDIAKEYS) |
| 240 | |
| 241 | # FLTK STR #2641 |
| 242 | check_cxx_source_compiles("#include <FL/Enumerations.H>\nint main(int c, char** v) { return FL_FULLSCREEN; }" HAVE_FLTK_FULLSCREEN) |
| 243 | |
| 244 | # FLTK STR #2660 |
| 245 | 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) |
| 246 | |
Pierre Ossman | 208b2ea | 2012-10-24 08:28:18 +0000 | [diff] [blame] | 247 | # FLTK STR #2697 |
| 248 | 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) |
| 249 | |
Pierre Ossman | 8eb3508 | 2012-03-27 12:50:54 +0000 | [diff] [blame] | 250 | # FLTK STR #2816 |
| 251 | 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) |
| 252 | |
Pierre Ossman | aae3891 | 2012-07-13 11:22:55 +0000 | [diff] [blame] | 253 | # FLTK STR #2860 |
| 254 | 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) |
| 255 | |
Pierre Ossman | 4f3ac69 | 2014-08-22 15:10:22 +0200 | [diff] [blame] | 256 | # FLTK STR #xxxx |
Pierre Ossman | 64ff1ca | 2014-09-11 10:48:29 +0200 | [diff] [blame] | 257 | 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 Ossman | 4f3ac69 | 2014-08-22 15:10:22 +0200 | [diff] [blame] | 258 | |
Pierre Ossman | 6d66d6d | 2014-09-11 10:46:12 +0200 | [diff] [blame] | 259 | # FLTK STR #xxxx |
| 260 | check_cxx_source_compiles("#include <FL/Fl.H>\nint main(int c, char** v) { Fl::disable_im(); return 0; }" HAVE_FLTK_IM) |
| 261 | |
DRC | 3591fa5 | 2011-11-03 19:01:18 +0000 | [diff] [blame] | 262 | set(CMAKE_REQUIRED_INCLUDES) |
| 263 | set(CMAKE_REQUIRED_LIBRARIES) |
| 264 | endif() |
| 265 | |
Adam Tkac | 125bd25 | 2011-01-19 14:20:34 +0000 | [diff] [blame] | 266 | # Check for GNUTLS library |
Pierre Ossman | 9506420 | 2011-05-30 12:22:39 +0000 | [diff] [blame] | 267 | option(ENABLE_GNUTLS "Enable protocol encryption and advanced authentication" ON) |
Pierre Ossman | 32c88c4 | 2011-05-27 11:50:58 +0000 | [diff] [blame] | 268 | if(ENABLE_GNUTLS) |
Pierre Ossman | 9506420 | 2011-05-30 12:22:39 +0000 | [diff] [blame] | 269 | find_package(GnuTLS) |
| 270 | if (GNUTLS_FOUND) |
| 271 | include_directories(${GNUTLS_INCLUDE_DIR}) |
| 272 | add_definitions("-DHAVE_GNUTLS") |
| 273 | add_definitions(${GNUTLS_DEFINITIONS}) |
| 274 | |
| 275 | # Detect old version of GnuTLS |
DRC | 17331b9 | 2011-06-07 04:07:20 +0000 | [diff] [blame] | 276 | set(CMAKE_REQUIRED_FLAGS -I${GNUTLS_INCLUDE_DIR}) |
Pierre Ossman | 9506420 | 2011-05-30 12:22:39 +0000 | [diff] [blame] | 277 | set(CMAKE_EXTRA_INCLUDE_FILES gnutls/gnutls.h) |
DRC | 17331b9 | 2011-06-07 04:07:20 +0000 | [diff] [blame] | 278 | set(CMAKE_REQUIRED_LIBRARIES ${GNUTLS_LIBRARIES}) |
DRC | 56e625c | 2011-06-24 03:19:28 +0000 | [diff] [blame] | 279 | if(WIN32) |
DRC | 56e625c | 2011-06-24 03:19:28 +0000 | [diff] [blame] | 280 | set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ws2_32 user32) |
| 281 | endif() |
DRC | 17331b9 | 2011-06-07 04:07:20 +0000 | [diff] [blame] | 282 | if(ZLIB_FOUND) |
| 283 | # When we build against the static version of GnuTLS, we also use the |
| 284 | # included version of Zlib, but it isn't built yet, so we have to use the |
| 285 | # system's version (if available) to perform this test. |
| 286 | set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES};-lz) |
| 287 | endif() |
Pierre Ossman | 2137f4f | 2012-07-03 14:52:26 +0000 | [diff] [blame] | 288 | check_function_exists(gnutls_transport_set_errno HAVE_GNUTLS_SET_ERRNO) |
| 289 | check_function_exists(gnutls_transport_set_global_errno HAVE_GNUTLS_SET_GLOBAL_ERRNO) |
Pierre Ossman | 9506420 | 2011-05-30 12:22:39 +0000 | [diff] [blame] | 290 | check_function_exists(gnutls_x509_crt_print HAVE_GNUTLS_X509_CRT_PRINT) |
| 291 | check_type_size(gnutls_x509_crt_t GNUTLS_X509_CRT_T) |
| 292 | check_type_size(gnutls_datum_t GNUTLS_DATUM_T) |
| 293 | check_type_size(gnutls_pk_algorithm_t GNUTLS_PK_ALGORITHM_T) |
| 294 | check_type_size(gnutls_sign_algorithm_t GNUTLS_SIGN_ALGORITHM_T) |
DRC | 17331b9 | 2011-06-07 04:07:20 +0000 | [diff] [blame] | 295 | set(CMAKE_REQUIRED_FLAGS) |
Pierre Ossman | 9506420 | 2011-05-30 12:22:39 +0000 | [diff] [blame] | 296 | set(CMAKE_EXTRA_INCLUDE_FILES) |
| 297 | set(CMAKE_REQUIRED_LIBRARIES) |
| 298 | endif() |
Adam Tkac | 125bd25 | 2011-01-19 14:20:34 +0000 | [diff] [blame] | 299 | endif() |
| 300 | |
DRC | 777290b | 2011-06-22 00:18:17 +0000 | [diff] [blame] | 301 | # Check for PAM library |
| 302 | option(ENABLE_PAM "Enable PAM authentication support" ON) |
| 303 | if(ENABLE_PAM) |
| 304 | check_include_files(security/pam_appl.h HAVE_PAM_H) |
| 305 | set(CMAKE_REQUIRED_LIBRARIES -lpam) |
| 306 | check_function_exists(pam_start HAVE_PAM_START) |
| 307 | set(CMAKE_REQUIRED_LIBRARIES) |
| 308 | if(HAVE_PAM_H AND HAVE_PAM_START) |
| 309 | set(PAM_LIBS pam) |
| 310 | else() |
| 311 | set(ENABLE_PAM 0) |
| 312 | endif() |
| 313 | endif() |
| 314 | set(HAVE_PAM ${ENABLE_PAM}) |
| 315 | |
Pierre Ossman | ee0e362 | 2011-03-08 13:08:15 +0000 | [diff] [blame] | 316 | # Check for socket functions |
Henrik Andersson | e1fd8e1 | 2011-03-08 13:00:12 +0000 | [diff] [blame] | 317 | if(WIN32) |
Pierre Ossman | 0153e23 | 2011-03-08 13:05:27 +0000 | [diff] [blame] | 318 | set(CMAKE_EXTRA_INCLUDE_FILES winsock2.h ws2tcpip.h) |
Henrik Andersson | e1fd8e1 | 2011-03-08 13:00:12 +0000 | [diff] [blame] | 319 | set(CMAKE_REQUIRED_LIBRARIES ws2_32) |
Pierre Ossman | 0153e23 | 2011-03-08 13:05:27 +0000 | [diff] [blame] | 320 | else() |
| 321 | set(CMAKE_EXTRA_INCLUDE_FILES sys/socket.h) |
Henrik Andersson | e1fd8e1 | 2011-03-08 13:00:12 +0000 | [diff] [blame] | 322 | endif() |
DRC | 6375809 | 2010-11-09 19:24:12 +0000 | [diff] [blame] | 323 | check_function_exists(inet_aton HAVE_INET_ATON) |
Pierre Ossman | 32c4622 | 2012-12-13 13:56:28 +0000 | [diff] [blame] | 324 | check_function_exists(getaddrinfo HAVE_GETADDRINFO) |
DRC | 6375809 | 2010-11-09 19:24:12 +0000 | [diff] [blame] | 325 | set(CMAKE_EXTRA_INCLUDE_FILES) |
| 326 | set(CMAKE_REQUIRED_LIBRARIES) |
Pierre Ossman | ee0e362 | 2011-03-08 13:08:15 +0000 | [diff] [blame] | 327 | |
Pierre Ossman | ee0e362 | 2011-03-08 13:08:15 +0000 | [diff] [blame] | 328 | # Generate config.h and make sure the source finds it |
DRC | 1980dd5 | 2011-06-24 19:28:27 +0000 | [diff] [blame] | 329 | configure_file(config.h.in config.h) |
DRC | 6375809 | 2010-11-09 19:24:12 +0000 | [diff] [blame] | 330 | add_definitions(-DHAVE_CONFIG_H) |
| 331 | include_directories(${CMAKE_BINARY_DIR}) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 332 | |
Pierre Ossman | f95272d | 2014-10-17 13:59:35 +0200 | [diff] [blame^] | 333 | include(cmake/StaticBuild.cmake) |
| 334 | |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 335 | add_subdirectory(common) |
Pierre Ossman | 8f64ef7 | 2011-03-08 16:32:49 +0000 | [diff] [blame] | 336 | |
| 337 | if(WIN32) |
| 338 | add_subdirectory(win) |
| 339 | else() |
Henrik Andersson | a7a38a6 | 2011-06-10 13:05:09 +0000 | [diff] [blame] | 340 | # No interest in building x related parts on Apple |
| 341 | if(NOT APPLE) |
| 342 | add_subdirectory(unix) |
| 343 | endif() |
Pierre Ossman | 8f64ef7 | 2011-03-08 16:32:49 +0000 | [diff] [blame] | 344 | endif() |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 345 | |
DRC | 3591fa5 | 2011-11-03 19:01:18 +0000 | [diff] [blame] | 346 | if(ENABLE_NLS) |
| 347 | add_subdirectory(po) |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 348 | endif() |
Pierre Ossman | 6412770 | 2012-03-27 12:33:36 +0000 | [diff] [blame] | 349 | |
Peter Åstrand | 889b489 | 2014-02-20 08:04:17 +0000 | [diff] [blame] | 350 | option(BUILD_VIEWER "Build TigerVNC viewer" ON) |
| 351 | if(BUILD_VIEWER) |
| 352 | add_subdirectory(vncviewer) |
| 353 | add_subdirectory(media) |
| 354 | endif() |
DRC | 1a18407 | 2011-06-24 06:55:18 +0000 | [diff] [blame] | 355 | |
Pierre Ossman | 236c03c | 2014-07-04 14:12:49 +0200 | [diff] [blame] | 356 | add_subdirectory(tests) |
| 357 | |
Pierre Ossman | 6412770 | 2012-03-27 12:33:36 +0000 | [diff] [blame] | 358 | |
DRC | 1a18407 | 2011-06-24 06:55:18 +0000 | [diff] [blame] | 359 | include(cmake/BuildPackages.cmake) |
DRC | b714002 | 2011-06-25 07:33:57 +0000 | [diff] [blame] | 360 | |
| 361 | # uninstall |
| 362 | configure_file("${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" |
| 363 | "cmake_uninstall.cmake" IMMEDIATE @ONLY) |
| 364 | |
| 365 | add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P cmake_uninstall.cmake) |