CMakeLists.txt 20 KB

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