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 | |
| 13 | if(MINGW OR CYGWIN) |
| 14 | execute_process(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE BUILD) |
| 15 | string(REGEX REPLACE "\n" "" BUILD ${BUILD}) |
| 16 | elseif(WIN32) |
| 17 | execute_process(COMMAND "${CMAKE_SOURCE_DIR}/cmakescripts/getdate.bat" |
| 18 | OUTPUT_VARIABLE BUILD) |
| 19 | string(REGEX REPLACE "\n" "" BUILD ${BUILD}) |
| 20 | else() |
| 21 | message(FATAL_ERROR "Platform not supported by this build system. Use autotools instead.") |
| 22 | endif() |
| 23 | |
| 24 | if(NOT CMAKE_BUILD_TYPE) |
| 25 | set(CMAKE_BUILD_TYPE Release) |
| 26 | endif() |
| 27 | |
| 28 | message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}") |
| 29 | |
| 30 | # This only works if building from the command line. There is currently no way |
| 31 | # to set a variable's value based on the build type when using the MSVC IDE. |
| 32 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") |
| 33 | set(BUILD "${BUILD}d") |
| 34 | endif() |
| 35 | |
| 36 | message(STATUS "VERSION = ${VERSION}, BUILD = ${BUILD}") |
| 37 | |
| 38 | if(NOT DEFINED BUILD_WINVNC) |
| 39 | if(MSVC) |
| 40 | set(BUILD_WINVNC 1) |
| 41 | else() |
| 42 | set(BUILD_WINVNC 0) |
| 43 | endif() |
| 44 | endif() |
| 45 | |
| 46 | if(MSVC) |
| 47 | # Use the static C library for all build types |
| 48 | foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE |
| 49 | CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO |
| 50 | CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE |
| 51 | CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) |
| 52 | if(${var} MATCHES "/MD") |
| 53 | string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}") |
| 54 | endif() |
| 55 | endforeach() |
| 56 | |
| 57 | # NOTE: 4244 and 4267 are 64-bit to 32-bit conversion warnings, so normally |
| 58 | # it is not a good idea to disable them, but we do this to duplicate the |
| 59 | # behavior of GCC, which is less strict. |
| 60 | add_definitions(-wd4244 -wd4267 -wd4800 -wd4996) |
| 61 | endif() |
| 62 | |
Pierre Ossman | 0bfc1cd | 2011-03-03 12:35:04 +0000 | [diff] [blame^] | 63 | if(CMAKE_CL_64) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 64 | message(STATUS "64-bit build") |
| 65 | else() |
| 66 | message(STATUS "32-bit build") |
| 67 | endif() |
| 68 | |
| 69 | # CMake doesn't properly support resource compilation with MinGW. Boo! |
| 70 | if(MINGW) |
| 71 | if(NOT DEFINED RC) |
| 72 | set(CMAKE_RC_COMPILER_INIT windres) |
| 73 | else() |
| 74 | set(CMAKE_RC_COMPILER_INIT ${RC}) |
| 75 | endif() |
| 76 | enable_language(RC) |
| 77 | message(STATUS "Resource compiler: ${CMAKE_RC_COMPILER}") |
| 78 | set(CMAKE_RC_COMPILE_OBJECT |
| 79 | "<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> -o <OBJECT> --output-format=coff <SOURCE>") |
| 80 | endif() |
| 81 | |
Pierre Ossman | a7769f2 | 2011-03-03 09:44:49 +0000 | [diff] [blame] | 82 | # Check for zlib |
| 83 | find_package(ZLIB) |
| 84 | option(USE_INCLUDED_ZLIB "Force use of the bundled zlib") |
| 85 | if(NOT ZLIB_FOUND) |
| 86 | message(STATUS "System zlib not found. Using included zlib") |
| 87 | set(USE_INCLUDED_ZLIB 1) |
| 88 | endif() |
| 89 | |
Pierre Ossman | 4c6bd4c | 2011-03-03 09:55:21 +0000 | [diff] [blame] | 90 | # Check for libjpeg |
| 91 | find_package(JPEG REQUIRED) |
| 92 | |
Adam Tkac | 125bd25 | 2011-01-19 14:20:34 +0000 | [diff] [blame] | 93 | # Check for GNUTLS library |
| 94 | find_package(GnuTLS) |
| 95 | if(GNUTLS_FOUND) |
| 96 | include_directories(${GNUTLS_INCLUDE_DIR}) |
| 97 | add_definitions("-DHAVE_GNUTLS") |
| 98 | add_definitions(${GNUTLS_DEFINITIONS}) |
| 99 | endif() |
| 100 | |
DRC | 6375809 | 2010-11-09 19:24:12 +0000 | [diff] [blame] | 101 | # Generate config.h |
| 102 | include(CheckIncludeFiles) |
| 103 | include(CheckFunctionExists) |
| 104 | set(CMAKE_EXTRA_INCLUDE_FILES winsock2.h) |
| 105 | set(CMAKE_REQUIRED_LIBRARIES ws2_32) |
| 106 | check_function_exists(inet_aton HAVE_INET_ATON) |
| 107 | check_function_exists(inet_ntop HAVE_INET_NTOP) |
| 108 | set(CMAKE_EXTRA_INCLUDE_FILES) |
| 109 | set(CMAKE_REQUIRED_LIBRARIES) |
| 110 | check_function_exists(snprintf HAVE_SNPRINTF) |
| 111 | check_function_exists(strcasecmp HAVE_STRCASECMP) |
| 112 | check_function_exists(strncasecmp HAVE_STRNCASECMP) |
| 113 | check_function_exists(vsnprintf HAVE_VSNPRINTF) |
| 114 | configure_file(config.h.cmake.in config.h) |
| 115 | add_definitions(-DHAVE_CONFIG_H) |
| 116 | include_directories(${CMAKE_BINARY_DIR}) |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 117 | |
DRC | ed1ef85 | 2011-02-10 10:43:05 +0000 | [diff] [blame] | 118 | add_definitions(-D_WIN32_IE=0x0500 -D_WIN32_WINNT=0x0500) |
| 119 | |
DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 120 | add_subdirectory(common) |
| 121 | add_subdirectory(win) |