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) |
DRC | de30d95 | 2011-06-24 20:05:06 +0000 | [diff] [blame] | 21 | set(VERSION 1.1.80) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 22 | |
| 23 | # The RC version must always be four comma-separated numbers |
DRC | de30d95 | 2011-06-24 20:05:06 +0000 | [diff] [blame] | 24 | set(RCVERSION 1,1,80,0) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 25 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 26 | # Manual toggle until we can deprecate the old viewers |
DRC | de22ae9 | 2011-06-23 16:45:18 +0000 | [diff] [blame] | 27 | option(BUILD_NEW_VNCVIEWER "Build the new FLTK based vncviewer instead of the old ones" ON) |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 28 | |
Pierre Ossman | 8f64ef7 | 2011-03-08 16:32:49 +0000 | [diff] [blame] | 29 | # Compatibility variables for the migration from autotools |
| 30 | add_definitions(-DPACKAGE_NAME="${CMAKE_PROJECT_NAME}") |
| 31 | add_definitions(-DPACKAGE_VERSION="${VERSION}") |
| 32 | add_definitions(-DLOCALEDIR="${CMAKE_INSTALL_PREFIX}/share/locale") |
| 33 | |
Pierre Ossman | e811516 | 2011-03-03 12:51:38 +0000 | [diff] [blame] | 34 | # Try to encode today's date into the build id. We assume that MSVC |
| 35 | # means we need to use a native Windows method, otherwise we assume |
| 36 | # some kind of Unix system. The id will be empty if things fail. |
| 37 | set(BUILD "") |
| 38 | if(MSVC) |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 39 | execute_process(COMMAND "${CMAKE_SOURCE_DIR}/cmake/getdate.bat" |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 40 | OUTPUT_VARIABLE BUILD) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 41 | else() |
Pierre Ossman | e811516 | 2011-03-03 12:51:38 +0000 | [diff] [blame] | 42 | execute_process(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE BUILD) |
| 43 | endif() |
| 44 | |
| 45 | if(NOT BUILD) |
| 46 | set(BUILD "") |
| 47 | else() |
| 48 | string(REGEX REPLACE "\n" "" BUILD ${BUILD}) |
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 | |
| 59 | # This only works if building from the command line. There is currently no way |
| 60 | # to set a variable's value based on the build type when using the MSVC IDE. |
| 61 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") |
| 62 | set(BUILD "${BUILD}d") |
| 63 | endif() |
| 64 | |
| 65 | message(STATUS "VERSION = ${VERSION}, BUILD = ${BUILD}") |
DRC | d8e93dc | 2011-07-28 22:13:40 +0000 | [diff] [blame] | 66 | add_definitions(-D__BUILD__="${BUILD}") |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 67 | |
| 68 | if(NOT DEFINED BUILD_WINVNC) |
| 69 | if(MSVC) |
| 70 | set(BUILD_WINVNC 1) |
| 71 | else() |
| 72 | set(BUILD_WINVNC 0) |
| 73 | endif() |
| 74 | endif() |
| 75 | |
| 76 | if(MSVC) |
| 77 | # Use the static C library for all build types |
| 78 | foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE |
| 79 | CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO |
| 80 | CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE |
| 81 | CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) |
| 82 | if(${var} MATCHES "/MD") |
| 83 | string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}") |
| 84 | endif() |
| 85 | endforeach() |
| 86 | |
| 87 | # NOTE: 4244 and 4267 are 64-bit to 32-bit conversion warnings, so normally |
| 88 | # it is not a good idea to disable them, but we do this to duplicate the |
| 89 | # behavior of GCC, which is less strict. |
| 90 | add_definitions(-wd4244 -wd4267 -wd4800 -wd4996) |
DRC | fcc0d1c | 2011-08-10 20:02:13 +0000 | [diff] [blame] | 91 | |
| 92 | # Avoid linker warning when doing Debug build if dependent libraries are |
| 93 | # linked with the Release version of the static C library. |
| 94 | set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:LIBCMT") |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 95 | endif() |
| 96 | |
Pierre Ossman | 9640f44 | 2011-03-08 13:12:33 +0000 | [diff] [blame] | 97 | # Minimum version is Windows 2000 (5.0) |
DRC | 2301beb | 2011-06-22 05:46:53 +0000 | [diff] [blame] | 98 | if(WIN32) |
| 99 | if(NOT CMAKE_SIZEOF_VOID_P MATCHES 8) |
| 100 | add_definitions(-D_WIN32_IE=0x0500 -D_WIN32_WINNT=0x0500) |
| 101 | else() |
DRC | 7cf9fbc | 2011-07-06 07:23:51 +0000 | [diff] [blame] | 102 | set(WIN64 1) |
DRC | 2301beb | 2011-06-22 05:46:53 +0000 | [diff] [blame] | 103 | # Win64 doesn't like us requesting a Windows version that didn't have |
| 104 | # 64-bit support. Request XP (5.1) instead. |
| 105 | add_definitions(-D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501) |
| 106 | endif() |
Pierre Ossman | 9640f44 | 2011-03-08 13:12:33 +0000 | [diff] [blame] | 107 | endif() |
| 108 | |
Pierre Ossman | 69314c7 | 2011-03-08 12:18:13 +0000 | [diff] [blame] | 109 | if(CMAKE_SIZEOF_VOID_P MATCHES 8) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 110 | message(STATUS "64-bit build") |
| 111 | else() |
| 112 | message(STATUS "32-bit build") |
| 113 | endif() |
| 114 | |
DRC | 883f2d6 | 2011-07-28 09:58:24 +0000 | [diff] [blame] | 115 | # This ensures that we don't depend on libstdc++ or libgcc |
| 116 | if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE AND NOT CYGWIN) |
| 117 | option(BUILD_STATIC |
| 118 | "Link statically against libgcc and libstdc++, if possible" OFF) |
| 119 | if(BUILD_STATIC) |
| 120 | # For some reason, simply passing ${CMAKE_CXX_FLAGS} to the compiler in |
| 121 | # execute_process() doesn't work. Grrr... |
DRC | ca91758 | 2011-08-08 03:22:15 +0000 | [diff] [blame] | 122 | if(CMAKE_SIZEOF_VOID_P MATCHES 8) |
DRC | 883f2d6 | 2011-07-28 09:58:24 +0000 | [diff] [blame] | 123 | execute_process(COMMAND ${CMAKE_CXX_COMPILER} -m64 |
| 124 | --print-file-name=libstdc++.a OUTPUT_VARIABLE LIBSTDCPLUSPLUS |
| 125 | RESULT_VARIABLE RESULT) |
| 126 | else() |
| 127 | execute_process(COMMAND ${CMAKE_CXX_COMPILER} -m32 |
| 128 | --print-file-name=libstdc++.a OUTPUT_VARIABLE LIBSTDCPLUSPLUS |
| 129 | RESULT_VARIABLE RESULT) |
| 130 | endif() |
| 131 | string(REGEX REPLACE "\n" "" LIBSTDCPLUSPLUS ${LIBSTDCPLUSPLUS}) |
| 132 | if(RESULT MATCHES 0 AND LIBSTDCPLUSPLUS) |
| 133 | message(STATUS "Linking with static libstdc++:\n ${LIBSTDCPLUSPLUS}") |
| 134 | file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/staticlib) |
| 135 | execute_process(COMMAND ${CMAKE_COMMAND} -E remove |
| 136 | ${CMAKE_BINARY_DIR}/staticlib/libstdc++.a) |
| 137 | execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink |
| 138 | ${LIBSTDCPLUSPLUS} ${CMAKE_BINARY_DIR}/staticlib/libstdc++.a) |
| 139 | set(CMAKE_EXE_LINKER_FLAGS |
| 140 | "${CMAKE_EXE_LINKER_FLAGS} -L${CMAKE_BINARY_DIR}/staticlib") |
| 141 | set(CMAKE_SHARED_LINKER_FLAGS |
| 142 | "${CMAKE_SHARED_LINKER_FLAGS} -L${CMAKE_BINARY_DIR}/staticlib") |
| 143 | else() |
| 144 | message(WARNING Cannot find static libstdc++. VirtualGL will depend on dynamic libstdc++.) |
| 145 | endif() |
| 146 | add_definitions(-static-libgcc) |
| 147 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc") |
| 148 | set(CMAKE_SHARED_LINKER_FLAGS |
| 149 | "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc") |
| 150 | endif() |
| 151 | endif() |
| 152 | |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 153 | # CMake doesn't properly support resource compilation with MinGW. Boo! |
| 154 | if(MINGW) |
| 155 | if(NOT DEFINED RC) |
| 156 | set(CMAKE_RC_COMPILER_INIT windres) |
| 157 | else() |
| 158 | set(CMAKE_RC_COMPILER_INIT ${RC}) |
| 159 | endif() |
| 160 | enable_language(RC) |
| 161 | message(STATUS "Resource compiler: ${CMAKE_RC_COMPILER}") |
| 162 | set(CMAKE_RC_COMPILE_OBJECT |
| 163 | "<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> -o <OBJECT> --output-format=coff <SOURCE>") |
| 164 | endif() |
| 165 | |
Pierre Ossman | 8f64ef7 | 2011-03-08 16:32:49 +0000 | [diff] [blame] | 166 | # X11 stuff. It's in a if() so that we can say REQUIRED |
DRC | 1b7abb9 | 2011-06-23 19:12:08 +0000 | [diff] [blame] | 167 | if(UNIX AND NOT APPLE) |
Pierre Ossman | 8f64ef7 | 2011-03-08 16:32:49 +0000 | [diff] [blame] | 168 | find_package(X11 REQUIRED) |
| 169 | endif() |
| 170 | |
Pierre Ossman | a7769f2 | 2011-03-03 09:44:49 +0000 | [diff] [blame] | 171 | # Check for zlib |
| 172 | find_package(ZLIB) |
| 173 | option(USE_INCLUDED_ZLIB "Force use of the bundled zlib") |
| 174 | if(NOT ZLIB_FOUND) |
Pierre Ossman | a7769f2 | 2011-03-03 09:44:49 +0000 | [diff] [blame] | 175 | set(USE_INCLUDED_ZLIB 1) |
| 176 | endif() |
DRC | f340e7c | 2011-08-23 20:26:11 +0000 | [diff] [blame] | 177 | if(USE_INCLUDED_ZLIB) |
| 178 | message(STATUS "Using included zlib library") |
| 179 | endif() |
Pierre Ossman | a7769f2 | 2011-03-03 09:44:49 +0000 | [diff] [blame] | 180 | |
Peter Åstrand | bb445ef | 2011-04-28 09:29:13 +0000 | [diff] [blame] | 181 | # Check for gettext |
| 182 | option(ENABLE_NLS "Enable translation of program messages" ON) |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 183 | if(ENABLE_NLS) |
| 184 | # Tools |
DRC | 2690f7a | 2011-06-24 04:17:02 +0000 | [diff] [blame] | 185 | find_package(Gettext) |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 186 | set(LOCALE_DIR "${CMAKE_INSTALL_PREFIX}/share/locale") |
| 187 | |
| 188 | # Gettext needs iconv |
DRC | 2690f7a | 2011-06-24 04:17:02 +0000 | [diff] [blame] | 189 | find_package(Iconv) |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 190 | |
DRC | 2690f7a | 2011-06-24 04:17:02 +0000 | [diff] [blame] | 191 | if(ICONV_FOUND) |
| 192 | # Headers and libraries (copied from licq) |
| 193 | set(GETTEXT_FOUND FALSE) |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 194 | |
DRC | 2690f7a | 2011-06-24 04:17:02 +0000 | [diff] [blame] | 195 | find_path(GETTEXT_INCLUDE_DIR libintl.h) |
| 196 | if(GETTEXT_INCLUDE_DIR) |
| 197 | set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES}) |
| 198 | check_function_exists(dgettext LIBC_HAS_DGETTEXT) |
| 199 | if(LIBC_HAS_DGETTEXT) |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 200 | set(GETTEXT_FOUND TRUE) |
DRC | 2690f7a | 2011-06-24 04:17:02 +0000 | [diff] [blame] | 201 | else() |
| 202 | find_library(LIBINTL_LIBRARY NAMES intl libintl) |
| 203 | check_library_exists(${LIBINTL_LIBRARY} "dgettext" "" LIBINTL_HAS_DGETTEXT) |
| 204 | if(LIBINTL_HAS_DGETTEXT) |
| 205 | set(GETTEXT_LIBRARIES ${LIBINTL_LIBRARY} ${ICONV_LIBRARIES}) |
| 206 | set(GETTEXT_FOUND TRUE) |
| 207 | endif() |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 208 | endif() |
DRC | 2690f7a | 2011-06-24 04:17:02 +0000 | [diff] [blame] | 209 | set(CMAKE_REQUIRED_LIBRARIES) |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 210 | endif() |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 211 | endif() |
| 212 | |
| 213 | if(NOT GETTEXT_FOUND) |
DRC | 2690f7a | 2011-06-24 04:17:02 +0000 | [diff] [blame] | 214 | message(WARNING "Gettext NOT found. Native Language Support disabled.") |
| 215 | set(ENABLE_NLS 0) |
Pierre Ossman | b232b5f | 2011-04-28 14:38:04 +0000 | [diff] [blame] | 216 | endif() |
| 217 | endif() |
Peter Åstrand | bb445ef | 2011-04-28 09:29:13 +0000 | [diff] [blame] | 218 | |
Pierre Ossman | 4c6bd4c | 2011-03-03 09:55:21 +0000 | [diff] [blame] | 219 | # Check for libjpeg |
| 220 | find_package(JPEG REQUIRED) |
| 221 | |
Pierre Ossman | 6fa0749 | 2011-03-04 11:35:24 +0000 | [diff] [blame] | 222 | # 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] | 223 | set(CMAKE_REQUIRED_LIBRARIES ${JPEG_LIBRARIES}) |
| 224 | set(CMAKE_REQUIRED_FLAGS -I${JPEG_INCLUDE_DIR}) |
DRC | 4e326a0 | 2011-07-28 08:06:39 +0000 | [diff] [blame] | 225 | if(MSVC) |
| 226 | set(CMAKE_REQUIRED_DEFINITIONS -MT) |
| 227 | endif() |
DRC | fe06e61 | 2011-06-07 01:55:12 +0000 | [diff] [blame] | 228 | |
DRC | cebb1ce | 2011-08-01 20:25:40 +0000 | [diff] [blame] | 229 | set(JPEG_TEST_SOURCE "\n |
DRC | 4e326a0 | 2011-07-28 08:06:39 +0000 | [diff] [blame] | 230 | #include <stdio.h>\n |
| 231 | #include <jpeglib.h>\n |
| 232 | int main(void) {\n |
| 233 | struct jpeg_compress_struct cinfo;\n |
| 234 | struct jpeg_error_mgr jerr;\n |
| 235 | cinfo.err=jpeg_std_error(&jerr);\n |
| 236 | jpeg_create_compress(&cinfo);\n |
| 237 | cinfo.input_components = 3;\n |
| 238 | jpeg_set_defaults(&cinfo);\n |
| 239 | cinfo.in_color_space = JCS_EXT_RGB;\n |
| 240 | jpeg_default_colorspace(&cinfo);\n |
| 241 | return 0;\n |
DRC | cebb1ce | 2011-08-01 20:25:40 +0000 | [diff] [blame] | 242 | }") |
| 243 | |
| 244 | if(CMAKE_CROSSCOMPILING) |
| 245 | check_c_source_compiles("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO) |
| 246 | else() |
| 247 | check_c_source_runs("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO) |
| 248 | endif() |
DRC | fe06e61 | 2011-06-07 01:55:12 +0000 | [diff] [blame] | 249 | |
| 250 | set(CMAKE_REQUIRED_LIBRARIES) |
| 251 | set(CMAKE_REQUIRED_FLAGS) |
DRC | 4e326a0 | 2011-07-28 08:06:39 +0000 | [diff] [blame] | 252 | set(CMAKE_REQUIRED_DEFINITIONS) |
DRC | fe06e61 | 2011-06-07 01:55:12 +0000 | [diff] [blame] | 253 | |
DRC | 1953b51 | 2011-06-24 04:19:36 +0000 | [diff] [blame] | 254 | if(NOT FOUND_LIBJPEG_TURBO) |
Pierre Ossman | 6fa0749 | 2011-03-04 11:35:24 +0000 | [diff] [blame] | 255 | message(STATUS "WARNING: You are not using libjpeg-turbo. Performance will suffer.") |
| 256 | endif() |
| 257 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 258 | # Check for FLTK |
| 259 | if(BUILD_NEW_VNCVIEWER) |
| 260 | set(FLTK_SKIP_FLUID TRUE) |
| 261 | set(FLTK_SKIP_OPENGL TRUE) |
DRC | 71f2199 | 2011-06-23 09:30:15 +0000 | [diff] [blame] | 262 | set(FLTK_SKIP_IMAGES TRUE) |
| 263 | set(FLTK_SKIP_FORMS TRUE) |
DRC | 2ff39b8 | 2011-07-28 08:38:59 +0000 | [diff] [blame] | 264 | find_package(FLTK) |
Pierre Ossman | 89f868a | 2011-04-11 11:59:31 +0000 | [diff] [blame] | 265 | |
DRC | 1b7abb9 | 2011-06-23 19:12:08 +0000 | [diff] [blame] | 266 | if(NOT APPLE) |
| 267 | # No proper handling for extra X11 libs that FLTK might need... |
| 268 | if(X11_Xft_FOUND) |
| 269 | set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xft_LIB}) |
| 270 | endif() |
| 271 | if(X11_Xinerama_FOUND) |
| 272 | set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xinerama_LIB}) |
| 273 | endif() |
| 274 | if(X11_Xfixes_FOUND) |
| 275 | set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xfixes_LIB}) |
| 276 | endif() |
| 277 | if(X11_Xcursor_FOUND) |
| 278 | set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xcursor_LIB}) |
| 279 | endif() |
Pierre Ossman | 835b4ef | 2011-06-08 17:02:36 +0000 | [diff] [blame] | 280 | endif() |
Pierre Ossman | 4a6be4a | 2011-05-19 14:49:18 +0000 | [diff] [blame] | 281 | |
DRC | 2ff39b8 | 2011-07-28 08:38:59 +0000 | [diff] [blame] | 282 | if(FLTK_FOUND) |
| 283 | set(CMAKE_REQUIRED_INCLUDES ${FLTK_INCLUDE_DIR}) |
| 284 | set(CMAKE_REQUIRED_LIBRARIES ${FLTK_LIBRARIES}) |
Pierre Ossman | 4a6be4a | 2011-05-19 14:49:18 +0000 | [diff] [blame] | 285 | |
DRC | 2ff39b8 | 2011-07-28 08:38:59 +0000 | [diff] [blame] | 286 | # FLTK STR #2599 |
| 287 | check_cxx_source_compiles("#include <FL/Fl_Widget.H>\nint main(int c, char** v) { void (Fl_Widget::*foo)() = &Fl_Widget::set_simple_keyboard; return 0; }" HAVE_FLTK_DEAD_KEYS) |
Pierre Ossman | 4a6be4a | 2011-05-19 14:49:18 +0000 | [diff] [blame] | 288 | |
DRC | 2ff39b8 | 2011-07-28 08:38:59 +0000 | [diff] [blame] | 289 | # FLTK STR #2636 |
| 290 | 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) |
Pierre Ossman | 4a6be4a | 2011-05-19 14:49:18 +0000 | [diff] [blame] | 291 | |
DRC | 2ff39b8 | 2011-07-28 08:38:59 +0000 | [diff] [blame] | 292 | # FLTK STR #2638 |
| 293 | check_cxx_source_compiles("#include <FL/Enumerations.H>\nint main(int c, char** v) { return FL_Volume_Down; }" HAVE_FLTK_MEDIAKEYS) |
Pierre Ossman | cb0cffe | 2011-05-20 14:55:10 +0000 | [diff] [blame] | 294 | |
DRC | 2ff39b8 | 2011-07-28 08:38:59 +0000 | [diff] [blame] | 295 | # FLTK STR #2641 |
| 296 | check_cxx_source_compiles("#include <FL/Enumerations.H>\nint main(int c, char** v) { return FL_FULLSCREEN; }" HAVE_FLTK_FULLSCREEN) |
Pierre Ossman | 4c613d3 | 2011-05-26 14:14:06 +0000 | [diff] [blame] | 297 | |
DRC | 2ff39b8 | 2011-07-28 08:38:59 +0000 | [diff] [blame] | 298 | # FLTK STR #2660 |
| 299 | 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) |
Pierre Ossman | 835b4ef | 2011-06-08 17:02:36 +0000 | [diff] [blame] | 300 | |
DRC | 2ff39b8 | 2011-07-28 08:38:59 +0000 | [diff] [blame] | 301 | set(CMAKE_REQUIRED_INCLUDES) |
| 302 | set(CMAKE_REQUIRED_LIBRARIES) |
| 303 | endif() |
| 304 | |
| 305 | option(USE_INCLUDED_FLTK |
| 306 | "Force the use of the FLTK library bundled with the TigerVNC source") |
| 307 | if(NOT FLTK_FOUND OR NOT HAVE_FLTK_DEAD_KEYS OR NOT HAVE_FLTK_CLIPBOARD |
| 308 | OR NOT HAVE_FLTK_MEDIAKEYS OR NOT HAVE_FLTK_FULLSCREEN |
| 309 | OR NOT HAVE_FLTK_CURSOR) |
| 310 | set(USE_INCLUDED_FLTK 1) |
| 311 | endif() |
| 312 | if(USE_INCLUDED_FLTK) |
DRC | 2ff39b8 | 2011-07-28 08:38:59 +0000 | [diff] [blame] | 313 | set(FLTK_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/common/fltk) |
| 314 | set(FLTK_LIBRARIES) |
| 315 | if(APPLE) |
| 316 | set(FLTK_LIBRARIES "-framework Carbon -framework Cocoa -framework ApplicationServices") |
| 317 | endif() |
DRC | c3f1be6 | 2011-09-14 17:08:29 +0000 | [diff] [blame^] | 318 | if(NOT WIN32) |
| 319 | set(FLTK_LIBRARIES "-ldl") |
| 320 | endif() |
DRC | 2ff39b8 | 2011-07-28 08:38:59 +0000 | [diff] [blame] | 321 | message(STATUS "Using included FLTK library") |
| 322 | endif() |
| 323 | |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 324 | endif() |
| 325 | |
Adam Tkac | 125bd25 | 2011-01-19 14:20:34 +0000 | [diff] [blame] | 326 | # Check for GNUTLS library |
Pierre Ossman | 9506420 | 2011-05-30 12:22:39 +0000 | [diff] [blame] | 327 | option(ENABLE_GNUTLS "Enable protocol encryption and advanced authentication" ON) |
Pierre Ossman | 32c88c4 | 2011-05-27 11:50:58 +0000 | [diff] [blame] | 328 | if(ENABLE_GNUTLS) |
Pierre Ossman | 9506420 | 2011-05-30 12:22:39 +0000 | [diff] [blame] | 329 | find_package(GnuTLS) |
| 330 | if (GNUTLS_FOUND) |
| 331 | include_directories(${GNUTLS_INCLUDE_DIR}) |
| 332 | add_definitions("-DHAVE_GNUTLS") |
| 333 | add_definitions(${GNUTLS_DEFINITIONS}) |
| 334 | |
| 335 | # Detect old version of GnuTLS |
DRC | 17331b9 | 2011-06-07 04:07:20 +0000 | [diff] [blame] | 336 | set(CMAKE_REQUIRED_FLAGS -I${GNUTLS_INCLUDE_DIR}) |
Pierre Ossman | 9506420 | 2011-05-30 12:22:39 +0000 | [diff] [blame] | 337 | set(CMAKE_EXTRA_INCLUDE_FILES gnutls/gnutls.h) |
DRC | 17331b9 | 2011-06-07 04:07:20 +0000 | [diff] [blame] | 338 | set(CMAKE_REQUIRED_LIBRARIES ${GNUTLS_LIBRARIES}) |
DRC | 56e625c | 2011-06-24 03:19:28 +0000 | [diff] [blame] | 339 | if(WIN32) |
| 340 | set(CMAKE_EXTRA_INCLUDE_FILES gcrypt.h ${CMAKE_EXTRA_INCLUDE_FILES}) |
| 341 | set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ws2_32 user32) |
| 342 | endif() |
DRC | 17331b9 | 2011-06-07 04:07:20 +0000 | [diff] [blame] | 343 | if(ZLIB_FOUND) |
| 344 | # When we build against the static version of GnuTLS, we also use the |
| 345 | # included version of Zlib, but it isn't built yet, so we have to use the |
| 346 | # system's version (if available) to perform this test. |
| 347 | set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES};-lz) |
| 348 | endif() |
Pierre Ossman | 9506420 | 2011-05-30 12:22:39 +0000 | [diff] [blame] | 349 | check_function_exists(gnutls_transport_set_global_errno HAVE_OLD_GNUTLS) |
| 350 | check_function_exists(gnutls_x509_crt_print HAVE_GNUTLS_X509_CRT_PRINT) |
| 351 | check_type_size(gnutls_x509_crt_t GNUTLS_X509_CRT_T) |
| 352 | check_type_size(gnutls_datum_t GNUTLS_DATUM_T) |
| 353 | check_type_size(gnutls_pk_algorithm_t GNUTLS_PK_ALGORITHM_T) |
| 354 | check_type_size(gnutls_sign_algorithm_t GNUTLS_SIGN_ALGORITHM_T) |
DRC | 17331b9 | 2011-06-07 04:07:20 +0000 | [diff] [blame] | 355 | set(CMAKE_REQUIRED_FLAGS) |
Pierre Ossman | 9506420 | 2011-05-30 12:22:39 +0000 | [diff] [blame] | 356 | set(CMAKE_EXTRA_INCLUDE_FILES) |
| 357 | set(CMAKE_REQUIRED_LIBRARIES) |
| 358 | endif() |
Adam Tkac | 125bd25 | 2011-01-19 14:20:34 +0000 | [diff] [blame] | 359 | endif() |
| 360 | |
DRC | 777290b | 2011-06-22 00:18:17 +0000 | [diff] [blame] | 361 | # Check for PAM library |
| 362 | option(ENABLE_PAM "Enable PAM authentication support" ON) |
| 363 | if(ENABLE_PAM) |
| 364 | check_include_files(security/pam_appl.h HAVE_PAM_H) |
| 365 | set(CMAKE_REQUIRED_LIBRARIES -lpam) |
| 366 | check_function_exists(pam_start HAVE_PAM_START) |
| 367 | set(CMAKE_REQUIRED_LIBRARIES) |
| 368 | if(HAVE_PAM_H AND HAVE_PAM_START) |
| 369 | set(PAM_LIBS pam) |
| 370 | else() |
| 371 | set(ENABLE_PAM 0) |
| 372 | endif() |
| 373 | endif() |
| 374 | set(HAVE_PAM ${ENABLE_PAM}) |
| 375 | |
Pierre Ossman | ee0e362 | 2011-03-08 13:08:15 +0000 | [diff] [blame] | 376 | # Check for socket functions |
Henrik Andersson | e1fd8e1 | 2011-03-08 13:00:12 +0000 | [diff] [blame] | 377 | if(WIN32) |
Pierre Ossman | 0153e23 | 2011-03-08 13:05:27 +0000 | [diff] [blame] | 378 | set(CMAKE_EXTRA_INCLUDE_FILES winsock2.h ws2tcpip.h) |
Henrik Andersson | e1fd8e1 | 2011-03-08 13:00:12 +0000 | [diff] [blame] | 379 | set(CMAKE_REQUIRED_LIBRARIES ws2_32) |
Pierre Ossman | 0153e23 | 2011-03-08 13:05:27 +0000 | [diff] [blame] | 380 | else() |
| 381 | set(CMAKE_EXTRA_INCLUDE_FILES sys/socket.h) |
Henrik Andersson | e1fd8e1 | 2011-03-08 13:00:12 +0000 | [diff] [blame] | 382 | endif() |
DRC | 6375809 | 2010-11-09 19:24:12 +0000 | [diff] [blame] | 383 | check_function_exists(inet_aton HAVE_INET_ATON) |
| 384 | check_function_exists(inet_ntop HAVE_INET_NTOP) |
Henrik Andersson | e1fd8e1 | 2011-03-08 13:00:12 +0000 | [diff] [blame] | 385 | check_type_size(socklen_t SOCKLEN_T) |
DRC | 6375809 | 2010-11-09 19:24:12 +0000 | [diff] [blame] | 386 | set(CMAKE_EXTRA_INCLUDE_FILES) |
| 387 | set(CMAKE_REQUIRED_LIBRARIES) |
Pierre Ossman | ee0e362 | 2011-03-08 13:08:15 +0000 | [diff] [blame] | 388 | |
| 389 | # Check for the newer standard string functions |
DRC | 6375809 | 2010-11-09 19:24:12 +0000 | [diff] [blame] | 390 | check_function_exists(snprintf HAVE_SNPRINTF) |
| 391 | check_function_exists(strcasecmp HAVE_STRCASECMP) |
| 392 | check_function_exists(strncasecmp HAVE_STRNCASECMP) |
| 393 | check_function_exists(vsnprintf HAVE_VSNPRINTF) |
Pierre Ossman | ee0e362 | 2011-03-08 13:08:15 +0000 | [diff] [blame] | 394 | |
| 395 | # Generate config.h and make sure the source finds it |
DRC | 1980dd5 | 2011-06-24 19:28:27 +0000 | [diff] [blame] | 396 | configure_file(config.h.in config.h) |
DRC | 6375809 | 2010-11-09 19:24:12 +0000 | [diff] [blame] | 397 | add_definitions(-DHAVE_CONFIG_H) |
| 398 | include_directories(${CMAKE_BINARY_DIR}) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 399 | |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 400 | add_subdirectory(common) |
Pierre Ossman | 8f64ef7 | 2011-03-08 16:32:49 +0000 | [diff] [blame] | 401 | |
| 402 | if(WIN32) |
| 403 | add_subdirectory(win) |
| 404 | else() |
Henrik Andersson | a7a38a6 | 2011-06-10 13:05:09 +0000 | [diff] [blame] | 405 | # No interest in building x related parts on Apple |
| 406 | if(NOT APPLE) |
| 407 | add_subdirectory(unix) |
| 408 | endif() |
Pierre Ossman | 8f64ef7 | 2011-03-08 16:32:49 +0000 | [diff] [blame] | 409 | endif() |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 410 | |
| 411 | if(BUILD_NEW_VNCVIEWER) |
DRC | d0b64c9 | 2011-06-07 04:07:41 +0000 | [diff] [blame] | 412 | if(ENABLE_NLS) |
| 413 | add_subdirectory(po) |
| 414 | endif() |
Pierre Ossman | 5156d5e | 2011-03-09 09:42:34 +0000 | [diff] [blame] | 415 | add_subdirectory(vncviewer) |
| 416 | endif() |
DRC | 1a18407 | 2011-06-24 06:55:18 +0000 | [diff] [blame] | 417 | |
| 418 | include(cmake/BuildPackages.cmake) |
DRC | b714002 | 2011-06-25 07:33:57 +0000 | [diff] [blame] | 419 | |
| 420 | # uninstall |
| 421 | configure_file("${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" |
| 422 | "cmake_uninstall.cmake" IMMEDIATE @ONLY) |
| 423 | |
| 424 | add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P cmake_uninstall.cmake) |