1 #=============================================================================
2 # CMake - Cross Platform Makefile Generator
3 # Copyright 2000-2012 Kitware, Inc., Insight Software Consortium
5 # Distributed under the OSI-approved BSD License (the "License");
6 # see accompanying file Copyright.txt for details.
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.2 FATAL_ERROR)
13 set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
17 # Running from bootstrap script. Set local variable and remove from cache.
18 set(CMAKE_BOOTSTRAP 1)
19 unset(CMAKE_BOOTSTRAP CACHE)
22 set(CMake_BIN_DIR ${CMake_BINARY_DIR}/bin)
24 if("${CMake_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
25 # Disallow architecture-specific try_run. It may not run on the host.
27 if(CMAKE_TRY_COMPILE_OSX_ARCHITECTURES)
28 message(FATAL_ERROR "TRY_RUN not allowed with CMAKE_TRY_COMPILE_OSX_ARCHITECTURES=[${CMAKE_TRY_COMPILE_OSX_ARCHITECTURES}]")
35 #-----------------------------------------------------------------------
36 # a macro to deal with system libraries, implemented as a macro
37 # simply to improve readability of the main script
38 #-----------------------------------------------------------------------
39 macro(CMAKE_HANDLE_SYSTEM_LIBRARIES)
40 # Options have dependencies.
41 include(CMakeDependentOption)
43 # Optionally use system xmlrpc. We no longer build or use it by default.
44 option(CTEST_USE_XMLRPC "Enable xmlrpc submission method in CTest." OFF)
45 mark_as_advanced(CTEST_USE_XMLRPC)
47 # Allow the user to enable/disable all system utility library options by
48 # defining CMAKE_USE_SYSTEM_LIBRARIES or CMAKE_USE_SYSTEM_LIBRARY_${util}.
49 set(UTILITIES BZIP2 CURL EXPAT LIBARCHIVE ZLIB)
50 foreach(util ${UTILITIES})
51 if(NOT DEFINED CMAKE_USE_SYSTEM_LIBRARY_${util}
52 AND DEFINED CMAKE_USE_SYSTEM_LIBRARIES)
53 set(CMAKE_USE_SYSTEM_LIBRARY_${util} "${CMAKE_USE_SYSTEM_LIBRARIES}")
55 if(DEFINED CMAKE_USE_SYSTEM_LIBRARY_${util})
56 if(CMAKE_USE_SYSTEM_LIBRARY_${util})
57 set(CMAKE_USE_SYSTEM_LIBRARY_${util} ON)
59 set(CMAKE_USE_SYSTEM_LIBRARY_${util} OFF)
62 unset(CMAKE_USE_SYSTEM_LIBRARY_${util} CACHE)
64 string(TOLOWER "${util}" lutil)
65 set(CMAKE_USE_SYSTEM_${util} "${CMAKE_USE_SYSTEM_LIBRARY_${util}}"
66 CACHE BOOL "Use system-installed ${lutil}" FORCE)
68 set(CMAKE_USE_SYSTEM_LIBRARY_${util} OFF)
72 unset(CMAKE_USE_SYSTEM_LIBRARIES CACHE)
75 # Optionally use system utility libraries.
76 option(CMAKE_USE_SYSTEM_LIBARCHIVE "Use system-installed libarchive" "${CMAKE_USE_SYSTEM_LIBRARY_LIBARCHIVE}")
77 CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_CURL "Use system-installed curl"
78 "${CMAKE_USE_SYSTEM_LIBRARY_CURL}" "NOT CTEST_USE_XMLRPC" ON)
79 CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_EXPAT "Use system-installed expat"
80 "${CMAKE_USE_SYSTEM_LIBRARY_EXPAT}" "NOT CTEST_USE_XMLRPC" ON)
81 CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_ZLIB "Use system-installed zlib"
82 "${CMAKE_USE_SYSTEM_LIBRARY_ZLIB}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE;NOT CMAKE_USE_SYSTEM_CURL" ON)
83 CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_BZIP2 "Use system-installed bzip2"
84 "${CMAKE_USE_SYSTEM_LIBRARY_BZIP2}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE" ON)
86 # Mention to the user what system libraries are being used.
87 foreach(util ${UTILITIES})
88 if(CMAKE_USE_SYSTEM_${util})
89 message(STATUS "Using system-installed ${util}")
93 # Inform utility library header wrappers whether to use system versions.
94 configure_file(${CMake_SOURCE_DIR}/Utilities/cmThirdParty.h.in
95 ${CMake_BINARY_DIR}/Utilities/cmThirdParty.h
103 set(CMAKE_BUILD_ON_VISUAL_STUDIO 0)
104 if(WIN32 AND NOT UNIX AND NOT BORLAND AND NOT MINGW )
105 set(CMAKE_BUILD_ON_VISUAL_STUDIO 1)
109 #-----------------------------------------------------------------------
110 # a macro to determine the generator and ctest executable to use
111 # for testing. Simply to improve readability of the main script.
112 #-----------------------------------------------------------------------
113 macro(CMAKE_SETUP_TESTING)
115 set(MAKEPROGRAM ${CMAKE_MAKE_PROGRAM})
119 set(CMAKE_TEST_GENERATOR "" CACHE STRING
120 "Generator used when running tests")
121 set(CMAKE_TEST_MAKEPROGRAM "" CACHE FILEPATH
122 "Generator used when running tests")
123 if(NOT CMAKE_TEST_GENERATOR)
124 set(CMAKE_TEST_GENERATOR "${CMAKE_GENERATOR}")
125 set(CMAKE_TEST_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}")
126 set(CMAKE_TEST_MAKEPROGRAM "${MAKEPROGRAM}")
128 set(CMAKE_TEST_DIFFERENT_GENERATOR TRUE)
129 set(CMAKE_TEST_GENERATOR_TOOLSET "")
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)
137 if("${CMAKE_TEST_GENERATOR}" MATCHES "NMake" OR
138 "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio")
139 set(CMAKE_TEST_MSVC 1)
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)
150 # This variable is set by cmake, however to
151 # test cmake we want to make sure that
152 # the ctest from this cmake is used for testing
153 # and not the ctest from the cmake building and testing
155 set(CMAKE_CTEST_COMMAND "${CMake_BIN_DIR}/ctest")
156 set(CMAKE_CMAKE_COMMAND "${CMake_BIN_DIR}/cmake")
157 set(CMAKE_CPACK_COMMAND "${CMake_BIN_DIR}/cpack")
160 # configure some files for testing
161 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Templates/CTestScript.cmake.in"
162 "${CMAKE_CURRENT_BINARY_DIR}/CTestScript.cmake"
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)
176 mark_as_advanced(DART_ROOT)
177 mark_as_advanced(CURL_TESTING)
181 # Provide a way for Visual Studio Express users to turn OFF the new FOLDER
182 # organization feature. Default to ON for non-Express users. Express users must
183 # explicitly turn off this option to build CMake in the Express IDE...
185 option(CMAKE_USE_FOLDERS "Enable folder grouping of projects in IDEs." ON)
186 mark_as_advanced(CMAKE_USE_FOLDERS)
189 #-----------------------------------------------------------------------
190 # a macro that only sets the FOLDER target property if it's
192 #-----------------------------------------------------------------------
193 macro(CMAKE_SET_TARGET_FOLDER tgt folder)
194 if(CMAKE_USE_FOLDERS)
195 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
197 # Really, I just want this to be an "if(TARGET ${tgt})" ...
198 # but I'm not sure that our min req'd., CMake 2.4.5 can handle
199 # that... so I'm just activating this for now, with a version
200 # compare, and only for MSVC builds.
202 if(NOT ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.8)
203 set_property(TARGET "${tgt}" PROPERTY FOLDER "${folder}")
207 set_property(GLOBAL PROPERTY USE_FOLDERS OFF)
212 #-----------------------------------------------------------------------
213 # a macro to build the utilities used by CMake
214 # Simply to improve readability of the main script.
215 #-----------------------------------------------------------------------
216 macro (CMAKE_BUILD_UTILITIES)
217 #---------------------------------------------------------------------
218 # Create the KWIML library for CMake.
220 set(KWIML_HEADER_ROOT ${CMake_BINARY_DIR}/Utilities)
221 add_subdirectory(Utilities/KWIML)
223 #---------------------------------------------------------------------
224 # Create the kwsys library for CMake.
225 set(KWSYS_NAMESPACE cmsys)
226 set(KWSYS_USE_SystemTools 1)
227 set(KWSYS_USE_Directory 1)
228 set(KWSYS_USE_RegularExpression 1)
229 set(KWSYS_USE_Base64 1)
231 set(KWSYS_USE_Process 1)
232 set(KWSYS_USE_CommandLineArguments 1)
233 set(KWSYS_HEADER_ROOT ${CMake_BINARY_DIR}/Source)
234 set(KWSYS_INSTALL_DOC_DIR "${CMake_DOC_DEST}")
235 add_subdirectory(Source/kwsys)
236 set(kwsys_folder "Utilities/KWSys")
237 CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE} "${kwsys_folder}")
238 CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}_c "${kwsys_folder}")
240 CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestDynload "${kwsys_folder}")
241 CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestProcess "${kwsys_folder}")
242 CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestsC "${kwsys_folder}")
243 CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestsCxx "${kwsys_folder}")
244 CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestSharedForward "${kwsys_folder}")
247 #---------------------------------------------------------------------
248 # Setup third-party libraries.
249 # Everything in the tree should be able to include files from the
250 # Utilities directory.
252 ${CMake_BINARY_DIR}/Utilities
253 ${CMake_SOURCE_DIR}/Utilities
256 # check for the use of system libraries versus builtin ones
257 # (a macro defined in this file)
258 CMAKE_HANDLE_SYSTEM_LIBRARIES()
260 #---------------------------------------------------------------------
261 # Build zlib library for Curl, CMake, and CTest.
262 set(CMAKE_ZLIB_HEADER "cm_zlib.h")
263 if(CMAKE_USE_SYSTEM_ZLIB)
267 "CMAKE_USE_SYSTEM_ZLIB is ON but a zlib is not found!")
269 set(CMAKE_ZLIB_INCLUDES ${ZLIB_INCLUDE_DIR})
270 set(CMAKE_ZLIB_LIBRARIES ${ZLIB_LIBRARIES})
272 set(CMAKE_ZLIB_INCLUDES ${CMake_SOURCE_DIR}/Utilities)
273 set(CMAKE_ZLIB_LIBRARIES cmzlib)
274 add_subdirectory(Utilities/cmzlib)
275 CMAKE_SET_TARGET_FOLDER(cmzlib "Utilities/3rdParty")
278 #---------------------------------------------------------------------
279 # Build Curl library for CTest.
280 if(CMAKE_USE_SYSTEM_CURL)
284 "CMAKE_USE_SYSTEM_CURL is ON but a curl is not found!")
286 set(CMAKE_CURL_INCLUDES ${CURL_INCLUDE_DIRS})
287 set(CMAKE_CURL_LIBRARIES ${CURL_LIBRARIES})
289 set(CURL_SPECIAL_ZLIB_H ${CMAKE_ZLIB_HEADER})
290 set(CURL_SPECIAL_LIBZ_INCLUDES ${CMAKE_ZLIB_INCLUDES})
291 set(CURL_SPECIAL_LIBZ ${CMAKE_ZLIB_LIBRARIES})
292 option(CMAKE_BUILD_CURL_SHARED "Should curl be built shared" FALSE)
293 if(NOT CMAKE_BUILD_CURL_SHARED)
294 add_definitions(-DCURL_STATICLIB)
296 set(CMAKE_CURL_INCLUDES)
297 set(CMAKE_CURL_LIBRARIES cmcurl)
298 if(CMAKE_TESTS_CDASH_SERVER)
299 set(CMAKE_CURL_TEST_URL "${CMAKE_TESTS_CDASH_SERVER}/user.php")
301 add_subdirectory(Utilities/cmcurl)
302 CMAKE_SET_TARGET_FOLDER(cmcurl "Utilities/3rdParty")
303 CMAKE_SET_TARGET_FOLDER(LIBCURL "Utilities/3rdParty")
306 #---------------------------------------------------------------------
307 # Build Compress library for CTest.
308 set(CMAKE_COMPRESS_INCLUDES
309 "${CMAKE_CURRENT_BINARY_DIR}/Utilities/cmcompress")
310 set(CMAKE_COMPRESS_LIBRARIES "cmcompress")
311 add_subdirectory(Utilities/cmcompress)
312 CMAKE_SET_TARGET_FOLDER(cmcompress "Utilities/3rdParty")
313 if(CMAKE_USE_SYSTEM_BZIP2)
316 set(BZIP2_INCLUDE_DIR
317 "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmbzip2")
318 set(BZIP2_LIBRARIES cmbzip2)
319 add_subdirectory(Utilities/cmbzip2)
320 CMAKE_SET_TARGET_FOLDER(cmbzip2 "Utilities/3rdParty")
323 #---------------------------------------------------------------------
324 # Build or use system libarchive for CMake and CTest.
325 if(CMAKE_USE_SYSTEM_LIBARCHIVE)
326 if(EXISTS ${CMAKE_ROOT}/Modules/FindLibArchive.cmake) # added in 2.8.3
327 find_package(LibArchive)
329 include(${CMake_SOURCE_DIR}/Modules/FindLibArchive.cmake)
331 if(NOT LibArchive_FOUND)
332 message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBARCHIVE is ON but LibArchive is not found!")
334 set(CMAKE_TAR_INCLUDES ${LibArchive_INCLUDE_DIRS})
335 set(CMAKE_TAR_LIBRARIES ${LibArchive_LIBRARIES})
337 set(ZLIB_INCLUDE_DIR ${CMAKE_ZLIB_INCLUDES})
338 set(ZLIB_LIBRARY ${CMAKE_ZLIB_LIBRARIES})
339 add_definitions(-DLIBARCHIVE_STATIC)
340 set(ENABLE_NETTLE OFF CACHE INTERNAL "Enable use of Nettle")
341 set(ENABLE_OPENSSL ${CMAKE_USE_OPENSSL} CACHE INTERNAL "Enable use of OpenSSL")
342 set(ENABLE_XATTR OFF CACHE INTERNAL "Enable extended attribute support")
343 set(ENABLE_ACL OFF CACHE INTERNAL "Enable ACL support")
344 set(ENABLE_ICONV OFF CACHE INTERNAL "Enable iconv support")
345 add_subdirectory(Utilities/cmlibarchive)
346 CMAKE_SET_TARGET_FOLDER(cmlibarchive "Utilities/3rdParty")
347 set(CMAKE_TAR_LIBRARIES cmlibarchive ${BZIP2_LIBRARIES})
350 #---------------------------------------------------------------------
351 # Build expat library for CMake and CTest.
352 if(CMAKE_USE_SYSTEM_EXPAT)
356 "CMAKE_USE_SYSTEM_EXPAT is ON but a expat is not found!")
358 set(CMAKE_EXPAT_INCLUDES ${EXPAT_INCLUDE_DIRS})
359 set(CMAKE_EXPAT_LIBRARIES ${EXPAT_LIBRARIES})
361 set(CMAKE_EXPAT_INCLUDES)
362 set(CMAKE_EXPAT_LIBRARIES cmexpat)
363 add_subdirectory(Utilities/cmexpat)
364 CMAKE_SET_TARGET_FOLDER(cmexpat "Utilities/3rdParty")
367 #---------------------------------------------------------------------
368 # Build XMLRPC library for CMake and CTest.
370 find_package(XMLRPC QUIET REQUIRED libwww-client)
373 "CTEST_USE_XMLRPC is ON but xmlrpc is not found!")
375 set(CMAKE_XMLRPC_INCLUDES ${XMLRPC_INCLUDE_DIRS})
376 set(CMAKE_XMLRPC_LIBRARIES ${XMLRPC_LIBRARIES})
379 #---------------------------------------------------------------------
382 # there is a bug in the Syllable libraries which makes linking ccmake fail, Alex
383 if(NOT "${CMAKE_SYSTEM_NAME}" MATCHES syllable)
384 set(CURSES_NEED_NCURSES TRUE)
385 find_package(Curses QUIET)
387 option(BUILD_CursesDialog "Build the CMake Curses Dialog ccmake" ON)
389 message("Curses libraries were not found. Curses GUI for CMake will not be built.")
390 set(BUILD_CursesDialog 0)
393 set(BUILD_CursesDialog 0)
396 set(BUILD_CursesDialog 0)
398 if(BUILD_CursesDialog)
399 add_subdirectory(Source/CursesDialog/form)
403 #-----------------------------------------------------------------------
404 if(CMAKE_CXX_PLATFORM_ID MATCHES "OpenBSD")
405 execute_process(COMMAND ${CMAKE_CXX_COMPILER}
406 ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
407 OUTPUT_VARIABLE _GXX_VERSION
409 string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
410 _GXX_VERSION_SHORT ${_GXX_VERSION})
411 if(_GXX_VERSION_SHORT EQUAL 33)
413 "GXX 3.3 on OpenBSD is known to cause CPack to Crash.\n"
414 "Please use GXX 4.2 or greater to build CMake on OpenBSD\n"
415 "${CMAKE_CXX_COMPILER} version is: ${_GXX_VERSION}")
419 #-----------------------------------------------------------------------
420 # The main section of the CMakeLists file
422 #-----------------------------------------------------------------------
423 include(Source/CMakeVersion.cmake)
424 # Releases define a small tweak level.
425 if("${CMake_VERSION_TWEAK}" VERSION_LESS 20000000)
426 set(CMake_VERSION_IS_RELEASE 1)
427 set(CMake_VERSION_SOURCE "")
429 set(CMake_VERSION_IS_RELEASE 0)
430 include(${CMake_SOURCE_DIR}/Source/CMakeVersionSource.cmake)
433 # Compute the full version string.
434 set(CMake_VERSION ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH})
435 if(${CMake_VERSION_TWEAK} GREATER 0)
436 set(CMake_VERSION ${CMake_VERSION}.${CMake_VERSION_TWEAK})
439 set(CMake_VERSION ${CMake_VERSION}-rc${CMake_VERSION_RC})
441 if(CMake_VERSION_SOURCE)
442 set(CMake_VERSION ${CMake_VERSION}-${CMake_VERSION_SOURCE})
445 # Include the standard Dart testing module
447 include (${CMAKE_ROOT}/Modules/Dart.cmake)
449 # Set up test-time configuration.
450 set_directory_properties(PROPERTIES
451 TEST_INCLUDE_FILE "${CMake_BINARY_DIR}/Tests/EnforceConfig.cmake")
453 # where to write the resulting executables and libraries
454 set(BUILD_SHARED_LIBS OFF)
455 set(EXECUTABLE_OUTPUT_PATH "" CACHE INTERNAL "No configurable exe dir.")
456 set(LIBRARY_OUTPUT_PATH "" CACHE INTERNAL
457 "Where to put the libraries for CMake")
459 # The CMake executables usually do not need any rpath to run in the build or
461 set(CMAKE_SKIP_RPATH ON CACHE INTERNAL "CMake does not need RPATHs.")
463 set(CMAKE_DATA_DIR "/share/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}" CACHE STRING
464 "Install location for data (relative to prefix).")
465 set(CMAKE_DOC_DIR "/doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}" CACHE STRING
466 "Install location for documentation (relative to prefix).")
467 set(CMAKE_MAN_DIR "/man" CACHE STRING
468 "Install location for man pages (relative to prefix).")
469 mark_as_advanced(CMAKE_DATA_DIR CMAKE_DOC_DIR CMAKE_MAN_DIR)
470 if(CYGWIN AND EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
471 # Force doc, data and man dirs to conform to cygwin layout.
472 set(CMAKE_DOC_DIR "/share/doc/cmake-${CMake_VERSION}")
473 set(CMAKE_DATA_DIR "/share/cmake-${CMake_VERSION}")
474 set(CMAKE_MAN_DIR "/share/man")
475 # let the user know we just forced these values
476 message(STATUS "Setup for Cygwin packaging")
477 message(STATUS "Override cache CMAKE_DOC_DIR = ${CMAKE_DOC_DIR}")
478 message(STATUS "Override cache CMAKE_DATA_DIR = ${CMAKE_DATA_DIR}")
479 message(STATUS "Override cache CMAKE_MAN_DIR = ${CMAKE_MAN_DIR}")
481 string(REGEX REPLACE "^/" "" CMake_DATA_DEST "${CMAKE_DATA_DIR}")
482 string(REGEX REPLACE "^/" "" CMake_DOC_DEST "${CMAKE_DOC_DIR}")
485 include(${CMake_SOURCE_DIR}/Tests/CMakeInstall.cmake)
488 # include special compile flags for some compilers
489 include(CompileFlags.cmake)
491 # no clue why we are testing for this here
492 include(CheckSymbolExists)
493 CHECK_SYMBOL_EXISTS(unsetenv "stdlib.h" HAVE_UNSETENV)
494 CHECK_SYMBOL_EXISTS(environ "stdlib.h" HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE)
496 # CMAKE_TESTS_CDASH_SERVER: CDash server used by CMake/Tests.
498 # If not defined or "", this variable defaults to the server at
499 # http://www.cdash.org/CDash.
501 # If set explicitly to "NOTFOUND", curl tests and ctest tests that use
502 # the network are skipped.
504 # If set to something starting with "http://localhost/", the CDash is
505 # expected to be an instance of CDash used for CDash testing, pointing
506 # to a cdash4simpletest database. In these cases, the CDash dashboards
507 # should be run first.
509 if("x${CMAKE_TESTS_CDASH_SERVER}" STREQUAL "x")
510 set(CMAKE_TESTS_CDASH_SERVER "http://www.cdash.org/CDash")
513 # build the utilities (a macro defined in this file)
514 CMAKE_BUILD_UTILITIES()
516 # On NetBSD ncurses is required, since curses doesn't have the wsyncup()
517 # function. ncurses is installed via pkgsrc, so the library is in /usr/pkg/lib,
518 # which isn't in the default linker search path. So without RPATH ccmake
519 # doesn't run and the build doesn't succeed since ccmake is executed for
520 # generating the documentation.
521 if(BUILD_CursesDialog)
522 get_filename_component(_CURSES_DIR "${CURSES_LIBRARY}" PATH)
523 set(CURSES_NEED_RPATH FALSE)
524 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")
525 set(CURSES_NEED_RPATH TRUE)
531 set(CMAKE_BUNDLE_NAME
532 "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}-${CMake_VERSION_PATCH}")
533 set(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}")
534 # make sure CMAKE_INSTALL_PREFIX ends in /
535 string(LENGTH "${CMAKE_INSTALL_PREFIX}" LEN)
536 math(EXPR LEN "${LEN} -1" )
537 string(SUBSTRING "${CMAKE_INSTALL_PREFIX}" ${LEN} 1 ENDCH)
538 if(NOT "${ENDCH}" STREQUAL "/")
539 set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/")
541 set(CMAKE_INSTALL_PREFIX
542 "${CMAKE_INSTALL_PREFIX}${CMAKE_BUNDLE_NAME}.app/Contents")
545 set(QT_NEED_RPATH FALSE)
546 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")
547 set(QT_NEED_RPATH TRUE)
552 # The same might be true on other systems for other libraries.
553 # Then only enable RPATH if we have are building at least with cmake 2.4,
554 # since this one has much better RPATH features than cmake 2.2.
555 # The executables are then built with the RPATH for the libraries outside
556 # the build tree, which is both the build and the install RPATH.
558 if( CMAKE_USE_SYSTEM_CURL OR CMAKE_USE_SYSTEM_ZLIB
559 OR CMAKE_USE_SYSTEM_EXPAT OR CTEST_USE_XMLRPC OR CURSES_NEED_RPATH OR QT_NEED_RPATH)
560 set(CMAKE_SKIP_RPATH OFF CACHE INTERNAL "CMake built with RPATH.")
561 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
562 set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
567 # add the uninstall support
569 "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
570 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
572 add_custom_target(uninstall
573 "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
575 include (CMakeCPack.cmake)
577 # setup some Testing support (a macro defined in this file)
578 CMAKE_SETUP_TESTING()
580 "${CMAKE_CURRENT_SOURCE_DIR}/DartLocal.conf.in"
581 "${CMAKE_CURRENT_BINARY_DIR}/DartLocal.conf"
585 "Perform strict testing to record property and variable access. Can be used to report any undefined properties or variables" OFF)
586 mark_as_advanced(CMAKE_STRICT)
588 if(NOT CMake_VERSION_IS_RELEASE)
589 if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND
590 NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 4.2)
591 set(C_FLAGS_LIST -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts
592 -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security
593 -Wmissing-format-attribute -fno-common -Wundef
595 set(CXX_FLAGS_LIST -Wnon-virtual-dtor -Wcast-align -Wchar-subscripts -Wall -W
596 -Wshadow -Wpointer-arith -Wformat-security -Wundef
599 foreach(FLAG_LANG C CXX)
600 foreach(FLAG ${${FLAG_LANG}_FLAGS_LIST})
601 if(NOT " ${CMAKE_${FLAG_LANG}_FLAGS} " MATCHES " ${FLAG} ")
602 set(CMAKE_${FLAG_LANG}_FLAGS "${CMAKE_${FLAG_LANG}_FLAGS} ${FLAG}")
608 unset(CXX_FLAGS_LIST)
612 # build the remaining subdirectories
613 add_subdirectory(Source)
614 add_subdirectory(Utilities)
615 add_subdirectory(Tests)
618 CMAKE_SET_TARGET_FOLDER(CMakeLibTests "Tests")
620 CMAKE_SET_TARGET_FOLDER(cmw9xcom "Utilities/Win9xCompat")
621 CMAKE_SET_TARGET_FOLDER(documentation "Documentation")
624 add_test(SystemInformationNew "${CMAKE_CMAKE_COMMAND}"
625 --system-information -G "${CMAKE_TEST_GENERATOR}" )
627 # Install license file as it requires.
628 install(FILES Copyright.txt DESTINATION ${CMake_DOC_DEST})
630 # Install script directories.
632 DIRECTORY Modules Templates
633 DESTINATION "${CMake_DATA_DEST}"
634 FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
635 DIRECTORY_PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE
636 GROUP_READ GROUP_EXECUTE
637 WORLD_READ WORLD_EXECUTE
638 PATTERN "*.sh*" PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE
639 GROUP_READ GROUP_EXECUTE
640 WORLD_READ WORLD_EXECUTE
643 # process docs related install
644 add_subdirectory(Docs)
646 #-----------------------------------------------------------------------
647 # End of the main section of the CMakeLists file
648 #-----------------------------------------------------------------------
650 # As a special case when building CMake itself, CMake 2.8.0 and below
651 # look up EXECUTABLE_OUTPUT_PATH in the top-level CMakeLists.txt file
652 # to compute the location of the "cmake" executable. We set it here
653 # so that those CMake versions can find it. We wait until after all
654 # the add_subdirectory() calls to avoid affecting the subdirectories.
655 set(EXECUTABLE_OUTPUT_PATH ${CMake_BIN_DIR})