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 | |
| 63 | # Detect whether compiler is 64-bit |
| 64 | if((MSVC AND CMAKE_CL_64) OR (CMAKE_SIZEOF_VOID_P MATCHES 8)) |
| 65 | set(64BIT 1) |
| 66 | set(WIN64 1) |
| 67 | endif() |
| 68 | |
| 69 | if(64BIT) |
| 70 | message(STATUS "64-bit build") |
| 71 | else() |
| 72 | message(STATUS "32-bit build") |
| 73 | endif() |
| 74 | |
| 75 | # CMake doesn't properly support resource compilation with MinGW. Boo! |
| 76 | if(MINGW) |
| 77 | if(NOT DEFINED RC) |
| 78 | set(CMAKE_RC_COMPILER_INIT windres) |
| 79 | else() |
| 80 | set(CMAKE_RC_COMPILER_INIT ${RC}) |
| 81 | endif() |
| 82 | enable_language(RC) |
| 83 | message(STATUS "Resource compiler: ${CMAKE_RC_COMPILER}") |
| 84 | set(CMAKE_RC_COMPILE_OBJECT |
| 85 | "<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> -o <OBJECT> --output-format=coff <SOURCE>") |
| 86 | endif() |
| 87 | |
| 88 | |
| 89 | add_subdirectory(common) |
| 90 | add_subdirectory(win) |
| 91 | |
| 92 | |
| 93 | # |
| 94 | # Installer |
| 95 | # |
| 96 | |
| 97 | set(INST_NAME ${CMAKE_PROJECT_NAME}) |
| 98 | |
| 99 | if(64BIT) |
| 100 | set(INST_NAME ${INST_NAME}64) |
| 101 | set(INST_DEFS -DWIN64) |
| 102 | endif() |
| 103 | |
| 104 | if(MSVC_IDE) |
| 105 | set(INSTALLERDIR "$(OutDir)") |
| 106 | set(BUILDDIRDEF "-DBUILD_DIR=${INSTALLERDIR}\\") |
| 107 | else() |
| 108 | set(INSTALLERDIR .) |
| 109 | set(BUILDDIRDEF "-DBUILD_DIR=") |
| 110 | endif() |
| 111 | |
| 112 | set(INST_DEPS vncviewer) |
| 113 | |
| 114 | if(BUILD_WINVNC) |
| 115 | set(INST_DEFS ${INST_DEFS} -DBUILD_WINVNC) |
| 116 | set(INST_DEPS ${INST_DEPS} winvnc4 wm_hooks vncconfig) |
| 117 | endif() |
| 118 | |
| 119 | configure_file(win/tigervnc.iss.in tigervnc.iss) |
| 120 | |
| 121 | add_custom_target(installer |
| 122 | iscc -o${INSTALLERDIR} ${INST_DEFS} ${BUILDDIRDEF} -F${INST_NAME} tigervnc.iss |
| 123 | DEPENDS ${INST_DEPS} |
| 124 | SOURCES tigervnc.iss) |
| 125 | |
| 126 | install(FILES ${CMAKE_SOURCE_DIR}/win/README_BINARY.txt |
| 127 | ${CMAKE_SOURCE_DIR}/LICENCE.txt DESTINATION .) |