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