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