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