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