DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 1 | # |
| 2 | # Setup |
| 3 | # |
| 4 | |
| 5 | cmake_minimum_required(VERSION 2.6) |
| 6 | |
| 7 | project(TigerVNC) |
| 8 | set(VERSION 1.0.90) |
| 9 | |
| 10 | # The RC version must always be four comma-separated numbers |
| 11 | set(RCVERSION 1,0,90,0) |
| 12 | |
Pierre Ossman | e811516 | 2011-03-03 12:51:38 +0000 | [diff] [blame] | 13 | # Try to encode today's date into the build id. We assume that MSVC |
| 14 | # means we need to use a native Windows method, otherwise we assume |
| 15 | # some kind of Unix system. The id will be empty if things fail. |
| 16 | set(BUILD "") |
| 17 | if(MSVC) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 18 | execute_process(COMMAND "${CMAKE_SOURCE_DIR}/cmakescripts/getdate.bat" |
| 19 | OUTPUT_VARIABLE BUILD) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 20 | else() |
Pierre Ossman | e811516 | 2011-03-03 12:51:38 +0000 | [diff] [blame] | 21 | execute_process(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE BUILD) |
| 22 | endif() |
| 23 | |
| 24 | if(NOT BUILD) |
| 25 | set(BUILD "") |
| 26 | else() |
| 27 | string(REGEX REPLACE "\n" "" BUILD ${BUILD}) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 28 | endif() |
| 29 | |
Pierre Ossman | 2c66a63 | 2011-03-03 12:52:59 +0000 | [diff] [blame] | 30 | # Default to optimised builds instead of debug ones. Our code has no bugs ;) |
| 31 | # (CMake makes it fairly easy to toggle this back to Debug if needed) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 32 | if(NOT CMAKE_BUILD_TYPE) |
| 33 | set(CMAKE_BUILD_TYPE Release) |
| 34 | endif() |
| 35 | |
| 36 | message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}") |
| 37 | |
| 38 | # This only works if building from the command line. There is currently no way |
| 39 | # to set a variable's value based on the build type when using the MSVC IDE. |
| 40 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") |
| 41 | set(BUILD "${BUILD}d") |
| 42 | endif() |
| 43 | |
| 44 | message(STATUS "VERSION = ${VERSION}, BUILD = ${BUILD}") |
| 45 | |
| 46 | if(NOT DEFINED BUILD_WINVNC) |
| 47 | if(MSVC) |
| 48 | set(BUILD_WINVNC 1) |
| 49 | else() |
| 50 | set(BUILD_WINVNC 0) |
| 51 | endif() |
| 52 | endif() |
| 53 | |
| 54 | if(MSVC) |
| 55 | # Use the static C library for all build types |
| 56 | foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE |
| 57 | CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO |
| 58 | CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE |
| 59 | CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) |
| 60 | if(${var} MATCHES "/MD") |
| 61 | string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}") |
| 62 | endif() |
| 63 | endforeach() |
| 64 | |
| 65 | # NOTE: 4244 and 4267 are 64-bit to 32-bit conversion warnings, so normally |
| 66 | # it is not a good idea to disable them, but we do this to duplicate the |
| 67 | # behavior of GCC, which is less strict. |
| 68 | add_definitions(-wd4244 -wd4267 -wd4800 -wd4996) |
| 69 | endif() |
| 70 | |
Pierre Ossman | 69314c7 | 2011-03-08 12:18:13 +0000 | [diff] [blame^] | 71 | if(CMAKE_SIZEOF_VOID_P MATCHES 8) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 72 | message(STATUS "64-bit build") |
| 73 | else() |
| 74 | message(STATUS "32-bit build") |
| 75 | endif() |
| 76 | |
| 77 | # CMake doesn't properly support resource compilation with MinGW. Boo! |
| 78 | if(MINGW) |
| 79 | if(NOT DEFINED RC) |
| 80 | set(CMAKE_RC_COMPILER_INIT windres) |
| 81 | else() |
| 82 | set(CMAKE_RC_COMPILER_INIT ${RC}) |
| 83 | endif() |
| 84 | enable_language(RC) |
| 85 | message(STATUS "Resource compiler: ${CMAKE_RC_COMPILER}") |
| 86 | set(CMAKE_RC_COMPILE_OBJECT |
| 87 | "<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> -o <OBJECT> --output-format=coff <SOURCE>") |
| 88 | endif() |
| 89 | |
Pierre Ossman | a7769f2 | 2011-03-03 09:44:49 +0000 | [diff] [blame] | 90 | # Check for zlib |
| 91 | find_package(ZLIB) |
| 92 | option(USE_INCLUDED_ZLIB "Force use of the bundled zlib") |
| 93 | if(NOT ZLIB_FOUND) |
| 94 | message(STATUS "System zlib not found. Using included zlib") |
| 95 | set(USE_INCLUDED_ZLIB 1) |
| 96 | endif() |
| 97 | |
Pierre Ossman | 4c6bd4c | 2011-03-03 09:55:21 +0000 | [diff] [blame] | 98 | # Check for libjpeg |
| 99 | find_package(JPEG REQUIRED) |
| 100 | |
Pierre Ossman | 6fa0749 | 2011-03-04 11:35:24 +0000 | [diff] [blame] | 101 | # Warn if it doesn't seem to be the accelerated libjpeg that's found |
| 102 | include(CheckCSourceCompiles) |
| 103 | check_c_source_compiles("#include <stdio.h>\n#include <jpeglib.h>\nint main(int c, char** v) { return JCS_EXT_RGBX; }" FOUND_JPEG_TURBO) |
| 104 | if(NOT FOUND_JPEG_TURBO) |
| 105 | message(STATUS "WARNING: You are not using libjpeg-turbo. Performance will suffer.") |
| 106 | endif() |
| 107 | |
Adam Tkac | 125bd25 | 2011-01-19 14:20:34 +0000 | [diff] [blame] | 108 | # Check for GNUTLS library |
| 109 | find_package(GnuTLS) |
| 110 | if(GNUTLS_FOUND) |
| 111 | include_directories(${GNUTLS_INCLUDE_DIR}) |
| 112 | add_definitions("-DHAVE_GNUTLS") |
| 113 | add_definitions(${GNUTLS_DEFINITIONS}) |
| 114 | endif() |
| 115 | |
DRC | 6375809 | 2010-11-09 19:24:12 +0000 | [diff] [blame] | 116 | # Generate config.h |
| 117 | include(CheckIncludeFiles) |
| 118 | include(CheckFunctionExists) |
| 119 | set(CMAKE_EXTRA_INCLUDE_FILES winsock2.h) |
| 120 | set(CMAKE_REQUIRED_LIBRARIES ws2_32) |
| 121 | check_function_exists(inet_aton HAVE_INET_ATON) |
| 122 | check_function_exists(inet_ntop HAVE_INET_NTOP) |
| 123 | set(CMAKE_EXTRA_INCLUDE_FILES) |
| 124 | set(CMAKE_REQUIRED_LIBRARIES) |
| 125 | check_function_exists(snprintf HAVE_SNPRINTF) |
| 126 | check_function_exists(strcasecmp HAVE_STRCASECMP) |
| 127 | check_function_exists(strncasecmp HAVE_STRNCASECMP) |
| 128 | check_function_exists(vsnprintf HAVE_VSNPRINTF) |
| 129 | configure_file(config.h.cmake.in config.h) |
| 130 | add_definitions(-DHAVE_CONFIG_H) |
| 131 | include_directories(${CMAKE_BINARY_DIR}) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 132 | |
Pierre Ossman | 20dea46 | 2011-03-04 14:41:14 +0000 | [diff] [blame] | 133 | # Minimum version is Windows 2000 (5.0) |
Pierre Ossman | 69314c7 | 2011-03-08 12:18:13 +0000 | [diff] [blame^] | 134 | if(NOT CMAKE_SIZEOF_VOID_P MATCHES 8) |
Pierre Ossman | 20dea46 | 2011-03-04 14:41:14 +0000 | [diff] [blame] | 135 | add_definitions(-D_WIN32_IE=0x0500 -D_WIN32_WINNT=0x0500) |
| 136 | else() |
| 137 | # Win64 doesn't like us requesting a Windows version that didn't have |
| 138 | # 64-bit support. Request XP (5.1) instead. |
| 139 | add_definitions(-D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501) |
| 140 | endif() |
DRC | ed1ef85 | 2011-02-10 10:43:05 +0000 | [diff] [blame] | 141 | |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 142 | add_subdirectory(common) |
| 143 | add_subdirectory(win) |