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