CMakeLists.txt 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. PROJECT(CMake)
  2. CMAKE_MINIMUM_REQUIRED(VERSION 2.2) # Need 2.4 for SUBDIRS
  3. MARK_AS_ADVANCED(CMAKE_BACKWARDS_COMPATIBILITY)
  4. #-----------------------------------------------------------------------
  5. # a macro to deal with system libraries, implemented as a macro
  6. # simply to improve readability of the main script
  7. #-----------------------------------------------------------------------
  8. MACRO(CMAKE_HANDLE_SYSTEM_LIBRARIES)
  9. # Third party libraries must be something that can be found.
  10. IF(EXISTS ${CMAKE_ROOT}/Modules/FindXMLRPC.cmake)
  11. SET(CMAKE_ALLOW_SYSTEM_LIBRARIES 1)
  12. ELSE(EXISTS ${CMAKE_ROOT}/Modules/FindXMLRPC.cmake)
  13. SET(CMAKE_ALLOW_SYSTEM_LIBRARIES 0)
  14. ENDIF(EXISTS ${CMAKE_ROOT}/Modules/FindXMLRPC.cmake)
  15. IF(CMAKE_ALLOW_SYSTEM_LIBRARIES)
  16. # Options have dependencies.
  17. INCLUDE(CMakeDependentOption)
  18. # Allow the user to enable/disable all system utility library options
  19. # by setting CMAKE_USE_SYSTEM_LIBRARIES on the command line.
  20. IF(DEFINED CMAKE_USE_SYSTEM_LIBRARIES)
  21. SET(CMAKE_USE_SYSTEM_LIBRARIES_USER 1)
  22. ENDIF(DEFINED CMAKE_USE_SYSTEM_LIBRARIES)
  23. IF(CMAKE_USE_SYSTEM_LIBRARIES)
  24. SET(CMAKE_USE_SYSTEM_LIBRARIES ON)
  25. ELSE(CMAKE_USE_SYSTEM_LIBRARIES)
  26. SET(CMAKE_USE_SYSTEM_LIBRARIES OFF)
  27. ENDIF(CMAKE_USE_SYSTEM_LIBRARIES)
  28. IF(CMAKE_USE_SYSTEM_LIBRARIES_USER)
  29. SET(CMAKE_USE_SYSTEM_CURL "${CMAKE_USE_SYSTEM_LIBRARIES}"
  30. CACHE BOOL "Use system-installed curl" FORCE)
  31. SET(CMAKE_USE_SYSTEM_EXPAT "${CMAKE_USE_SYSTEM_LIBRARIES}"
  32. CACHE BOOL "Use system-installed expat" FORCE)
  33. SET(CMAKE_USE_SYSTEM_XMLRPC "${CMAKE_USE_SYSTEM_LIBRARIES}"
  34. CACHE BOOL "Use system-installed xmlrpc" FORCE)
  35. SET(CMAKE_USE_SYSTEM_ZLIB "${CMAKE_USE_SYSTEM_LIBRARIES}"
  36. CACHE BOOL "Use system-installed zlib" FORCE)
  37. ENDIF(CMAKE_USE_SYSTEM_LIBRARIES_USER)
  38. # Optionally use system utility libraries.
  39. OPTION(CMAKE_USE_SYSTEM_CURL "Use system-installed curl"
  40. ${CMAKE_USE_SYSTEM_LIBRARIES})
  41. OPTION(CMAKE_USE_SYSTEM_XMLRPC "Use system-installed xmlrpc"
  42. ${CMAKE_USE_SYSTEM_LIBRARIES})
  43. CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_EXPAT "Use system-installed expat"
  44. ${CMAKE_USE_SYSTEM_LIBRARIES} "NOT CMAKE_USE_SYSTEM_XMLRPC" ON)
  45. CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_ZLIB "Use system-installed zlib"
  46. ${CMAKE_USE_SYSTEM_LIBRARIES} "NOT CMAKE_USE_SYSTEM_CURL" ON)
  47. # There is currently no option for system tar because the upstream
  48. # libtar does not have our modifications to allow reentrant
  49. # object-oriented use of the library.
  50. # OPTION(CMAKE_USE_SYSTEM_TAR "Use system-installed tar" OFF)
  51. ELSE(CMAKE_ALLOW_SYSTEM_LIBRARIES)
  52. SET(CMAKE_USE_SYSTEM_CURL 0)
  53. SET(CMAKE_USE_SYSTEM_EXPAT 0)
  54. SET(CMAKE_USE_SYSTEM_XMLRPC 0)
  55. SET(CMAKE_USE_SYSTEM_ZLIB 0)
  56. ENDIF(CMAKE_ALLOW_SYSTEM_LIBRARIES)
  57. # Mention to the user what system libraries are being used.
  58. FOREACH(util CURL EXPAT XMLRPC ZLIB)
  59. IF(CMAKE_USE_SYSTEM_${util})
  60. MESSAGE(STATUS "Using system-installed ${util}")
  61. ENDIF(CMAKE_USE_SYSTEM_${util})
  62. ENDFOREACH(util)
  63. # Inform utility library header wrappers whether to use system versions.
  64. CONFIGURE_FILE(${CMake_SOURCE_DIR}/Utilities/cmThirdParty.h.in
  65. ${CMake_BINARY_DIR}/Utilities/cmThirdParty.h
  66. @ONLY)
  67. ENDMACRO(CMAKE_HANDLE_SYSTEM_LIBRARIES)
  68. #-----------------------------------------------------------------------
  69. # a macro to check for MFC and setup to build the MFC Dialog
  70. # simply to improve readability of the main script
  71. #-----------------------------------------------------------------------
  72. MACRO(CMAKE_TEST_FOR_MFC)
  73. SET(CMAKE_BUILD_ON_VISUAL_STUDIO 0)
  74. IF(WIN32 AND NOT UNIX AND NOT BORLAND AND NOT MINGW )
  75. SET(CMAKE_BUILD_ON_VISUAL_STUDIO 1)
  76. ENDIF(WIN32 AND NOT UNIX AND NOT BORLAND AND NOT MINGW )
  77. IF(CMAKE_BUILD_ON_VISUAL_STUDIO)
  78. IF("CMake_HAVE_MFC" MATCHES "^CMake_HAVE_MFC$")
  79. SET(CHECK_INCLUDE_FILE_VAR "afxwin.h")
  80. CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in
  81. ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx)
  82. MESSAGE(STATUS "Looking for MFC")
  83. TRY_COMPILE(CMake_HAVE_MFC
  84. ${CMAKE_BINARY_DIR}
  85. ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx
  86. CMAKE_FLAGS
  87. -DCMAKE_MFC_FLAG:STRING=2
  88. -DCOMPILE_DEFINITIONS:STRING=-D_AFXDLL
  89. OUTPUT_VARIABLE OUTPUT)
  90. IF(CMake_HAVE_MFC)
  91. MESSAGE(STATUS "Looking for MFC - found")
  92. SET(CMake_HAVE_MFC 1 CACHE INTERNAL "Have MFC?")
  93. FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
  94. "Determining if MFC exists passed with the following output:\n"
  95. "${OUTPUT}\n\n")
  96. ELSE(CMake_HAVE_MFC)
  97. MESSAGE(STATUS "Looking for MFC - not found")
  98. SET(CMake_HAVE_MFC 0 CACHE INTERNAL "Have MFC?")
  99. FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
  100. "Determining if MFC exists failed with the following output:\n"
  101. "${OUTPUT}\n\n")
  102. ENDIF(CMake_HAVE_MFC)
  103. ENDIF("CMake_HAVE_MFC" MATCHES "^CMake_HAVE_MFC$")
  104. IF(CMake_HAVE_MFC)
  105. OPTION(BUILD_MFCDialog "Whether to build the CMakeSetup MFC dialog." ON)
  106. ELSE(CMake_HAVE_MFC)
  107. SET(BUILD_MFCDialog 0)
  108. ENDIF(CMake_HAVE_MFC)
  109. ELSE(CMAKE_BUILD_ON_VISUAL_STUDIO)
  110. SET(BUILD_MFCDialog 0)
  111. ENDIF(CMAKE_BUILD_ON_VISUAL_STUDIO)
  112. ENDMACRO(CMAKE_TEST_FOR_MFC)
  113. #-----------------------------------------------------------------------
  114. # a macro to determine the generator and ctest executable to use
  115. # for testing. Simply to improve readability of the main script.
  116. #-----------------------------------------------------------------------
  117. MACRO(CMAKE_SETUP_TESTING)
  118. IF (NOT DART_ROOT)
  119. SET(MAKEPROGRAM ${CMAKE_MAKE_PROGRAM})
  120. ENDIF (NOT DART_ROOT)
  121. IF(BUILD_TESTING)
  122. SET(CMAKE_TEST_GENERATOR "" CACHE STRING
  123. "Generator used when running tests")
  124. SET(CMAKE_TEST_MAKEPROGRAM "" CACHE FILEPATH
  125. "Generator used when running tests")
  126. IF(NOT CMAKE_TEST_GENERATOR)
  127. SET(CMAKE_TEST_GENERATOR "${CMAKE_GENERATOR}")
  128. SET(CMAKE_TEST_MAKEPROGRAM "${MAKEPROGRAM}")
  129. ELSE(NOT CMAKE_TEST_GENERATOR)
  130. SET(CMAKE_TEST_DIFFERENT_GENERATOR TRUE)
  131. ENDIF(NOT CMAKE_TEST_GENERATOR)
  132. # Are we testing with the MSVC compiler?
  133. SET(CMAKE_TEST_MSVC 0)
  134. IF(MSVC AND NOT CMAKE_TEST_DIFFERENT_GENERATOR)
  135. SET(CMAKE_TEST_MSVC 1)
  136. ELSE(MSVC AND NOT CMAKE_TEST_DIFFERENT_GENERATOR)
  137. IF("${CMAKE_TEST_GENERATOR}" MATCHES "NMake" OR
  138. "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio")
  139. SET(CMAKE_TEST_MSVC 1)
  140. ENDIF("${CMAKE_TEST_GENERATOR}" MATCHES "NMake" OR
  141. "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio")
  142. ENDIF(MSVC AND NOT CMAKE_TEST_DIFFERENT_GENERATOR)
  143. SET(CMAKE_TEST_SYSTEM_LIBRARIES 0)
  144. FOREACH(util CURL EXPAT XMLRPC ZLIB)
  145. IF(CMAKE_USE_SYSTEM_${util})
  146. SET(CMAKE_TEST_SYSTEM_LIBRARIES 1)
  147. ENDIF(CMAKE_USE_SYSTEM_${util})
  148. ENDFOREACH(util)
  149. # This variable is set by cmake, however to
  150. # test cmake we want to make sure that
  151. # the ctest from this cmake is used for testing
  152. # and not the ctest from the cmake building and testing
  153. # cmake.
  154. SET(CMAKE_CTEST_COMMAND "${EXECUTABLE_OUTPUT_PATH}/ctest")
  155. SET(CMAKE_CMAKE_COMMAND "${EXECUTABLE_OUTPUT_PATH}/cmake")
  156. ENDIF(BUILD_TESTING)
  157. # configure some files for testing
  158. CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/Templates/CTestScript.cmake.in"
  159. "${CMAKE_CURRENT_BINARY_DIR}/CTestScript.cmake"
  160. @ONLY)
  161. CONFIGURE_FILE(${CMake_SOURCE_DIR}/Tests/.NoDartCoverage
  162. ${CMake_BINARY_DIR}/Tests/.NoDartCoverage)
  163. CONFIGURE_FILE(${CMake_SOURCE_DIR}/Tests/.NoDartCoverage
  164. ${CMake_BINARY_DIR}/Modules/.NoDartCoverage)
  165. CONFIGURE_FILE(${CMake_SOURCE_DIR}/CTestCustom.cmake.in
  166. ${CMake_BINARY_DIR}/CTestCustom.cmake @ONLY)
  167. CONFIGURE_FILE(${CMake_SOURCE_DIR}/CTestCustom.ctest.in
  168. ${CMake_BINARY_DIR}/CTestCustom.ctest @ONLY)
  169. IF(BUILD_TESTING AND DART_ROOT)
  170. CONFIGURE_FILE(${CMake_SOURCE_DIR}/CMakeLogo.gif
  171. ${CMake_BINARY_DIR}/Testing/HTML/TestingResults/Icons/Logo.gif COPYONLY)
  172. ENDIF(BUILD_TESTING AND DART_ROOT)
  173. MARK_AS_ADVANCED(DART_ROOT)
  174. MARK_AS_ADVANCED(CURL_TESTING)
  175. ENDMACRO(CMAKE_SETUP_TESTING)
  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 kwsys library for CMake.
  183. SET(KWSYS_NAMESPACE cmsys)
  184. SET(KWSYS_USE_SystemTools 1)
  185. SET(KWSYS_USE_Directory 1)
  186. SET(KWSYS_USE_RegularExpression 1)
  187. SET(KWSYS_USE_Base64 1)
  188. SET(KWSYS_USE_MD5 1)
  189. SET(KWSYS_USE_Process 1)
  190. SET(KWSYS_USE_CommandLineArguments 1)
  191. SET(KWSYS_HEADER_ROOT ${CMake_BINARY_DIR}/Source)
  192. SUBDIRS(Source/kwsys)
  193. #---------------------------------------------------------------------
  194. # Setup third-party libraries.
  195. # Everything in the tree should be able to include files from the
  196. # Utilities directory.
  197. INCLUDE_DIRECTORIES(
  198. ${CMake_SOURCE_DIR}/Utilities
  199. ${CMake_BINARY_DIR}/Utilities
  200. )
  201. # check for the use of system libraries versus builtin ones
  202. # (a macro defined in this file)
  203. CMAKE_HANDLE_SYSTEM_LIBRARIES()
  204. #---------------------------------------------------------------------
  205. # Build zlib library for Curl, CMake, and CTest.
  206. SET(CMAKE_ZLIB_HEADER "cm_zlib.h")
  207. IF(CMAKE_USE_SYSTEM_ZLIB)
  208. FIND_PACKAGE(ZLIB)
  209. IF(NOT ZLIB_FOUND)
  210. MESSAGE(FATAL_ERROR
  211. "CMAKE_USE_SYSTEM_ZLIB is ON but a zlib is not found!")
  212. ENDIF(NOT ZLIB_FOUND)
  213. SET(CMAKE_ZLIB_INCLUDES ${ZLIB_INCLUDE_DIR})
  214. SET(CMAKE_ZLIB_LIBRARIES ${ZLIB_LIBRARIES})
  215. ELSE(CMAKE_USE_SYSTEM_ZLIB)
  216. SET(CMAKE_ZLIB_INCLUDES)
  217. SET(CMAKE_ZLIB_LIBRARIES cmzlib)
  218. SUBDIRS(Utilities/cmzlib)
  219. ENDIF(CMAKE_USE_SYSTEM_ZLIB)
  220. #---------------------------------------------------------------------
  221. # Build Curl library for CTest.
  222. IF(CMAKE_USE_SYSTEM_CURL)
  223. FIND_PACKAGE(CURL)
  224. IF(NOT CURL_FOUND)
  225. MESSAGE(FATAL_ERROR
  226. "CMAKE_USE_SYSTEM_CURL is ON but a curl is not found!")
  227. ENDIF(NOT CURL_FOUND)
  228. SET(CMAKE_CURL_INCLUDES ${CURL_INCLUDE_DIRS})
  229. SET(CMAKE_CURL_LIBRARIES ${CURL_LIBRARIES})
  230. ELSE(CMAKE_USE_SYSTEM_CURL)
  231. SET(CURL_SPECIAL_ZLIB_H ${CMAKE_ZLIB_HEADER})
  232. SET(CURL_SPECIAL_LIBZ_INCLUDES ${CMAKE_ZLIB_INCLUDES})
  233. SET(CURL_SPECIAL_LIBZ ${CMAKE_ZLIB_LIBRARIES})
  234. ADD_DEFINITIONS(-DCURL_STATICLIB)
  235. SET(CMAKE_CURL_INCLUDES)
  236. SET(CMAKE_CURL_LIBRARIES cmcurl)
  237. SUBDIRS(Utilities/cmcurl)
  238. ENDIF(CMAKE_USE_SYSTEM_CURL)
  239. #---------------------------------------------------------------------
  240. # Build Tar library for CTest.
  241. SET(CMTAR_ZLIB_HEADER ${CMAKE_ZLIB_HEADER})
  242. SET(CMTAR_ZLIB_LIBRARIES ${CMAKE_ZLIB_LIBRARIES})
  243. SET(CMTAR_ZLIB_INCLUDE_DIRS ${CMAKE_ZLIB_INCLUDES})
  244. SET(CMAKE_TAR_INCLUDES ${CMAKE_CURRENT_BINARY_DIR}/Utilities/cmtar)
  245. SET(CMAKE_TAR_LIBRARIES cmtar)
  246. SUBDIRS(Utilities/cmtar)
  247. #---------------------------------------------------------------------
  248. # Build Compress library for CTest.
  249. SET(CMAKE_COMPRESS_INCLUDES
  250. "${CMAKE_CURRENT_BINARY_DIR}/Utilities/cmcompress")
  251. SET(CMAKE_COMPRESS_LIBRARIES "cmcompress")
  252. SUBDIRS(Utilities/cmcompress)
  253. #---------------------------------------------------------------------
  254. # Build expat library for CMake and CTest.
  255. IF(CMAKE_USE_SYSTEM_EXPAT)
  256. FIND_PACKAGE(EXPAT)
  257. IF(NOT EXPAT_FOUND)
  258. MESSAGE(FATAL_ERROR
  259. "CMAKE_USE_SYSTEM_EXPAT is ON but a expat is not found!")
  260. ENDIF(NOT EXPAT_FOUND)
  261. SET(CMAKE_EXPAT_INCLUDES ${EXPAT_INCLUDE_DIRS})
  262. SET(CMAKE_EXPAT_LIBRARIES ${EXPAT_LIBRARIES})
  263. ELSE(CMAKE_USE_SYSTEM_EXPAT)
  264. SET(CMAKE_EXPAT_INCLUDES)
  265. SET(CMAKE_EXPAT_LIBRARIES cmexpat)
  266. SUBDIRS(Utilities/cmexpat)
  267. ENDIF(CMAKE_USE_SYSTEM_EXPAT)
  268. #---------------------------------------------------------------------
  269. # Build XMLRPC library for CMake and CTest.
  270. IF(CMAKE_USE_SYSTEM_XMLRPC)
  271. FIND_PACKAGE(XMLRPC QUIET REQUIRED libwww-client)
  272. IF(NOT XMLRPC_FOUND)
  273. MESSAGE(FATAL_ERROR
  274. "CMAKE_USE_SYSTEM_XMLRPC is ON but a xmlrpc is not found!")
  275. ENDIF(NOT XMLRPC_FOUND)
  276. SET(CMAKE_XMLRPC_INCLUDES ${XMLRPC_INCLUDE_DIRS})
  277. SET(CMAKE_XMLRPC_LIBRARIES ${XMLRPC_LIBRARIES})
  278. ELSE(CMAKE_USE_SYSTEM_XMLRPC)
  279. SET(CMAKE_XMLRPC_INCLUDES)
  280. SET(CMAKE_XMLRPC_LIBRARIES cmXMLRPC)
  281. SUBDIRS(Utilities/cmxmlrpc)
  282. ENDIF(CMAKE_USE_SYSTEM_XMLRPC)
  283. #---------------------------------------------------------------------
  284. # Use curses?
  285. IF (UNIX)
  286. # there is a bug in the Syllable libraries which makes linking ccmake fail, Alex
  287. IF(NOT "${CMAKE_SYSTEM_NAME}" MATCHES syllable)
  288. SET(CURSES_NEED_NCURSES TRUE)
  289. FIND_PACKAGE(Curses QUIET)
  290. IF (CURSES_LIBRARY)
  291. OPTION(BUILD_CursesDialog "Build the CMake Curses Dialog ccmake" ON)
  292. ELSE (CURSES_LIBRARY)
  293. MESSAGE("Curses libraries were not found. Curses GUI for CMake will not be built.")
  294. SET(BUILD_CursesDialog 0)
  295. ENDIF (CURSES_LIBRARY)
  296. ELSE(NOT "${CMAKE_SYSTEM_NAME}" MATCHES syllable)
  297. SET(BUILD_CursesDialog 0)
  298. ENDIF(NOT "${CMAKE_SYSTEM_NAME}" MATCHES syllable)
  299. ELSE (UNIX)
  300. SET(BUILD_CursesDialog 0)
  301. ENDIF (UNIX)
  302. IF(BUILD_CursesDialog)
  303. SUBDIRS(Source/CursesDialog/form)
  304. ENDIF(BUILD_CursesDialog)
  305. ENDMACRO (CMAKE_BUILD_UTILITIES)
  306. #-----------------------------------------------------------------------
  307. # The main section of the CMakeLists file
  308. #
  309. #-----------------------------------------------------------------------
  310. # The CMake version number.
  311. SET(CMake_VERSION_MAJOR 2)
  312. SET(CMake_VERSION_MINOR 5)
  313. SET(CMake_VERSION_PATCH 0)
  314. # CVS versions are odd, if this is an odd minor version
  315. # then set the CMake_VERSION_DATE variable
  316. IF("${CMake_VERSION_MINOR}" MATCHES "[13579]$")
  317. INCLUDE(${CMake_SOURCE_DIR}/Source/kwsys/kwsysDateStamp.cmake)
  318. SET(CMake_VERSION_DATE
  319. "${KWSYS_DATE_STAMP_YEAR}${KWSYS_DATE_STAMP_MONTH}${KWSYS_DATE_STAMP_DAY}"
  320. )
  321. ENDIF("${CMake_VERSION_MINOR}" MATCHES "[13579]$")
  322. SET(CMake_VERSION "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
  323. SET(CMake_VERSION_FULL "${CMake_VERSION}.${CMake_VERSION_PATCH}")
  324. # Include the standard Dart testing module
  325. ENABLE_TESTING()
  326. INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake)
  327. # where to write the resulting executables and libraries
  328. SET(BUILD_SHARED_LIBS OFF)
  329. SET(EXECUTABLE_OUTPUT_PATH ${CMake_BINARY_DIR}/bin CACHE INTERNAL
  330. "Where to put the executables for CMake")
  331. SET(LIBRARY_OUTPUT_PATH "" CACHE INTERNAL
  332. "Where to put the libraries for CMake")
  333. INCLUDE_REGULAR_EXPRESSION("^.*$")
  334. # The CMake executables usually do not need any rpath to run in the build or
  335. # install tree.
  336. SET(CMAKE_SKIP_RPATH ON CACHE INTERNAL "CMake does not need RPATHs.")
  337. SET(CMAKE_DATA_DIR "/share/cmake-${CMake_VERSION}" CACHE STRING
  338. "Install location for data (relative to prefix).")
  339. SET(CMAKE_DOC_DIR "/doc/cmake-${CMake_VERSION}" CACHE STRING
  340. "Install location for documentation (relative to prefix).")
  341. SET(CMAKE_MAN_DIR "/man" CACHE STRING
  342. "Install location for man pages (relative to prefix).")
  343. MARK_AS_ADVANCED(CMAKE_DATA_DIR CMAKE_DOC_DIR CMAKE_MAN_DIR)
  344. # include special compile flags for some compilers
  345. INCLUDE(CompileFlags.cmake)
  346. # no clue why we are testing for this here
  347. INCLUDE(CheckSymbolExists)
  348. CHECK_SYMBOL_EXISTS(unsetenv "stdlib.h" HAVE_UNSETENV)
  349. CHECK_SYMBOL_EXISTS(environ "stdlib.h" HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE)
  350. # build the utilities (a macro defined in this file)
  351. CMAKE_BUILD_UTILITIES()
  352. # On NetBSD ncurses is required, since curses doesn't have the wsyncup()
  353. # function. ncurses is installed via pkgsrc, so the library is in /usr/pkg/lib,
  354. # which isn't in the default linker search path. So without RPATH ccmake
  355. # doesn't run and the build doesn't succeed since ccmake is executed for
  356. # generating the documentation.
  357. IF(BUILD_CursesDialog)
  358. GET_FILENAME_COMPONENT(_CURSES_DIR "${CURSES_LIBRARY}" PATH)
  359. SET(CURSES_NEED_RPATH FALSE)
  360. 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")
  361. SET(CURSES_NEED_RPATH TRUE)
  362. ENDIF(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")
  363. ENDIF(BUILD_CursesDialog)
  364. IF(BUILD_QtDialog)
  365. SET(QT_NEED_RPATH FALSE)
  366. 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")
  367. SET(QT_NEED_RPATH TRUE)
  368. ENDIF(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")
  369. ENDIF(BUILD_QtDialog)
  370. # The same might be true on other systems for other libraries if
  371. # CMAKE_USE_SYSTEM_XMLRPC or other variables like this are enabled.
  372. # Then only enable RPATH if we have are building at least with cmake 2.4,
  373. # since this one has much better RPATH features than cmake 2.2.
  374. # The executables are then built with the RPATH for the libraries outside
  375. # the build tree, which is both the build and the install RPATH.
  376. IF (UNIX AND "${CMAKE_MAJOR_VERSION}${CMAKE_MINOR_VERSION}" GREATER 23)
  377. IF( CMAKE_USE_SYSTEM_CURL OR CMAKE_USE_SYSTEM_ZLIB
  378. OR CMAKE_USE_SYSTEM_EXPAT OR CMAKE_USE_SYSTEM_XMLRPC OR CURSES_NEED_RPATH OR QT_NEED_RPATH)
  379. SET(CMAKE_SKIP_RPATH OFF CACHE INTERNAL "CMake built with RPATH.")
  380. SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  381. SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
  382. MESSAGE(STATUS "Enabling RPATH")
  383. ENDIF(CMAKE_USE_SYSTEM_CURL OR CMAKE_USE_SYSTEM_ZLIB
  384. OR CMAKE_USE_SYSTEM_EXPAT OR CMAKE_USE_SYSTEM_XMLRPC OR CURSES_NEED_RPATH OR QT_NEED_RPATH)
  385. ENDIF (UNIX AND "${CMAKE_MAJOR_VERSION}${CMAKE_MINOR_VERSION}" GREATER 23)
  386. # should we build the MFC dialog? (a macro defined in this file)
  387. CMAKE_TEST_FOR_MFC()
  388. # add the uninstall support
  389. CONFIGURE_FILE(
  390. "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
  391. "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  392. @ONLY)
  393. ADD_CUSTOM_TARGET(uninstall
  394. "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
  395. INCLUDE (CMakeCPack.cmake)
  396. # setup some Testing support (a macro defined in this file)
  397. CMAKE_SETUP_TESTING()
  398. CONFIGURE_FILE(
  399. "${CMAKE_CURRENT_SOURCE_DIR}/DartLocal.conf.in"
  400. "${CMAKE_CURRENT_BINARY_DIR}/DartLocal.conf"
  401. COPYONLY)
  402. OPTION(CMAKE_STRICT
  403. "Perform strict testing to record property and variable access. Can be used to report any undefined properties or variables" OFF)
  404. MARK_AS_ADVANCED(CMAKE_STRICT)
  405. # build the remaining subdirectories
  406. SUBDIRS(Source)
  407. SUBDIRS(Modules)
  408. SUBDIRS(Templates)
  409. SUBDIRS(Utilities)
  410. SUBDIRS(Tests)
  411. # add a test
  412. ADD_TEST(SystemInformationNew "${CMAKE_CMAKE_COMMAND}"
  413. --system-information -G "${CMAKE_TEST_GENERATOR}" )
  414. #-----------------------------------------------------------------------
  415. # End of the main section of the CMakeLists file
  416. #-----------------------------------------------------------------------