blob: 9c692b9134b9fcbadcc73adcd48d5839955e4420 [file] [log] [blame]
DRC180c0162010-10-27 07:20:27 +00001#
2# Setup
3#
4
5cmake_minimum_required(VERSION 2.6)
6
7project(TigerVNC)
8set(VERSION 1.0.90)
9
10# The RC version must always be four comma-separated numbers
11set(RCVERSION 1,0,90,0)
12
13if(MINGW OR CYGWIN)
14 execute_process(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE BUILD)
15 string(REGEX REPLACE "\n" "" BUILD ${BUILD})
16elseif(WIN32)
17 execute_process(COMMAND "${CMAKE_SOURCE_DIR}/cmakescripts/getdate.bat"
18 OUTPUT_VARIABLE BUILD)
19 string(REGEX REPLACE "\n" "" BUILD ${BUILD})
20else()
21 message(FATAL_ERROR "Platform not supported by this build system. Use autotools instead.")
22endif()
23
24if(NOT CMAKE_BUILD_TYPE)
25 set(CMAKE_BUILD_TYPE Release)
26endif()
27
28message(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.
32if(CMAKE_BUILD_TYPE STREQUAL "Debug")
33 set(BUILD "${BUILD}d")
34endif()
35
36message(STATUS "VERSION = ${VERSION}, BUILD = ${BUILD}")
37
38if(NOT DEFINED BUILD_WINVNC)
39 if(MSVC)
40 set(BUILD_WINVNC 1)
41 else()
42 set(BUILD_WINVNC 0)
43 endif()
44endif()
45
46if(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)
61endif()
62
Pierre Ossman0bfc1cd2011-03-03 12:35:04 +000063if(CMAKE_CL_64)
DRC180c0162010-10-27 07:20:27 +000064 message(STATUS "64-bit build")
65else()
66 message(STATUS "32-bit build")
67endif()
68
69# CMake doesn't properly support resource compilation with MinGW. Boo!
70if(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>")
80endif()
81
Pierre Ossmana7769f22011-03-03 09:44:49 +000082# Check for zlib
83find_package(ZLIB)
84option(USE_INCLUDED_ZLIB "Force use of the bundled zlib")
85if(NOT ZLIB_FOUND)
86 message(STATUS "System zlib not found. Using included zlib")
87 set(USE_INCLUDED_ZLIB 1)
88endif()
89
Pierre Ossman4c6bd4c2011-03-03 09:55:21 +000090# Check for libjpeg
91find_package(JPEG REQUIRED)
92
Adam Tkac125bd252011-01-19 14:20:34 +000093# Check for GNUTLS library
94find_package(GnuTLS)
95if(GNUTLS_FOUND)
96 include_directories(${GNUTLS_INCLUDE_DIR})
97 add_definitions("-DHAVE_GNUTLS")
98 add_definitions(${GNUTLS_DEFINITIONS})
99endif()
100
DRC63758092010-11-09 19:24:12 +0000101# Generate config.h
102include(CheckIncludeFiles)
103include(CheckFunctionExists)
104set(CMAKE_EXTRA_INCLUDE_FILES winsock2.h)
105set(CMAKE_REQUIRED_LIBRARIES ws2_32)
106check_function_exists(inet_aton HAVE_INET_ATON)
107check_function_exists(inet_ntop HAVE_INET_NTOP)
108set(CMAKE_EXTRA_INCLUDE_FILES)
109set(CMAKE_REQUIRED_LIBRARIES)
110check_function_exists(snprintf HAVE_SNPRINTF)
111check_function_exists(strcasecmp HAVE_STRCASECMP)
112check_function_exists(strncasecmp HAVE_STRNCASECMP)
113check_function_exists(vsnprintf HAVE_VSNPRINTF)
114configure_file(config.h.cmake.in config.h)
115add_definitions(-DHAVE_CONFIG_H)
116include_directories(${CMAKE_BINARY_DIR})
DRC180c0162010-10-27 07:20:27 +0000117
DRCed1ef852011-02-10 10:43:05 +0000118add_definitions(-D_WIN32_IE=0x0500 -D_WIN32_WINNT=0x0500)
119
DRC180c0162010-10-27 07:20:27 +0000120add_subdirectory(common)
121add_subdirectory(win)