Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

CMakeLists.txt 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. #
  2. # Setup
  3. #
  4. cmake_minimum_required(VERSION 2.6)
  5. include(CheckIncludeFiles)
  6. include(CheckFunctionExists)
  7. include(CheckTypeSize)
  8. include(CheckCSourceCompiles)
  9. include(CheckCXXSourceCompiles)
  10. project(tigervnc)
  11. set(VERSION 1.0.90)
  12. # The RC version must always be four comma-separated numbers
  13. set(RCVERSION 1,0,90,0)
  14. # Manual toggle until we can deprecate the old viewers
  15. option(BUILD_NEW_VNCVIEWER "Build the new FLTK based vncviewer instead of the old ones")
  16. # Compatibility variables for the migration from autotools
  17. add_definitions(-DPACKAGE_NAME="${CMAKE_PROJECT_NAME}")
  18. add_definitions(-DPACKAGE_VERSION="${VERSION}")
  19. add_definitions(-DLOCALEDIR="${CMAKE_INSTALL_PREFIX}/share/locale")
  20. # Try to encode today's date into the build id. We assume that MSVC
  21. # means we need to use a native Windows method, otherwise we assume
  22. # some kind of Unix system. The id will be empty if things fail.
  23. set(BUILD "")
  24. if(MSVC)
  25. execute_process(COMMAND "${CMAKE_SOURCE_DIR}/cmakescripts/getdate.bat"
  26. OUTPUT_VARIABLE BUILD)
  27. else()
  28. execute_process(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE BUILD)
  29. endif()
  30. if(NOT BUILD)
  31. set(BUILD "")
  32. else()
  33. string(REGEX REPLACE "\n" "" BUILD ${BUILD})
  34. endif()
  35. # Default to optimised builds instead of debug ones. Our code has no bugs ;)
  36. # (CMake makes it fairly easy to toggle this back to Debug if needed)
  37. if(NOT CMAKE_BUILD_TYPE)
  38. set(CMAKE_BUILD_TYPE Release)
  39. endif()
  40. message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
  41. # This only works if building from the command line. There is currently no way
  42. # to set a variable's value based on the build type when using the MSVC IDE.
  43. if(CMAKE_BUILD_TYPE STREQUAL "Debug")
  44. set(BUILD "${BUILD}d")
  45. endif()
  46. message(STATUS "VERSION = ${VERSION}, BUILD = ${BUILD}")
  47. if(NOT DEFINED BUILD_WINVNC)
  48. if(MSVC)
  49. set(BUILD_WINVNC 1)
  50. else()
  51. set(BUILD_WINVNC 0)
  52. endif()
  53. endif()
  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. # NOTE: 4244 and 4267 are 64-bit to 32-bit conversion warnings, so normally
  65. # it is not a good idea to disable them, but we do this to duplicate the
  66. # behavior of GCC, which is less strict.
  67. add_definitions(-wd4244 -wd4267 -wd4800 -wd4996)
  68. endif()
  69. # Minimum version is Windows 2000 (5.0)
  70. if(NOT CMAKE_SIZEOF_VOID_P MATCHES 8)
  71. add_definitions(-D_WIN32_IE=0x0500 -D_WIN32_WINNT=0x0500)
  72. else()
  73. # Win64 doesn't like us requesting a Windows version that didn't have
  74. # 64-bit support. Request XP (5.1) instead.
  75. add_definitions(-D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501)
  76. endif()
  77. if(CMAKE_SIZEOF_VOID_P MATCHES 8)
  78. message(STATUS "64-bit build")
  79. else()
  80. message(STATUS "32-bit build")
  81. endif()
  82. # CMake doesn't properly support resource compilation with MinGW. Boo!
  83. if(MINGW)
  84. if(NOT DEFINED RC)
  85. set(CMAKE_RC_COMPILER_INIT windres)
  86. else()
  87. set(CMAKE_RC_COMPILER_INIT ${RC})
  88. endif()
  89. enable_language(RC)
  90. message(STATUS "Resource compiler: ${CMAKE_RC_COMPILER}")
  91. set(CMAKE_RC_COMPILE_OBJECT
  92. "<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> -o <OBJECT> --output-format=coff <SOURCE>")
  93. endif()
  94. # X11 stuff. It's in a if() so that we can say REQUIRED
  95. if(UNIX)
  96. find_package(X11 REQUIRED)
  97. endif()
  98. # Check for zlib
  99. find_package(ZLIB)
  100. option(USE_INCLUDED_ZLIB "Force use of the bundled zlib")
  101. if(NOT ZLIB_FOUND)
  102. message(STATUS "System zlib not found. Using included zlib")
  103. set(USE_INCLUDED_ZLIB 1)
  104. endif()
  105. # Check for gettext
  106. option(ENABLE_NLS "Enable translation of program messages" ON)
  107. find_package(Gettext)
  108. set(LOCALE_DIR "${CMAKE_INSTALL_PREFIX}/share/locale")
  109. # Check for libjpeg
  110. find_package(JPEG REQUIRED)
  111. # Warn if it doesn't seem to be the accelerated libjpeg that's found
  112. check_c_source_compiles("#include <stdio.h>\n#include <jpeglib.h>\nint main(int c, char** v) { return JCS_EXT_RGBX; }" FOUND_JPEG_TURBO)
  113. if(NOT FOUND_JPEG_TURBO)
  114. message(STATUS "WARNING: You are not using libjpeg-turbo. Performance will suffer.")
  115. endif()
  116. # Check for FLTK
  117. if(BUILD_NEW_VNCVIEWER)
  118. set(FLTK_SKIP_FLUID TRUE)
  119. set(FLTK_SKIP_OPENGL TRUE)
  120. find_package(FLTK COMPONENTS REQUIRED)
  121. # FLTK STR #2599
  122. set(CMAKE_REQUIRED_INCLUDES ${FLTK_INCLUDE_DIR})
  123. set(CMAKE_REQUIRED_LIBRARIES ${FLTK_LIBRARIES})
  124. check_cxx_source_compiles("#include <FL/Fl.H>\nint main(int c, char** v) { Fl::event_compose_symbol(); return 0; }" HAVE_FLTK_DEAD_KEYS)
  125. set(CMAKE_REQUIRED_INCLUDES)
  126. set(CMAKE_REQUIRED_LIBRARIES)
  127. endif()
  128. # Check for GNUTLS library
  129. find_package(GnuTLS)
  130. if(GNUTLS_FOUND)
  131. include_directories(${GNUTLS_INCLUDE_DIR})
  132. add_definitions("-DHAVE_GNUTLS")
  133. add_definitions(${GNUTLS_DEFINITIONS})
  134. # Detect old version of GnuTLS
  135. set(CMAKE_EXTRA_INCLUDE_FILES gnutls/gnutls.h)
  136. set(CMAKE_REQUIRED_LIBRARIES gnutls)
  137. check_function_exists(gnutls_transport_set_global_errno HAVE_OLD_GNUTLS)
  138. check_function_exists(gnutls_x509_crt_print HAVE_GNUTLS_X509_CRT_PRINT)
  139. check_type_size(gnutls_x509_crt_t GNUTLS_X509_CRT_T)
  140. check_type_size(gnutls_datum_t GNUTLS_DATUM_T)
  141. check_type_size(gnutls_pk_algorithm_t GNUTLS_PK_ALGORITHM_T)
  142. check_type_size(gnutls_sign_algorithm_t GNUTLS_SIGN_ALGORITHM_T)
  143. set(CMAKE_EXTRA_INCLUDE_FILES)
  144. set(CMAKE_REQUIRED_LIBRARIES)
  145. endif()
  146. # Check for socket functions
  147. if(WIN32)
  148. set(CMAKE_EXTRA_INCLUDE_FILES winsock2.h ws2tcpip.h)
  149. set(CMAKE_REQUIRED_LIBRARIES ws2_32)
  150. else()
  151. set(CMAKE_EXTRA_INCLUDE_FILES sys/socket.h)
  152. endif()
  153. check_function_exists(inet_aton HAVE_INET_ATON)
  154. check_function_exists(inet_ntop HAVE_INET_NTOP)
  155. check_type_size(socklen_t SOCKLEN_T)
  156. set(CMAKE_EXTRA_INCLUDE_FILES)
  157. set(CMAKE_REQUIRED_LIBRARIES)
  158. # Check for the newer standard string functions
  159. check_function_exists(snprintf HAVE_SNPRINTF)
  160. check_function_exists(strcasecmp HAVE_STRCASECMP)
  161. check_function_exists(strncasecmp HAVE_STRNCASECMP)
  162. check_function_exists(vsnprintf HAVE_VSNPRINTF)
  163. # Generate config.h and make sure the source finds it
  164. configure_file(config.h.cmake.in config.h)
  165. add_definitions(-DHAVE_CONFIG_H)
  166. include_directories(${CMAKE_BINARY_DIR})
  167. add_subdirectory(common)
  168. if(WIN32)
  169. add_subdirectory(win)
  170. else()
  171. add_subdirectory(unix)
  172. endif()
  173. if(BUILD_NEW_VNCVIEWER)
  174. add_subdirectory(po)
  175. add_subdirectory(vncviewer)
  176. endif()