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) |
Pierre Ossman | 4b9c1ff | 2016-04-04 13:17:38 +0200 | [diff] [blame] | 6 | if(POLICY CMP0022) |
| 7 | cmake_policy(SET CMP0022 OLD) |
| 8 | endif() |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 9 | |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 10 | # Internal cmake modules |
| 11 | set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) |
| 12 | |
Pierre Ossman | 7f44326 | 2011-03-08 13:06:46 +0000 | [diff] [blame] | 13 | include(CheckIncludeFiles) |
| 14 | include(CheckFunctionExists) |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 15 | include(CheckLibraryExists) |
Pierre Ossman | 7f44326 | 2011-03-08 13:06:46 +0000 | [diff] [blame] | 16 | include(CheckTypeSize) |
| 17 | include(CheckCSourceCompiles) |
Pierre Ossman | 89f868a | 2011-04-11 11:59:31 +0000 | [diff] [blame] | 18 | include(CheckCXXSourceCompiles) |
DRC | 4e326a0 | 2011-07-28 08:06:39 +0000 | [diff] [blame] | 19 | include(CheckCSourceRuns) |
Pierre Ossman | 7f44326 | 2011-03-08 13:06:46 +0000 | [diff] [blame] | 20 | |
Henrik Andersson | 23029cc | 2011-06-09 09:13:23 +0000 | [diff] [blame] | 21 | include(CMakeMacroLibtoolFile) |
| 22 | |
Peter Åstrand | bb445ef | 2011-04-28 09:29:13 +0000 | [diff] [blame] | 23 | project(tigervnc) |
Pierre Ossman | eefa6fe | 2017-04-19 15:25:23 +0200 | [diff] [blame^] | 24 | set(VERSION 1.8.80) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 25 | |
| 26 | # The RC version must always be four comma-separated numbers |
Pierre Ossman | eefa6fe | 2017-04-19 15:25:23 +0200 | [diff] [blame^] | 27 | set(RCVERSION 1,8,80,0) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 28 | |
Pierre Ossman | 95e28f7 | 2012-03-27 10:24:53 +0000 | [diff] [blame] | 29 | # Installation paths |
| 30 | set(BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin") |
| 31 | set(DATA_DIR "${CMAKE_INSTALL_PREFIX}/share") |
| 32 | set(MAN_DIR "${DATA_DIR}/man") |
| 33 | set(LOCALE_DIR "${DATA_DIR}/locale") |
| 34 | set(DOC_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/${CMAKE_PROJECT_NAME}-${VERSION}") |
| 35 | |
| 36 | if(WIN32) |
| 37 | set(BIN_DIR "${CMAKE_INSTALL_PREFIX}") |
| 38 | set(DOC_DIR "${CMAKE_INSTALL_PREFIX}") |
| 39 | endif() |
| 40 | |
Pierre Ossman | e811516 | 2011-03-03 12:51:38 +0000 | [diff] [blame] | 41 | if(MSVC) |
DRC | 60d6158 | 2012-01-18 08:10:21 +0000 | [diff] [blame] | 42 | 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] | 43 | endif() |
| 44 | |
Pierre Ossman | 5945d73 | 2014-09-22 13:13:15 +0200 | [diff] [blame] | 45 | if(NOT BUILD_TIMESTAMP) |
| 46 | set(BUILD_TIMESTAMP "") |
DRC | 872e5dd | 2015-10-17 18:55:08 -0500 | [diff] [blame] | 47 | execute_process(COMMAND "date" "+%Y-%m-%d %H:%M" OUTPUT_VARIABLE BUILD_TIMESTAMP) |
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}") |
DRC | 872e5dd | 2015-10-17 18:55:08 -0500 | [diff] [blame] | 60 | message(STATUS "BUILD_TIMESTAMP = ${BUILD_TIMESTAMP}") |
Pierre Ossman | 5945d73 | 2014-09-22 13:13:15 +0200 | [diff] [blame] | 61 | add_definitions(-DBUILD_TIMESTAMP="${BUILD_TIMESTAMP}") |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 62 | |
Pierre Ossman | 8eaa190 | 2014-03-19 12:43:51 +0000 | [diff] [blame] | 63 | # We want to keep our asserts even in release builds so remove NDEBUG |
| 64 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -UNDEBUG") |
| 65 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -UNDEBUG") |
| 66 | set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -UNDEBUG") |
| 67 | set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -UNDEBUG") |
| 68 | set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -UNDEBUG") |
| 69 | set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -UNDEBUG") |
| 70 | |
Pierre Ossman | 7ca879f | 2015-03-03 16:02:03 +0100 | [diff] [blame] | 71 | # Tell the compiler to be stringent |
| 72 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wformat=2") |
| 73 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wformat=2") |
Pierre Ossman | 123d59c | 2015-03-03 16:50:47 +0100 | [diff] [blame] | 74 | # Make sure we catch these issues whilst developing |
| 75 | IF(CMAKE_BUILD_TYPE MATCHES Debug) |
| 76 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") |
| 77 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") |
Pierre Ossman | 123d59c | 2015-03-03 16:50:47 +0100 | [diff] [blame] | 78 | ENDIF() |
Pierre Ossman | 7ca879f | 2015-03-03 16:02:03 +0100 | [diff] [blame] | 79 | |
Pierre Ossman | 86640e8 | 2015-09-29 09:40:20 +0200 | [diff] [blame] | 80 | option(ENABLE_ASAN "Enable address sanitizer support" OFF) |
| 81 | if(ENABLE_ASAN AND NOT WIN32 AND NOT APPLE) |
| 82 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") |
| 83 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") |
| 84 | endif() |
| 85 | |
Pierre Ossman | b74728f | 2015-11-13 14:06:35 +0100 | [diff] [blame] | 86 | option(ENABLE_TSAN "Enable thread sanitizer support" OFF) |
| 87 | if(ENABLE_TSAN AND NOT WIN32 AND NOT APPLE AND CMAKE_SIZEOF_VOID_P MATCHES 8) |
| 88 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread") |
| 89 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread") |
| 90 | endif() |
| 91 | |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 92 | if(NOT DEFINED BUILD_WINVNC) |
DRC | 3080ec4 | 2011-10-12 20:00:55 +0000 | [diff] [blame] | 93 | set(BUILD_WINVNC 1) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 94 | endif() |
| 95 | |
Pierre Ossman | 1cc323d | 2015-11-12 12:17:34 +0100 | [diff] [blame] | 96 | # Minimum version is Windows Vista/2008 (6.0) |
DRC | 2301beb | 2011-06-22 05:46:53 +0000 | [diff] [blame] | 97 | if(WIN32) |
Pierre Ossman | 1cc323d | 2015-11-12 12:17:34 +0100 | [diff] [blame] | 98 | add_definitions(-D_WIN32_WINNT=0x0600) |
Pierre Ossman | 9640f44 | 2011-03-08 13:12:33 +0000 | [diff] [blame] | 99 | endif() |
| 100 | |
Pierre Ossman | 69314c7 | 2011-03-08 12:18:13 +0000 | [diff] [blame] | 101 | if(CMAKE_SIZEOF_VOID_P MATCHES 8) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 102 | message(STATUS "64-bit build") |
| 103 | else() |
| 104 | message(STATUS "32-bit build") |
| 105 | endif() |
| 106 | |
Joel Teichroeb | ec71201 | 2016-07-12 20:52:04 -0700 | [diff] [blame] | 107 | # Versions of CMake before 2.8.7 do not properly support resource compilation |
| 108 | # with MinGW. Boo! |
| 109 | if(MINGW AND "${CMAKE_VERSION}" VERSION_LESS "2.8.7") |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 110 | if(NOT DEFINED RC) |
| 111 | set(CMAKE_RC_COMPILER_INIT windres) |
| 112 | else() |
| 113 | set(CMAKE_RC_COMPILER_INIT ${RC}) |
| 114 | endif() |
| 115 | enable_language(RC) |
| 116 | message(STATUS "Resource compiler: ${CMAKE_RC_COMPILER}") |
| 117 | set(CMAKE_RC_COMPILE_OBJECT |
| 118 | "<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> -o <OBJECT> --output-format=coff <SOURCE>") |
| 119 | endif() |
| 120 | |
DRC | 3080ec4 | 2011-10-12 20:00:55 +0000 | [diff] [blame] | 121 | # MinGW64 has header support but no library support for IActiveDesktop, so we |
| 122 | # 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] | 123 | # in common/os if either doesn't exist. |
DRC | 3080ec4 | 2011-10-12 20:00:55 +0000 | [diff] [blame] | 124 | if(WIN32) |
| 125 | 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) |
| 126 | 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) |
| 127 | endif() |
| 128 | |
Pierre Ossman | 8f64ef7 | 2011-03-08 16:32:49 +0000 | [diff] [blame] | 129 | # X11 stuff. It's in a if() so that we can say REQUIRED |
DRC | 1b7abb9 | 2011-06-23 19:12:08 +0000 | [diff] [blame] | 130 | if(UNIX AND NOT APPLE) |
Pierre Ossman | 8f64ef7 | 2011-03-08 16:32:49 +0000 | [diff] [blame] | 131 | find_package(X11 REQUIRED) |
| 132 | endif() |
| 133 | |
Pierre Ossman | a7769f2 | 2011-03-03 09:44:49 +0000 | [diff] [blame] | 134 | # Check for zlib |
Pierre Ossman | cc8c6a2 | 2015-02-03 09:54:49 +0100 | [diff] [blame] | 135 | find_package(ZLIB REQUIRED) |
Pierre Ossman | a7769f2 | 2011-03-03 09:44:49 +0000 | [diff] [blame] | 136 | |
Peter Åstrand | bb445ef | 2011-04-28 09:29:13 +0000 | [diff] [blame] | 137 | # Check for gettext |
| 138 | option(ENABLE_NLS "Enable translation of program messages" ON) |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 139 | if(ENABLE_NLS) |
| 140 | # Tools |
DRC | 2690f7a | 2011-06-24 04:17:02 +0000 | [diff] [blame] | 141 | find_package(Gettext) |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 142 | |
| 143 | # Gettext needs iconv |
DRC | 2690f7a | 2011-06-24 04:17:02 +0000 | [diff] [blame] | 144 | find_package(Iconv) |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 145 | |
DRC | 2690f7a | 2011-06-24 04:17:02 +0000 | [diff] [blame] | 146 | if(ICONV_FOUND) |
| 147 | # Headers and libraries (copied from licq) |
| 148 | set(GETTEXT_FOUND FALSE) |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 149 | |
DRC | 2690f7a | 2011-06-24 04:17:02 +0000 | [diff] [blame] | 150 | find_path(GETTEXT_INCLUDE_DIR libintl.h) |
| 151 | if(GETTEXT_INCLUDE_DIR) |
| 152 | set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES}) |
Pierre Ossman | 14c563a | 2016-03-10 17:08:32 +0100 | [diff] [blame] | 153 | set(CMAKE_REQUIRED_FLAGS -fno-builtin-dgettext) |
DRC | 2690f7a | 2011-06-24 04:17:02 +0000 | [diff] [blame] | 154 | check_function_exists(dgettext LIBC_HAS_DGETTEXT) |
| 155 | if(LIBC_HAS_DGETTEXT) |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 156 | set(GETTEXT_FOUND TRUE) |
DRC | 2690f7a | 2011-06-24 04:17:02 +0000 | [diff] [blame] | 157 | else() |
| 158 | find_library(LIBINTL_LIBRARY NAMES intl libintl) |
Pierre Ossman | 210b4b5 | 2016-03-29 13:31:21 +0200 | [diff] [blame] | 159 | if(LIBINTL_LIBRARY) |
| 160 | check_library_exists(${LIBINTL_LIBRARY} "dgettext" "" LIBINTL_HAS_DGETTEXT) |
| 161 | if(LIBINTL_HAS_DGETTEXT) |
| 162 | set(GETTEXT_LIBRARIES ${LIBINTL_LIBRARY} ${ICONV_LIBRARIES}) |
| 163 | set(GETTEXT_FOUND TRUE) |
| 164 | endif() |
DRC | 2690f7a | 2011-06-24 04:17:02 +0000 | [diff] [blame] | 165 | endif() |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 166 | endif() |
DRC | 2690f7a | 2011-06-24 04:17:02 +0000 | [diff] [blame] | 167 | set(CMAKE_REQUIRED_LIBRARIES) |
Pierre Ossman | 14c563a | 2016-03-10 17:08:32 +0100 | [diff] [blame] | 168 | set(CMAKE_REQUIRED_FLAGS) |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 169 | endif() |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 170 | endif() |
| 171 | |
DRC | 37596dd | 2011-11-08 08:38:58 +0000 | [diff] [blame] | 172 | if(NOT GETTEXT_FOUND OR NOT ICONV_FOUND) |
DRC | 2690f7a | 2011-06-24 04:17:02 +0000 | [diff] [blame] | 173 | message(WARNING "Gettext NOT found. Native Language Support disabled.") |
| 174 | set(ENABLE_NLS 0) |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 175 | endif() |
| 176 | endif() |
Peter Åstrand | bb445ef | 2011-04-28 09:29:13 +0000 | [diff] [blame] | 177 | |
Pierre Ossman | 4c6bd4c | 2011-03-03 09:55:21 +0000 | [diff] [blame] | 178 | # Check for libjpeg |
| 179 | find_package(JPEG REQUIRED) |
| 180 | |
Pierre Ossman | 6fa0749 | 2011-03-04 11:35:24 +0000 | [diff] [blame] | 181 | # 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] | 182 | set(CMAKE_REQUIRED_LIBRARIES ${JPEG_LIBRARIES}) |
| 183 | set(CMAKE_REQUIRED_FLAGS -I${JPEG_INCLUDE_DIR}) |
DRC | fe06e61 | 2011-06-07 01:55:12 +0000 | [diff] [blame] | 184 | |
DRC | cebb1ce | 2011-08-01 20:25:40 +0000 | [diff] [blame] | 185 | set(JPEG_TEST_SOURCE "\n |
DRC | 4e326a0 | 2011-07-28 08:06:39 +0000 | [diff] [blame] | 186 | #include <stdio.h>\n |
| 187 | #include <jpeglib.h>\n |
| 188 | int main(void) {\n |
| 189 | struct jpeg_compress_struct cinfo;\n |
| 190 | struct jpeg_error_mgr jerr;\n |
| 191 | cinfo.err=jpeg_std_error(&jerr);\n |
| 192 | jpeg_create_compress(&cinfo);\n |
| 193 | cinfo.input_components = 3;\n |
| 194 | jpeg_set_defaults(&cinfo);\n |
| 195 | cinfo.in_color_space = JCS_EXT_RGB;\n |
| 196 | jpeg_default_colorspace(&cinfo);\n |
| 197 | return 0;\n |
DRC | cebb1ce | 2011-08-01 20:25:40 +0000 | [diff] [blame] | 198 | }") |
| 199 | |
| 200 | if(CMAKE_CROSSCOMPILING) |
| 201 | check_c_source_compiles("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO) |
| 202 | else() |
| 203 | check_c_source_runs("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO) |
| 204 | endif() |
DRC | fe06e61 | 2011-06-07 01:55:12 +0000 | [diff] [blame] | 205 | |
| 206 | set(CMAKE_REQUIRED_LIBRARIES) |
| 207 | set(CMAKE_REQUIRED_FLAGS) |
DRC | 4e326a0 | 2011-07-28 08:06:39 +0000 | [diff] [blame] | 208 | set(CMAKE_REQUIRED_DEFINITIONS) |
DRC | fe06e61 | 2011-06-07 01:55:12 +0000 | [diff] [blame] | 209 | |
DRC | 1953b51 | 2011-06-24 04:19:36 +0000 | [diff] [blame] | 210 | if(NOT FOUND_LIBJPEG_TURBO) |
Pierre Ossman | 6fa0749 | 2011-03-04 11:35:24 +0000 | [diff] [blame] | 211 | message(STATUS "WARNING: You are not using libjpeg-turbo. Performance will suffer.") |
| 212 | endif() |
| 213 | |
DRC | fd9f319 | 2015-10-16 03:28:58 -0500 | [diff] [blame] | 214 | include_directories(${JPEG_INCLUDE_DIR}) |
| 215 | |
DRC | 7636ad0 | 2011-10-04 04:03:34 +0000 | [diff] [blame] | 216 | option(BUILD_JAVA "Build Java version of the TigerVNC Viewer" FALSE) |
| 217 | if(BUILD_JAVA) |
DRC | c19ab9e | 2011-10-07 05:38:00 +0000 | [diff] [blame] | 218 | add_subdirectory(java) |
DRC | 7636ad0 | 2011-10-04 04:03:34 +0000 | [diff] [blame] | 219 | endif() |
| 220 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 221 | # Check for FLTK |
DRC | 3591fa5 | 2011-11-03 19:01:18 +0000 | [diff] [blame] | 222 | set(FLTK_SKIP_FLUID TRUE) |
| 223 | set(FLTK_SKIP_OPENGL TRUE) |
DRC | 3591fa5 | 2011-11-03 19:01:18 +0000 | [diff] [blame] | 224 | set(FLTK_SKIP_FORMS TRUE) |
| 225 | find_package(FLTK) |
Pierre Ossman | 89f868a | 2011-04-11 11:59:31 +0000 | [diff] [blame] | 226 | |
DRC | 16457a2 | 2012-01-17 23:33:29 +0000 | [diff] [blame] | 227 | if(UNIX AND NOT APPLE) |
DRC | 3591fa5 | 2011-11-03 19:01:18 +0000 | [diff] [blame] | 228 | # No proper handling for extra X11 libs that FLTK might need... |
| 229 | if(X11_Xft_FOUND) |
Pierre Ossman | e43d1aa | 2012-03-27 10:29:50 +0000 | [diff] [blame] | 230 | # Xft headers include references to fontconfig, so we need |
| 231 | # to link to that as well |
| 232 | find_library(FONTCONFIG_LIB fontconfig) |
| 233 | set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xft_LIB} ${FONTCONFIG_LIB}) |
Pierre Ossman | 835b4ef | 2011-06-08 17:02:36 +0000 | [diff] [blame] | 234 | endif() |
DRC | 3591fa5 | 2011-11-03 19:01:18 +0000 | [diff] [blame] | 235 | if(X11_Xinerama_FOUND) |
| 236 | set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xinerama_LIB}) |
DRC | 2ff39b8 | 2011-07-28 08:38:59 +0000 | [diff] [blame] | 237 | endif() |
DRC | 3591fa5 | 2011-11-03 19:01:18 +0000 | [diff] [blame] | 238 | if(X11_Xfixes_FOUND) |
| 239 | set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xfixes_LIB}) |
DRC | 2ff39b8 | 2011-07-28 08:38:59 +0000 | [diff] [blame] | 240 | endif() |
DRC | 3591fa5 | 2011-11-03 19:01:18 +0000 | [diff] [blame] | 241 | if(X11_Xcursor_FOUND) |
| 242 | set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xcursor_LIB}) |
DRC | 2ff39b8 | 2011-07-28 08:38:59 +0000 | [diff] [blame] | 243 | endif() |
Peter Åstrand (astrand) | c4bc5a8 | 2015-02-10 12:21:05 +0100 | [diff] [blame] | 244 | if(X11_Xrender_FOUND) |
| 245 | set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xrender_LIB}) |
| 246 | endif() |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 247 | endif() |
| 248 | |
Adam Tkac | 125bd25 | 2011-01-19 14:20:34 +0000 | [diff] [blame] | 249 | # Check for GNUTLS library |
Pierre Ossman | 9506420 | 2011-05-30 12:22:39 +0000 | [diff] [blame] | 250 | option(ENABLE_GNUTLS "Enable protocol encryption and advanced authentication" ON) |
Pierre Ossman | 32c88c4 | 2011-05-27 11:50:58 +0000 | [diff] [blame] | 251 | if(ENABLE_GNUTLS) |
Pierre Ossman | 9506420 | 2011-05-30 12:22:39 +0000 | [diff] [blame] | 252 | find_package(GnuTLS) |
| 253 | if (GNUTLS_FOUND) |
| 254 | include_directories(${GNUTLS_INCLUDE_DIR}) |
| 255 | add_definitions("-DHAVE_GNUTLS") |
| 256 | add_definitions(${GNUTLS_DEFINITIONS}) |
Pierre Ossman | 9506420 | 2011-05-30 12:22:39 +0000 | [diff] [blame] | 257 | endif() |
Adam Tkac | 125bd25 | 2011-01-19 14:20:34 +0000 | [diff] [blame] | 258 | endif() |
| 259 | |
DRC | 777290b | 2011-06-22 00:18:17 +0000 | [diff] [blame] | 260 | # Check for PAM library |
| 261 | option(ENABLE_PAM "Enable PAM authentication support" ON) |
| 262 | if(ENABLE_PAM) |
| 263 | check_include_files(security/pam_appl.h HAVE_PAM_H) |
| 264 | set(CMAKE_REQUIRED_LIBRARIES -lpam) |
| 265 | check_function_exists(pam_start HAVE_PAM_START) |
| 266 | set(CMAKE_REQUIRED_LIBRARIES) |
| 267 | if(HAVE_PAM_H AND HAVE_PAM_START) |
| 268 | set(PAM_LIBS pam) |
| 269 | else() |
| 270 | set(ENABLE_PAM 0) |
| 271 | endif() |
| 272 | endif() |
| 273 | set(HAVE_PAM ${ENABLE_PAM}) |
| 274 | |
Pierre Ossman | ee0e362 | 2011-03-08 13:08:15 +0000 | [diff] [blame] | 275 | # Generate config.h and make sure the source finds it |
DRC | 1980dd5 | 2011-06-24 19:28:27 +0000 | [diff] [blame] | 276 | configure_file(config.h.in config.h) |
DRC | 6375809 | 2010-11-09 19:24:12 +0000 | [diff] [blame] | 277 | add_definitions(-DHAVE_CONFIG_H) |
| 278 | include_directories(${CMAKE_BINARY_DIR}) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 279 | |
Pierre Ossman | f95272d | 2014-10-17 13:59:35 +0200 | [diff] [blame] | 280 | include(cmake/StaticBuild.cmake) |
| 281 | |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 282 | add_subdirectory(common) |
Pierre Ossman | 8f64ef7 | 2011-03-08 16:32:49 +0000 | [diff] [blame] | 283 | |
| 284 | if(WIN32) |
| 285 | add_subdirectory(win) |
| 286 | else() |
Henrik Andersson | a7a38a6 | 2011-06-10 13:05:09 +0000 | [diff] [blame] | 287 | # No interest in building x related parts on Apple |
| 288 | if(NOT APPLE) |
| 289 | add_subdirectory(unix) |
| 290 | endif() |
Pierre Ossman | 8f64ef7 | 2011-03-08 16:32:49 +0000 | [diff] [blame] | 291 | endif() |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 292 | |
DRC | 3591fa5 | 2011-11-03 19:01:18 +0000 | [diff] [blame] | 293 | if(ENABLE_NLS) |
| 294 | add_subdirectory(po) |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 295 | endif() |
Pierre Ossman | 6412770 | 2012-03-27 12:33:36 +0000 | [diff] [blame] | 296 | |
Peter Åstrand | 889b489 | 2014-02-20 08:04:17 +0000 | [diff] [blame] | 297 | option(BUILD_VIEWER "Build TigerVNC viewer" ON) |
| 298 | if(BUILD_VIEWER) |
| 299 | add_subdirectory(vncviewer) |
| 300 | add_subdirectory(media) |
| 301 | endif() |
DRC | 1a18407 | 2011-06-24 06:55:18 +0000 | [diff] [blame] | 302 | |
Pierre Ossman | 236c03c | 2014-07-04 14:12:49 +0200 | [diff] [blame] | 303 | add_subdirectory(tests) |
| 304 | |
Pierre Ossman | 6412770 | 2012-03-27 12:33:36 +0000 | [diff] [blame] | 305 | |
DRC | 1a18407 | 2011-06-24 06:55:18 +0000 | [diff] [blame] | 306 | include(cmake/BuildPackages.cmake) |
DRC | b714002 | 2011-06-25 07:33:57 +0000 | [diff] [blame] | 307 | |
| 308 | # uninstall |
| 309 | configure_file("${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" |
| 310 | "cmake_uninstall.cmake" IMMEDIATE @ONLY) |
| 311 | |
| 312 | add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P cmake_uninstall.cmake) |