CMakeLists.txt 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. #=============================================================================
  2. # CMake - Cross Platform Makefile Generator
  3. # Copyright 2000-2012 Kitware, Inc., Insight Software Consortium
  4. #
  5. # Distributed under the OSI-approved BSD License (the "License");
  6. # see accompanying file Copyright.txt for details.
  7. #
  8. # This software is distributed WITHOUT ANY WARRANTY; without even the
  9. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. # See the License for more information.
  11. #=============================================================================
  12. cmake_minimum_required(VERSION 2.8.4 FATAL_ERROR)
  13. if(POLICY CMP0025)
  14. cmake_policy(SET CMP0025 NEW)
  15. endif()
  16. project(CMake)
  17. if(CMAKE_BOOTSTRAP)
  18. # Running from bootstrap script. Set local variable and remove from cache.
  19. set(CMAKE_BOOTSTRAP 1)
  20. unset(CMAKE_BOOTSTRAP CACHE)
  21. endif()
  22. set(CMake_BIN_DIR ${CMake_BINARY_DIR}/bin)
  23. if("${CMake_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
  24. # Disallow architecture-specific try_run. It may not run on the host.
  25. macro(TRY_RUN)
  26. if(CMAKE_TRY_COMPILE_OSX_ARCHITECTURES)
  27. message(FATAL_ERROR "TRY_RUN not allowed with CMAKE_TRY_COMPILE_OSX_ARCHITECTURES=[${CMAKE_TRY_COMPILE_OSX_ARCHITECTURES}]")
  28. else()
  29. _TRY_RUN(${ARGV})
  30. endif()
  31. endmacro()
  32. endif()
  33. #-----------------------------------------------------------------------
  34. # a macro to deal with system libraries, implemented as a macro
  35. # simply to improve readability of the main script
  36. #-----------------------------------------------------------------------
  37. macro(CMAKE_HANDLE_SYSTEM_LIBRARIES)
  38. # Options have dependencies.
  39. include(CMakeDependentOption)
  40. # Optionally use system xmlrpc. We no longer build or use it by default.
  41. option(CTEST_USE_XMLRPC "Enable xmlrpc submission method in CTest." OFF)
  42. mark_as_advanced(CTEST_USE_XMLRPC)
  43. # Allow the user to enable/disable all system utility library options by
  44. # defining CMAKE_USE_SYSTEM_LIBRARIES or CMAKE_USE_SYSTEM_LIBRARY_${util}.
  45. set(UTILITIES BZIP2 CURL EXPAT LIBARCHIVE ZLIB)
  46. foreach(util ${UTILITIES})
  47. if(NOT DEFINED CMAKE_USE_SYSTEM_LIBRARY_${util}
  48. AND DEFINED CMAKE_USE_SYSTEM_LIBRARIES)
  49. set(CMAKE_USE_SYSTEM_LIBRARY_${util} "${CMAKE_USE_SYSTEM_LIBRARIES}")
  50. endif()
  51. if(DEFINED CMAKE_USE_SYSTEM_LIBRARY_${util})
  52. if(CMAKE_USE_SYSTEM_LIBRARY_${util})
  53. set(CMAKE_USE_SYSTEM_LIBRARY_${util} ON)
  54. else()
  55. set(CMAKE_USE_SYSTEM_LIBRARY_${util} OFF)
  56. endif()
  57. if(CMAKE_BOOTSTRAP)
  58. unset(CMAKE_USE_SYSTEM_LIBRARY_${util} CACHE)
  59. endif()
  60. string(TOLOWER "${util}" lutil)
  61. set(CMAKE_USE_SYSTEM_${util} "${CMAKE_USE_SYSTEM_LIBRARY_${util}}"
  62. CACHE BOOL "Use system-installed ${lutil}" FORCE)
  63. else()
  64. set(CMAKE_USE_SYSTEM_LIBRARY_${util} OFF)
  65. endif()
  66. endforeach()
  67. if(CMAKE_BOOTSTRAP)
  68. unset(CMAKE_USE_SYSTEM_LIBRARIES CACHE)
  69. endif()
  70. # Optionally use system utility libraries.
  71. option(CMAKE_USE_SYSTEM_LIBARCHIVE "Use system-installed libarchive" "${CMAKE_USE_SYSTEM_LIBRARY_LIBARCHIVE}")
  72. CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_CURL "Use system-installed curl"
  73. "${CMAKE_USE_SYSTEM_LIBRARY_CURL}" "NOT CTEST_USE_XMLRPC" ON)
  74. CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_EXPAT "Use system-installed expat"
  75. "${CMAKE_USE_SYSTEM_LIBRARY_EXPAT}" "NOT CTEST_USE_XMLRPC" ON)
  76. CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_ZLIB "Use system-installed zlib"
  77. "${CMAKE_USE_SYSTEM_LIBRARY_ZLIB}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE;NOT CMAKE_USE_SYSTEM_CURL" ON)
  78. CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_BZIP2 "Use system-installed bzip2"
  79. "${CMAKE_USE_SYSTEM_LIBRARY_BZIP2}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE" ON)
  80. # Mention to the user what system libraries are being used.
  81. foreach(util ${UTILITIES})
  82. if(CMAKE_USE_SYSTEM_${util})
  83. message(STATUS "Using system-installed ${util}")
  84. endif()
  85. endforeach()
  86. # Inform utility library header wrappers whether to use system versions.
  87. configure_file(${CMake_SOURCE_DIR}/Utilities/cmThirdParty.h.in
  88. ${CMake_BINARY_DIR}/Utilities/cmThirdParty.h
  89. @ONLY)
  90. endmacro()
  91. set(CMAKE_BUILD_ON_VISUAL_STUDIO 0)
  92. if(WIN32 AND NOT UNIX AND NOT BORLAND AND NOT MINGW )
  93. set(CMAKE_BUILD_ON_VISUAL_STUDIO 1)
  94. endif()
  95. #-----------------------------------------------------------------------
  96. # a macro to determine the generator and ctest executable to use
  97. # for testing. Simply to improve readability of the main script.
  98. #-----------------------------------------------------------------------
  99. macro(CMAKE_SETUP_TESTING)
  100. if(BUILD_TESTING)
  101. set(CMAKE_TEST_GENERATOR "" CACHE STRING
  102. "Generator used when running tests")
  103. set(CMAKE_TEST_MAKEPROGRAM "" CACHE FILEPATH
  104. "Generator used when running tests")
  105. if(NOT CMAKE_TEST_GENERATOR)
  106. set(CMAKE_TEST_GENERATOR "${CMAKE_GENERATOR}")
  107. set(CMAKE_TEST_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}")
  108. else()
  109. set(CMAKE_TEST_DIFFERENT_GENERATOR TRUE)
  110. set(CMAKE_TEST_GENERATOR_TOOLSET "")
  111. endif()
  112. # Are we testing with the MSVC compiler?
  113. set(CMAKE_TEST_MSVC 0)
  114. if(MSVC AND NOT CMAKE_TEST_DIFFERENT_GENERATOR)
  115. set(CMAKE_TEST_MSVC 1)
  116. else()
  117. if("${CMAKE_TEST_GENERATOR}" MATCHES "NMake" OR
  118. "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio")
  119. set(CMAKE_TEST_MSVC 1)
  120. endif()
  121. endif()
  122. set(CMAKE_TEST_SYSTEM_LIBRARIES 0)
  123. foreach(util CURL EXPAT XMLRPC ZLIB)
  124. if(CMAKE_USE_SYSTEM_${util})
  125. set(CMAKE_TEST_SYSTEM_LIBRARIES 1)
  126. endif()
  127. endforeach()
  128. # This variable is set by cmake, however to
  129. # test cmake we want to make sure that
  130. # the ctest from this cmake is used for testing
  131. # and not the ctest from the cmake building and testing
  132. # cmake.
  133. set(CMAKE_CTEST_COMMAND "${CMake_BIN_DIR}/ctest")
  134. set(CMAKE_CMAKE_COMMAND "${CMake_BIN_DIR}/cmake")
  135. set(CMAKE_CPACK_COMMAND "${CMake_BIN_DIR}/cpack")
  136. endif()
  137. # configure some files for testing
  138. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Templates/CTestScript.cmake.in"
  139. "${CMAKE_CURRENT_BINARY_DIR}/CTestScript.cmake"
  140. @ONLY)
  141. configure_file(${CMake_SOURCE_DIR}/Tests/.NoDartCoverage
  142. ${CMake_BINARY_DIR}/Tests/.NoDartCoverage)
  143. configure_file(${CMake_SOURCE_DIR}/Tests/.NoDartCoverage
  144. ${CMake_BINARY_DIR}/Modules/.NoDartCoverage)
  145. configure_file(${CMake_SOURCE_DIR}/CTestCustom.cmake.in
  146. ${CMake_BINARY_DIR}/CTestCustom.cmake @ONLY)
  147. configure_file(${CMake_SOURCE_DIR}/CTestCustom.ctest.in
  148. ${CMake_BINARY_DIR}/CTestCustom.ctest @ONLY)
  149. if(BUILD_TESTING AND DART_ROOT)
  150. configure_file(${CMake_SOURCE_DIR}/CMakeLogo.gif
  151. ${CMake_BINARY_DIR}/Testing/HTML/TestingResults/Icons/Logo.gif COPYONLY)
  152. endif()
  153. mark_as_advanced(DART_ROOT)
  154. mark_as_advanced(CURL_TESTING)
  155. endmacro()
  156. # Provide a way for Visual Studio Express users to turn OFF the new FOLDER
  157. # organization feature. Default to ON for non-Express users. Express users must
  158. # explicitly turn off this option to build CMake in the Express IDE...
  159. #
  160. option(CMAKE_USE_FOLDERS "Enable folder grouping of projects in IDEs." ON)
  161. mark_as_advanced(CMAKE_USE_FOLDERS)
  162. #-----------------------------------------------------------------------
  163. # a macro that only sets the FOLDER target property if it's
  164. # "appropriate"
  165. #-----------------------------------------------------------------------
  166. macro(CMAKE_SET_TARGET_FOLDER tgt folder)
  167. if(CMAKE_USE_FOLDERS)
  168. set_property(GLOBAL PROPERTY USE_FOLDERS ON)
  169. if(MSVC AND TARGET ${tgt})
  170. set_property(TARGET "${tgt}" PROPERTY FOLDER "${folder}")
  171. endif()
  172. else()
  173. set_property(GLOBAL PROPERTY USE_FOLDERS OFF)
  174. endif()
  175. endmacro()
  176. #-----------------------------------------------------------------------
  177. # a macro to build the utilities used by CMake
  178. # Simply to improve readability of the main script.
  179. #-----------------------------------------------------------------------
  180. macro (CMAKE_BUILD_UTILITIES)
  181. #---------------------------------------------------------------------
  182. # Create the KWIML library for CMake.
  183. set(KWIML cmIML)
  184. set(KWIML_HEADER_ROOT ${CMake_BINARY_DIR}/Utilities)
  185. add_subdirectory(Utilities/KWIML)
  186. #---------------------------------------------------------------------
  187. # Create the kwsys library for CMake.
  188. set(KWSYS_NAMESPACE cmsys)
  189. set(KWSYS_USE_SystemTools 1)
  190. set(KWSYS_USE_Directory 1)
  191. set(KWSYS_USE_RegularExpression 1)
  192. set(KWSYS_USE_Base64 1)
  193. set(KWSYS_USE_MD5 1)
  194. set(KWSYS_USE_Process 1)
  195. set(KWSYS_USE_CommandLineArguments 1)
  196. set(KWSYS_HEADER_ROOT ${CMake_BINARY_DIR}/Source)
  197. set(KWSYS_INSTALL_DOC_DIR "${CMAKE_DOC_DIR}")
  198. add_subdirectory(Source/kwsys)
  199. set(kwsys_folder "Utilities/KWSys")
  200. CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE} "${kwsys_folder}")
  201. CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}_c "${kwsys_folder}")
  202. if(BUILD_TESTING)
  203. CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestDynload "${kwsys_folder}")
  204. CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestProcess "${kwsys_folder}")
  205. CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestsC "${kwsys_folder}")
  206. CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestsCxx "${kwsys_folder}")
  207. CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestSharedForward "${kwsys_folder}")
  208. endif()
  209. #---------------------------------------------------------------------
  210. # Setup third-party libraries.
  211. # Everything in the tree should be able to include files from the
  212. # Utilities directory.
  213. include_directories(
  214. ${CMake_BINARY_DIR}/Utilities
  215. ${CMake_SOURCE_DIR}/Utilities
  216. )
  217. # check for the use of system libraries versus builtin ones
  218. # (a macro defined in this file)
  219. CMAKE_HANDLE_SYSTEM_LIBRARIES()
  220. #---------------------------------------------------------------------
  221. # Build zlib library for Curl, CMake, and CTest.
  222. set(CMAKE_ZLIB_HEADER "cm_zlib.h")
  223. if(CMAKE_USE_SYSTEM_ZLIB)
  224. find_package(ZLIB)
  225. if(NOT ZLIB_FOUND)
  226. message(FATAL_ERROR
  227. "CMAKE_USE_SYSTEM_ZLIB is ON but a zlib is not found!")
  228. endif()
  229. set(CMAKE_ZLIB_INCLUDES ${ZLIB_INCLUDE_DIR})
  230. set(CMAKE_ZLIB_LIBRARIES ${ZLIB_LIBRARIES})
  231. else()
  232. set(CMAKE_ZLIB_INCLUDES ${CMake_SOURCE_DIR}/Utilities)
  233. set(CMAKE_ZLIB_LIBRARIES cmzlib)
  234. add_subdirectory(Utilities/cmzlib)
  235. CMAKE_SET_TARGET_FOLDER(cmzlib "Utilities/3rdParty")
  236. endif()
  237. #---------------------------------------------------------------------
  238. # Build Curl library for CTest.
  239. if(CMAKE_USE_SYSTEM_CURL)
  240. find_package(CURL)
  241. if(NOT CURL_FOUND)
  242. message(FATAL_ERROR
  243. "CMAKE_USE_SYSTEM_CURL is ON but a curl is not found!")
  244. endif()
  245. set(CMAKE_CURL_INCLUDES ${CURL_INCLUDE_DIRS})
  246. set(CMAKE_CURL_LIBRARIES ${CURL_LIBRARIES})
  247. else()
  248. set(CURL_SPECIAL_ZLIB_H ${CMAKE_ZLIB_HEADER})
  249. set(CURL_SPECIAL_LIBZ_INCLUDES ${CMAKE_ZLIB_INCLUDES})
  250. set(CURL_SPECIAL_LIBZ ${CMAKE_ZLIB_LIBRARIES})
  251. option(CMAKE_BUILD_CURL_SHARED "Should curl be built shared" FALSE)
  252. if(NOT CMAKE_BUILD_CURL_SHARED)
  253. add_definitions(-DCURL_STATICLIB)
  254. endif()
  255. set(CMAKE_CURL_INCLUDES)
  256. set(CMAKE_CURL_LIBRARIES cmcurl)
  257. if(CMAKE_TESTS_CDASH_SERVER)
  258. set(CMAKE_CURL_TEST_URL "${CMAKE_TESTS_CDASH_SERVER}/user.php")
  259. endif()
  260. add_subdirectory(Utilities/cmcurl)
  261. CMAKE_SET_TARGET_FOLDER(cmcurl "Utilities/3rdParty")
  262. CMAKE_SET_TARGET_FOLDER(LIBCURL "Utilities/3rdParty")
  263. endif()
  264. #---------------------------------------------------------------------
  265. # Build Compress library for CTest.
  266. set(CMAKE_COMPRESS_INCLUDES
  267. "${CMAKE_CURRENT_BINARY_DIR}/Utilities/cmcompress")
  268. set(CMAKE_COMPRESS_LIBRARIES "cmcompress")
  269. add_subdirectory(Utilities/cmcompress)
  270. CMAKE_SET_TARGET_FOLDER(cmcompress "Utilities/3rdParty")
  271. if(CMAKE_USE_SYSTEM_BZIP2)
  272. find_package(BZip2)
  273. else()
  274. set(BZIP2_INCLUDE_DIR
  275. "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmbzip2")
  276. set(BZIP2_LIBRARIES cmbzip2)
  277. add_subdirectory(Utilities/cmbzip2)
  278. CMAKE_SET_TARGET_FOLDER(cmbzip2 "Utilities/3rdParty")
  279. endif()
  280. #---------------------------------------------------------------------
  281. # Build or use system libarchive for CMake and CTest.
  282. if(CMAKE_USE_SYSTEM_LIBARCHIVE)
  283. find_package(LibArchive)
  284. if(NOT LibArchive_FOUND)
  285. message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBARCHIVE is ON but LibArchive is not found!")
  286. endif()
  287. set(CMAKE_TAR_INCLUDES ${LibArchive_INCLUDE_DIRS})
  288. set(CMAKE_TAR_LIBRARIES ${LibArchive_LIBRARIES})
  289. else()
  290. set(ZLIB_INCLUDE_DIR ${CMAKE_ZLIB_INCLUDES})
  291. set(ZLIB_LIBRARY ${CMAKE_ZLIB_LIBRARIES})
  292. add_definitions(-DLIBARCHIVE_STATIC)
  293. set(ENABLE_NETTLE OFF CACHE INTERNAL "Enable use of Nettle")
  294. set(ENABLE_OPENSSL ${CMAKE_USE_OPENSSL} CACHE INTERNAL "Enable use of OpenSSL")
  295. set(ENABLE_XATTR OFF CACHE INTERNAL "Enable extended attribute support")
  296. set(ENABLE_ACL OFF CACHE INTERNAL "Enable ACL support")
  297. set(ENABLE_ICONV OFF CACHE INTERNAL "Enable iconv support")
  298. add_subdirectory(Utilities/cmlibarchive)
  299. CMAKE_SET_TARGET_FOLDER(cmlibarchive "Utilities/3rdParty")
  300. set(CMAKE_TAR_LIBRARIES cmlibarchive ${BZIP2_LIBRARIES})
  301. endif()
  302. #---------------------------------------------------------------------
  303. # Build expat library for CMake and CTest.
  304. if(CMAKE_USE_SYSTEM_EXPAT)
  305. find_package(EXPAT)
  306. if(NOT EXPAT_FOUND)
  307. message(FATAL_ERROR
  308. "CMAKE_USE_SYSTEM_EXPAT is ON but a expat is not found!")
  309. endif()
  310. set(CMAKE_EXPAT_INCLUDES ${EXPAT_INCLUDE_DIRS})
  311. set(CMAKE_EXPAT_LIBRARIES ${EXPAT_LIBRARIES})
  312. else()
  313. set(CMAKE_EXPAT_INCLUDES)
  314. set(CMAKE_EXPAT_LIBRARIES cmexpat)
  315. add_subdirectory(Utilities/cmexpat)
  316. CMAKE_SET_TARGET_FOLDER(cmexpat "Utilities/3rdParty")
  317. endif()
  318. #---------------------------------------------------------------------
  319. # Build XMLRPC library for CMake and CTest.
  320. if(CTEST_USE_XMLRPC)
  321. find_package(XMLRPC QUIET REQUIRED libwww-client)
  322. if(NOT XMLRPC_FOUND)
  323. message(FATAL_ERROR
  324. "CTEST_USE_XMLRPC is ON but xmlrpc is not found!")
  325. endif()
  326. set(CMAKE_XMLRPC_INCLUDES ${XMLRPC_INCLUDE_DIRS})
  327. set(CMAKE_XMLRPC_LIBRARIES ${XMLRPC_LIBRARIES})
  328. endif()
  329. #---------------------------------------------------------------------
  330. # Use curses?
  331. if (UNIX)
  332. # there is a bug in the Syllable libraries which makes linking ccmake fail, Alex
  333. if(NOT "${CMAKE_SYSTEM_NAME}" MATCHES syllable)
  334. set(CURSES_NEED_NCURSES TRUE)
  335. find_package(Curses QUIET)
  336. if (CURSES_LIBRARY)
  337. option(BUILD_CursesDialog "Build the CMake Curses Dialog ccmake" ON)
  338. else ()
  339. message("Curses libraries were not found. Curses GUI for CMake will not be built.")
  340. set(BUILD_CursesDialog 0)
  341. endif ()
  342. else()
  343. set(BUILD_CursesDialog 0)
  344. endif()
  345. else ()
  346. set(BUILD_CursesDialog 0)
  347. endif ()
  348. if(BUILD_CursesDialog)
  349. add_subdirectory(Source/CursesDialog/form)
  350. endif()
  351. endmacro ()
  352. #-----------------------------------------------------------------------
  353. if(CMAKE_CXX_PLATFORM_ID MATCHES "OpenBSD")
  354. execute_process(COMMAND ${CMAKE_CXX_COMPILER}
  355. ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
  356. OUTPUT_VARIABLE _GXX_VERSION
  357. )
  358. string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
  359. _GXX_VERSION_SHORT ${_GXX_VERSION})
  360. if(_GXX_VERSION_SHORT EQUAL 33)
  361. message(FATAL_ERROR
  362. "GXX 3.3 on OpenBSD is known to cause CPack to Crash.\n"
  363. "Please use GXX 4.2 or greater to build CMake on OpenBSD\n"
  364. "${CMAKE_CXX_COMPILER} version is: ${_GXX_VERSION}")
  365. endif()
  366. endif()
  367. #-----------------------------------------------------------------------
  368. # The main section of the CMakeLists file
  369. #
  370. #-----------------------------------------------------------------------
  371. # Compute CMake_VERSION, etc.
  372. include(Source/CMakeVersionCompute.cmake)
  373. # Include the standard Dart testing module
  374. enable_testing()
  375. include (${CMAKE_ROOT}/Modules/Dart.cmake)
  376. # Set up test-time configuration.
  377. set_directory_properties(PROPERTIES
  378. TEST_INCLUDE_FILE "${CMake_BINARY_DIR}/Tests/EnforceConfig.cmake")
  379. # where to write the resulting executables and libraries
  380. set(BUILD_SHARED_LIBS OFF)
  381. set(EXECUTABLE_OUTPUT_PATH "" CACHE INTERNAL "No configurable exe dir.")
  382. set(LIBRARY_OUTPUT_PATH "" CACHE INTERNAL
  383. "Where to put the libraries for CMake")
  384. # The CMake executables usually do not need any rpath to run in the build or
  385. # install tree.
  386. set(CMAKE_SKIP_RPATH ON CACHE INTERNAL "CMake does not need RPATHs.")
  387. # Load install destinations.
  388. include(Source/CMakeInstallDestinations.cmake)
  389. if(BUILD_TESTING)
  390. include(${CMake_SOURCE_DIR}/Tests/CMakeInstall.cmake)
  391. endif()
  392. # include special compile flags for some compilers
  393. include(CompileFlags.cmake)
  394. # no clue why we are testing for this here
  395. include(CheckSymbolExists)
  396. CHECK_SYMBOL_EXISTS(unsetenv "stdlib.h" HAVE_UNSETENV)
  397. CHECK_SYMBOL_EXISTS(environ "stdlib.h" HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE)
  398. # CMAKE_TESTS_CDASH_SERVER: CDash server used by CMake/Tests.
  399. #
  400. # If not defined or "", this variable defaults to the server at
  401. # http://www.cdash.org/CDash.
  402. #
  403. # If set explicitly to "NOTFOUND", curl tests and ctest tests that use
  404. # the network are skipped.
  405. #
  406. # If set to something starting with "http://localhost/", the CDash is
  407. # expected to be an instance of CDash used for CDash testing, pointing
  408. # to a cdash4simpletest database. In these cases, the CDash dashboards
  409. # should be run first.
  410. #
  411. if("x${CMAKE_TESTS_CDASH_SERVER}" STREQUAL "x")
  412. set(CMAKE_TESTS_CDASH_SERVER "http://www.cdash.org/CDash")
  413. endif()
  414. # build the utilities (a macro defined in this file)
  415. CMAKE_BUILD_UTILITIES()
  416. # On NetBSD ncurses is required, since curses doesn't have the wsyncup()
  417. # function. ncurses is installed via pkgsrc, so the library is in /usr/pkg/lib,
  418. # which isn't in the default linker search path. So without RPATH ccmake
  419. # doesn't run and the build doesn't succeed since ccmake is executed for
  420. # generating the documentation.
  421. if(BUILD_CursesDialog)
  422. get_filename_component(_CURSES_DIR "${CURSES_LIBRARY}" PATH)
  423. set(CURSES_NEED_RPATH FALSE)
  424. if(NOT "${_CURSES_DIR}" STREQUAL "/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/lib64" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib64")
  425. set(CURSES_NEED_RPATH TRUE)
  426. endif()
  427. endif()
  428. if(BUILD_QtDialog)
  429. if(APPLE)
  430. set(CMAKE_BUNDLE_VERSION
  431. "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}")
  432. set(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}")
  433. # make sure CMAKE_INSTALL_PREFIX ends in /
  434. string(LENGTH "${CMAKE_INSTALL_PREFIX}" LEN)
  435. math(EXPR LEN "${LEN} -1" )
  436. string(SUBSTRING "${CMAKE_INSTALL_PREFIX}" ${LEN} 1 ENDCH)
  437. if(NOT "${ENDCH}" STREQUAL "/")
  438. set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/")
  439. endif()
  440. set(CMAKE_INSTALL_PREFIX
  441. "${CMAKE_INSTALL_PREFIX}CMake.app/Contents")
  442. endif()
  443. set(QT_NEED_RPATH FALSE)
  444. if(NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib64" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib64")
  445. set(QT_NEED_RPATH TRUE)
  446. endif()
  447. endif()
  448. # The same might be true on other systems for other libraries.
  449. # Then only enable RPATH if we have are building at least with cmake 2.4,
  450. # since this one has much better RPATH features than cmake 2.2.
  451. # The executables are then built with the RPATH for the libraries outside
  452. # the build tree, which is both the build and the install RPATH.
  453. if (UNIX)
  454. if( CMAKE_USE_SYSTEM_CURL OR CMAKE_USE_SYSTEM_ZLIB
  455. OR CMAKE_USE_SYSTEM_EXPAT OR CTEST_USE_XMLRPC OR CURSES_NEED_RPATH OR QT_NEED_RPATH)
  456. set(CMAKE_SKIP_RPATH OFF CACHE INTERNAL "CMake built with RPATH.")
  457. set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  458. set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
  459. endif()
  460. endif ()
  461. # add the uninstall support
  462. configure_file(
  463. "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
  464. "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  465. @ONLY)
  466. add_custom_target(uninstall
  467. "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
  468. include (CMakeCPack.cmake)
  469. # setup some Testing support (a macro defined in this file)
  470. CMAKE_SETUP_TESTING()
  471. configure_file(
  472. "${CMAKE_CURRENT_SOURCE_DIR}/DartLocal.conf.in"
  473. "${CMAKE_CURRENT_BINARY_DIR}/DartLocal.conf"
  474. COPYONLY)
  475. if(NOT CMake_VERSION_IS_RELEASE)
  476. if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND
  477. NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 4.2)
  478. set(C_FLAGS_LIST -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts
  479. -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security
  480. -Wmissing-format-attribute -fno-common -Wundef
  481. )
  482. set(CXX_FLAGS_LIST -Wnon-virtual-dtor -Wcast-align -Wchar-subscripts -Wall -W
  483. -Wshadow -Wpointer-arith -Wformat-security -Wundef
  484. )
  485. foreach(FLAG_LANG C CXX)
  486. foreach(FLAG ${${FLAG_LANG}_FLAGS_LIST})
  487. if(NOT " ${CMAKE_${FLAG_LANG}_FLAGS} " MATCHES " ${FLAG} ")
  488. set(CMAKE_${FLAG_LANG}_FLAGS "${CMAKE_${FLAG_LANG}_FLAGS} ${FLAG}")
  489. endif()
  490. endforeach()
  491. endforeach()
  492. unset(C_FLAGS_LIST)
  493. unset(CXX_FLAGS_LIST)
  494. endif()
  495. endif()
  496. # build the remaining subdirectories
  497. add_subdirectory(Source)
  498. add_subdirectory(Utilities)
  499. add_subdirectory(Tests)
  500. if(BUILD_TESTING)
  501. CMAKE_SET_TARGET_FOLDER(CMakeLibTests "Tests")
  502. endif()
  503. CMAKE_SET_TARGET_FOLDER(cmw9xcom "Utilities/Win9xCompat")
  504. if(TARGET documentation)
  505. CMAKE_SET_TARGET_FOLDER(documentation "Documentation")
  506. endif()
  507. # add a test
  508. add_test(SystemInformationNew "${CMAKE_CMAKE_COMMAND}"
  509. --system-information -G "${CMAKE_TEST_GENERATOR}" )
  510. # Install license file as it requires.
  511. install(FILES Copyright.txt DESTINATION ${CMAKE_DOC_DIR})
  512. # Install script directories.
  513. install(
  514. DIRECTORY Help Modules Templates
  515. DESTINATION ${CMAKE_DATA_DIR}
  516. FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
  517. DIRECTORY_PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE
  518. GROUP_READ GROUP_EXECUTE
  519. WORLD_READ WORLD_EXECUTE
  520. PATTERN "*.sh*" PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE
  521. GROUP_READ GROUP_EXECUTE
  522. WORLD_READ WORLD_EXECUTE
  523. )
  524. # Install auxiliary files integrating with other tools.
  525. add_subdirectory(Auxiliary)
  526. #-----------------------------------------------------------------------
  527. # End of the main section of the CMakeLists file
  528. #-----------------------------------------------------------------------
  529. # As a special case when building CMake itself, CMake 2.8.0 and below
  530. # look up EXECUTABLE_OUTPUT_PATH in the top-level CMakeLists.txt file
  531. # to compute the location of the "cmake" executable. We set it here
  532. # so that those CMake versions can find it. We wait until after all
  533. # the add_subdirectory() calls to avoid affecting the subdirectories.
  534. set(EXECUTABLE_OUTPUT_PATH ${CMake_BIN_DIR})