CMakeLists.txt 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. PROJECT(CMake)
  2. CMAKE_MINIMUM_REQUIRED(VERSION 2.4 FATAL_ERROR)
  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. SET(MAKEPROGRAM ${CMAKE_MAKE_PROGRAM})
  119. IF(BUILD_TESTING)
  120. SET(CMAKE_TEST_GENERATOR "" CACHE STRING
  121. "Generator used when running tests")
  122. SET(CMAKE_TEST_MAKEPROGRAM "" CACHE FILEPATH
  123. "Generator used when running tests")
  124. IF(NOT CMAKE_TEST_GENERATOR)
  125. SET(CMAKE_TEST_GENERATOR "${CMAKE_GENERATOR}")
  126. SET(CMAKE_TEST_MAKEPROGRAM "${MAKEPROGRAM}")
  127. ELSE(NOT CMAKE_TEST_GENERATOR)
  128. SET(CMAKE_TEST_DIFFERENT_GENERATOR TRUE)
  129. ENDIF(NOT CMAKE_TEST_GENERATOR)
  130. # Are we testing with the MSVC compiler?
  131. SET(CMAKE_TEST_MSVC 0)
  132. IF(MSVC AND NOT CMAKE_TEST_DIFFERENT_GENERATOR)
  133. SET(CMAKE_TEST_MSVC 1)
  134. ELSE(MSVC AND NOT CMAKE_TEST_DIFFERENT_GENERATOR)
  135. IF("${CMAKE_TEST_GENERATOR}" MATCHES "NMake" OR
  136. "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio")
  137. SET(CMAKE_TEST_MSVC 1)
  138. ENDIF("${CMAKE_TEST_GENERATOR}" MATCHES "NMake" OR
  139. "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio")
  140. ENDIF(MSVC AND NOT CMAKE_TEST_DIFFERENT_GENERATOR)
  141. SET(CMAKE_TEST_SYSTEM_LIBRARIES 0)
  142. FOREACH(util CURL EXPAT XMLRPC ZLIB)
  143. IF(CMAKE_USE_SYSTEM_${util})
  144. SET(CMAKE_TEST_SYSTEM_LIBRARIES 1)
  145. ENDIF(CMAKE_USE_SYSTEM_${util})
  146. ENDFOREACH(util)
  147. # This variable is set by cmake, however to
  148. # test cmake we want to make sure that
  149. # the ctest from this cmake is used for testing
  150. # and not the ctest from the cmake building and testing
  151. # cmake.
  152. SET(CMAKE_CTEST_COMMAND "${EXECUTABLE_OUTPUT_PATH}/ctest")
  153. SET(CMAKE_CMAKE_COMMAND "${EXECUTABLE_OUTPUT_PATH}/cmake")
  154. ENDIF(BUILD_TESTING)
  155. # configure some files for testing
  156. CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/Templates/CTestScript.cmake.in"
  157. "${CMAKE_CURRENT_BINARY_DIR}/CTestScript.cmake"
  158. @ONLY)
  159. CONFIGURE_FILE(${CMake_SOURCE_DIR}/Tests/.NoDartCoverage
  160. ${CMake_BINARY_DIR}/Tests/.NoDartCoverage)
  161. CONFIGURE_FILE(${CMake_SOURCE_DIR}/Tests/.NoDartCoverage
  162. ${CMake_BINARY_DIR}/Modules/.NoDartCoverage)
  163. CONFIGURE_FILE(${CMake_SOURCE_DIR}/CTestCustom.cmake.in
  164. ${CMake_BINARY_DIR}/CTestCustom.cmake @ONLY)
  165. CONFIGURE_FILE(${CMake_SOURCE_DIR}/CTestCustom.ctest.in
  166. ${CMake_BINARY_DIR}/CTestCustom.ctest @ONLY)
  167. MARK_AS_ADVANCED(CURL_TESTING)
  168. ENDMACRO(CMAKE_SETUP_TESTING)
  169. #-----------------------------------------------------------------------
  170. # a macro to build the utilities used by CMake
  171. # Simply to improve readability of the main script.
  172. #-----------------------------------------------------------------------
  173. MACRO (CMAKE_BUILD_UTILITIES)
  174. #---------------------------------------------------------------------
  175. # Create the kwsys library for CMake.
  176. SET(KWSYS_NAMESPACE cmsys)
  177. SET(KWSYS_USE_SystemTools 1)
  178. SET(KWSYS_USE_Directory 1)
  179. SET(KWSYS_USE_RegularExpression 1)
  180. SET(KWSYS_USE_Base64 1)
  181. SET(KWSYS_USE_MD5 1)
  182. SET(KWSYS_USE_Process 1)
  183. SET(KWSYS_USE_CommandLineArguments 1)
  184. SET(KWSYS_HEADER_ROOT ${CMake_BINARY_DIR}/Source)
  185. SUBDIRS(Source/kwsys)
  186. #---------------------------------------------------------------------
  187. # Setup third-party libraries.
  188. # Everything in the tree should be able to include files from the
  189. # Utilities directory.
  190. INCLUDE_DIRECTORIES(
  191. ${CMake_SOURCE_DIR}/Utilities
  192. ${CMake_BINARY_DIR}/Utilities
  193. )
  194. # check for the use of system libraries versus builtin ones
  195. # (a macro defined in this file)
  196. CMAKE_HANDLE_SYSTEM_LIBRARIES()
  197. #---------------------------------------------------------------------
  198. # Build zlib library for Curl, CMake, and CTest.
  199. SET(CMAKE_ZLIB_HEADER "cm_zlib.h")
  200. IF(CMAKE_USE_SYSTEM_ZLIB)
  201. FIND_PACKAGE(ZLIB)
  202. IF(NOT ZLIB_FOUND)
  203. MESSAGE(FATAL_ERROR
  204. "CMAKE_USE_SYSTEM_ZLIB is ON but a zlib is not found!")
  205. ENDIF(NOT ZLIB_FOUND)
  206. SET(CMAKE_ZLIB_INCLUDES ${ZLIB_INCLUDE_DIR})
  207. SET(CMAKE_ZLIB_LIBRARIES ${ZLIB_LIBRARIES})
  208. ELSE(CMAKE_USE_SYSTEM_ZLIB)
  209. SET(CMAKE_ZLIB_INCLUDES)
  210. SET(CMAKE_ZLIB_LIBRARIES cmzlib)
  211. SUBDIRS(Utilities/cmzlib)
  212. ENDIF(CMAKE_USE_SYSTEM_ZLIB)
  213. #---------------------------------------------------------------------
  214. # Build Curl library for CTest.
  215. IF(CMAKE_USE_SYSTEM_CURL)
  216. FIND_PACKAGE(CURL)
  217. IF(NOT CURL_FOUND)
  218. MESSAGE(FATAL_ERROR
  219. "CMAKE_USE_SYSTEM_CURL is ON but a curl is not found!")
  220. ENDIF(NOT CURL_FOUND)
  221. SET(CMAKE_CURL_INCLUDES ${CURL_INCLUDE_DIRS})
  222. SET(CMAKE_CURL_LIBRARIES ${CURL_LIBRARIES})
  223. ELSE(CMAKE_USE_SYSTEM_CURL)
  224. SET(CURL_SPECIAL_ZLIB_H ${CMAKE_ZLIB_HEADER})
  225. SET(CURL_SPECIAL_LIBZ_INCLUDES ${CMAKE_ZLIB_INCLUDES})
  226. SET(CURL_SPECIAL_LIBZ ${CMAKE_ZLIB_LIBRARIES})
  227. ADD_DEFINITIONS(-DCURL_STATICLIB)
  228. SET(CMAKE_CURL_INCLUDES)
  229. SET(CMAKE_CURL_LIBRARIES cmcurl)
  230. SUBDIRS(Utilities/cmcurl)
  231. ENDIF(CMAKE_USE_SYSTEM_CURL)
  232. #---------------------------------------------------------------------
  233. # Build Tar library for CTest.
  234. SET(CMTAR_ZLIB_HEADER ${CMAKE_ZLIB_HEADER})
  235. SET(CMTAR_ZLIB_LIBRARIES ${CMAKE_ZLIB_LIBRARIES})
  236. SET(CMTAR_ZLIB_INCLUDE_DIRS ${CMAKE_ZLIB_INCLUDES})
  237. SET(CMAKE_TAR_INCLUDES ${CMAKE_CURRENT_BINARY_DIR}/Utilities/cmtar)
  238. SET(CMAKE_TAR_LIBRARIES cmtar)
  239. SUBDIRS(Utilities/cmtar)
  240. #---------------------------------------------------------------------
  241. # Build Compress library for CTest.
  242. SET(CMAKE_COMPRESS_INCLUDES
  243. "${CMAKE_CURRENT_BINARY_DIR}/Utilities/cmcompress")
  244. SET(CMAKE_COMPRESS_LIBRARIES "cmcompress")
  245. SUBDIRS(Utilities/cmcompress)
  246. #---------------------------------------------------------------------
  247. # Build expat library for CMake and CTest.
  248. IF(CMAKE_USE_SYSTEM_EXPAT)
  249. FIND_PACKAGE(EXPAT)
  250. IF(NOT EXPAT_FOUND)
  251. MESSAGE(FATAL_ERROR
  252. "CMAKE_USE_SYSTEM_EXPAT is ON but a expat is not found!")
  253. ENDIF(NOT EXPAT_FOUND)
  254. SET(CMAKE_EXPAT_INCLUDES ${EXPAT_INCLUDE_DIRS})
  255. SET(CMAKE_EXPAT_LIBRARIES ${EXPAT_LIBRARIES})
  256. ELSE(CMAKE_USE_SYSTEM_EXPAT)
  257. SET(CMAKE_EXPAT_INCLUDES)
  258. SET(CMAKE_EXPAT_LIBRARIES cmexpat)
  259. SUBDIRS(Utilities/cmexpat)
  260. ENDIF(CMAKE_USE_SYSTEM_EXPAT)
  261. #---------------------------------------------------------------------
  262. # Build XMLRPC library for CMake and CTest.
  263. IF(CMAKE_USE_SYSTEM_XMLRPC)
  264. FIND_PACKAGE(XMLRPC QUIET REQUIRED libwww-client)
  265. IF(NOT XMLRPC_FOUND)
  266. MESSAGE(FATAL_ERROR
  267. "CMAKE_USE_SYSTEM_XMLRPC is ON but a xmlrpc is not found!")
  268. ENDIF(NOT XMLRPC_FOUND)
  269. SET(CMAKE_XMLRPC_INCLUDES ${XMLRPC_INCLUDE_DIRS})
  270. SET(CMAKE_XMLRPC_LIBRARIES ${XMLRPC_LIBRARIES})
  271. ELSE(CMAKE_USE_SYSTEM_XMLRPC)
  272. SET(CMAKE_XMLRPC_INCLUDES)
  273. SET(CMAKE_XMLRPC_LIBRARIES cmXMLRPC)
  274. SUBDIRS(Utilities/cmxmlrpc)
  275. ENDIF(CMAKE_USE_SYSTEM_XMLRPC)
  276. #---------------------------------------------------------------------
  277. # Use curses?
  278. IF (UNIX)
  279. # there is a bug in the Syllable libraries which makes linking ccmake fail, Alex
  280. IF(NOT "${CMAKE_SYSTEM_NAME}" MATCHES syllable)
  281. SET(CURSES_NEED_NCURSES TRUE)
  282. FIND_PACKAGE(Curses QUIET)
  283. IF (CURSES_LIBRARY)
  284. OPTION(BUILD_CursesDialog "Build the CMake Curses Dialog ccmake" ON)
  285. ELSE (CURSES_LIBRARY)
  286. MESSAGE("Curses libraries were not found. Curses GUI for CMake will not be built.")
  287. SET(BUILD_CursesDialog 0)
  288. ENDIF (CURSES_LIBRARY)
  289. ELSE(NOT "${CMAKE_SYSTEM_NAME}" MATCHES syllable)
  290. SET(BUILD_CursesDialog 0)
  291. ENDIF(NOT "${CMAKE_SYSTEM_NAME}" MATCHES syllable)
  292. ELSE (UNIX)
  293. SET(BUILD_CursesDialog 0)
  294. ENDIF (UNIX)
  295. IF(BUILD_CursesDialog)
  296. SUBDIRS(Source/CursesDialog/form)
  297. ENDIF(BUILD_CursesDialog)
  298. ENDMACRO (CMAKE_BUILD_UTILITIES)
  299. #-----------------------------------------------------------------------
  300. # The main section of the CMakeLists file
  301. #
  302. #-----------------------------------------------------------------------
  303. # The CMake version number.
  304. SET(CMake_VERSION_MAJOR 2)
  305. SET(CMake_VERSION_MINOR 5)
  306. SET(CMake_VERSION_PATCH 0)
  307. # CVS versions are odd, if this is an odd minor version
  308. # then set the CMake_VERSION_DATE variable
  309. IF("${CMake_VERSION_MINOR}" MATCHES "[13579]$")
  310. INCLUDE(${CMake_SOURCE_DIR}/Source/kwsys/kwsysDateStamp.cmake)
  311. SET(CMake_VERSION_DATE
  312. "${KWSYS_DATE_STAMP_YEAR}${KWSYS_DATE_STAMP_MONTH}${KWSYS_DATE_STAMP_DAY}"
  313. )
  314. ENDIF("${CMake_VERSION_MINOR}" MATCHES "[13579]$")
  315. SET(CMake_VERSION "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
  316. SET(CMake_VERSION_FULL "${CMake_VERSION}.${CMake_VERSION_PATCH}")
  317. # Include the standard Dart testing module
  318. ENABLE_TESTING()
  319. INCLUDE (${CMAKE_ROOT}/Modules/CTest.cmake)
  320. # where to write the resulting executables and libraries
  321. SET(BUILD_SHARED_LIBS OFF)
  322. SET(EXECUTABLE_OUTPUT_PATH ${CMake_BINARY_DIR}/bin CACHE INTERNAL
  323. "Where to put the executables for CMake")
  324. SET(LIBRARY_OUTPUT_PATH "" CACHE INTERNAL
  325. "Where to put the libraries for CMake")
  326. INCLUDE_REGULAR_EXPRESSION("^.*$")
  327. # The CMake executables usually do not need any rpath to run in the build or
  328. # install tree.
  329. SET(CMAKE_SKIP_RPATH ON CACHE INTERNAL "CMake does not need RPATHs.")
  330. SET(CMAKE_DATA_DIR "/share/cmake-${CMake_VERSION}" CACHE STRING
  331. "Install location for data (relative to prefix).")
  332. SET(CMAKE_DOC_DIR "/doc/cmake-${CMake_VERSION}" CACHE STRING
  333. "Install location for documentation (relative to prefix).")
  334. SET(CMAKE_MAN_DIR "/man" CACHE STRING
  335. "Install location for man pages (relative to prefix).")
  336. MARK_AS_ADVANCED(CMAKE_DATA_DIR CMAKE_DOC_DIR CMAKE_MAN_DIR)
  337. # include special compile flags for some compilers
  338. INCLUDE(CompileFlags.cmake)
  339. # no clue why we are testing for this here
  340. INCLUDE(CheckSymbolExists)
  341. CHECK_SYMBOL_EXISTS(unsetenv "stdlib.h" HAVE_UNSETENV)
  342. CHECK_SYMBOL_EXISTS(environ "stdlib.h" HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE)
  343. # build the utilities (a macro defined in this file)
  344. CMAKE_BUILD_UTILITIES()
  345. # On NetBSD ncurses is required, since curses doesn't have the wsyncup()
  346. # function. ncurses is installed via pkgsrc, so the library is in /usr/pkg/lib,
  347. # which isn't in the default linker search path. So without RPATH ccmake
  348. # doesn't run and the build doesn't succeed since ccmake is executed for
  349. # generating the documentation.
  350. IF(BUILD_CursesDialog)
  351. GET_FILENAME_COMPONENT(_CURSES_DIR "${CURSES_LIBRARY}" PATH)
  352. SET(CURSES_NEED_RPATH FALSE)
  353. 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")
  354. SET(CURSES_NEED_RPATH TRUE)
  355. 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")
  356. ENDIF(BUILD_CursesDialog)
  357. IF(BUILD_QtDialog)
  358. IF(APPLE)
  359. SET(CMAKE_INSTALL_SUBDIR
  360. "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}-${CMake_VERSION_PATCH}")
  361. IF(CMake_VERSION_DATE)
  362. SET(CMAKE_INSTALL_SUBDIR
  363. "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}-${CMake_VERSION_DATE}")
  364. ENDIF(CMake_VERSION_DATE)
  365. # make sure CMAKE_INSTALL_PREFIX ends in /
  366. STRING(LENGTH "${CMAKE_INSTALL_PREFIX}" LEN)
  367. MATH(EXPR LEN "${LEN} -1" )
  368. STRING(SUBSTRING "${CMAKE_INSTALL_PREFIX}" ${LEN} 1 ENDCH)
  369. IF(NOT "${ENDCH}" STREQUAL "/")
  370. SET(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/")
  371. ENDIF(NOT "${ENDCH}" STREQUAL "/")
  372. SET(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}${CMAKE_INSTALL_SUBDIR}")
  373. SET(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}${CMAKE_INSTALL_SUBDIR}/cmake-gui.app/Contents")
  374. ENDIF(APPLE)
  375. SET(QT_NEED_RPATH FALSE)
  376. 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")
  377. SET(QT_NEED_RPATH TRUE)
  378. 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")
  379. ENDIF(BUILD_QtDialog)
  380. # The same might be true on other systems for other libraries if
  381. # CMAKE_USE_SYSTEM_XMLRPC or other variables like this are enabled.
  382. # Then only enable RPATH if we have are building at least with cmake 2.4,
  383. # since this one has much better RPATH features than cmake 2.2.
  384. # The executables are then built with the RPATH for the libraries outside
  385. # the build tree, which is both the build and the install RPATH.
  386. IF (UNIX AND "${CMAKE_MAJOR_VERSION}${CMAKE_MINOR_VERSION}" GREATER 23)
  387. IF( CMAKE_USE_SYSTEM_CURL OR CMAKE_USE_SYSTEM_ZLIB
  388. OR CMAKE_USE_SYSTEM_EXPAT OR CMAKE_USE_SYSTEM_XMLRPC OR CURSES_NEED_RPATH OR QT_NEED_RPATH)
  389. SET(CMAKE_SKIP_RPATH OFF CACHE INTERNAL "CMake built with RPATH.")
  390. SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  391. SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
  392. MESSAGE(STATUS "Enabling RPATH")
  393. ENDIF(CMAKE_USE_SYSTEM_CURL OR CMAKE_USE_SYSTEM_ZLIB
  394. OR CMAKE_USE_SYSTEM_EXPAT OR CMAKE_USE_SYSTEM_XMLRPC OR CURSES_NEED_RPATH OR QT_NEED_RPATH)
  395. ENDIF (UNIX AND "${CMAKE_MAJOR_VERSION}${CMAKE_MINOR_VERSION}" GREATER 23)
  396. # should we build the MFC dialog? (a macro defined in this file)
  397. CMAKE_TEST_FOR_MFC()
  398. # add the uninstall support
  399. CONFIGURE_FILE(
  400. "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
  401. "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  402. @ONLY)
  403. ADD_CUSTOM_TARGET(uninstall
  404. "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
  405. INCLUDE (CMakeCPack.cmake)
  406. # setup some Testing support (a macro defined in this file)
  407. CMAKE_SETUP_TESTING()
  408. CONFIGURE_FILE(
  409. "${CMAKE_CURRENT_SOURCE_DIR}/DartLocal.conf.in"
  410. "${CMAKE_CURRENT_BINARY_DIR}/DartLocal.conf"
  411. COPYONLY)
  412. OPTION(CMAKE_STRICT
  413. "Perform strict testing to record property and variable access. Can be used to report any undefined properties or variables" OFF)
  414. MARK_AS_ADVANCED(CMAKE_STRICT)
  415. # build the remaining subdirectories
  416. SUBDIRS(Source)
  417. SUBDIRS(Modules)
  418. SUBDIRS(Templates)
  419. SUBDIRS(Utilities)
  420. SUBDIRS(Tests)
  421. # add a test
  422. ADD_TEST(SystemInformationNew "${CMAKE_CMAKE_COMMAND}"
  423. --system-information -G "${CMAKE_TEST_GENERATOR}" )
  424. #-----------------------------------------------------------------------
  425. # End of the main section of the CMakeLists file
  426. #-----------------------------------------------------------------------