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