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