1 # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
4 cmake_minimum_required(VERSION 3.13...3.30 FATAL_ERROR)
5 set(CMAKE_USER_MAKE_RULES_OVERRIDE_C ${CMAKE_CURRENT_SOURCE_DIR}/Source/Modules/OverrideC.cmake)
6 set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX ${CMAKE_CURRENT_SOURCE_DIR}/Source/Modules/OverrideCXX.cmake)
9 unset(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX)
10 unset(CMAKE_USER_MAKE_RULES_OVERRIDE_C)
12 # FIXME: This block should go away after a transition period.
13 if(MSVC AND NOT CMAKE_VERSION VERSION_LESS 3.15)
14 # Filter out MSVC runtime library flags that may have come from
15 # the cache of an existing build tree or from scripts.
16 foreach(l IN ITEMS C CXX)
17 foreach(c IN ITEMS DEBUG MINSIZEREL RELEASE RELWITHDEBINFO)
18 string(REGEX REPLACE "[-/]M[DT]d?( |$)" "" "CMAKE_${l}_FLAGS_${c}" "${CMAKE_${l}_FLAGS_${c}}")
23 # Make sure we can find internal find_package modules only used for
24 # building CMake and not for shipping externally
25 list(INSERT CMAKE_MODULE_PATH 0 ${CMake_SOURCE_DIR}/Source/Modules)
28 # Running from bootstrap script. Set local variable and remove from cache.
29 set(CMAKE_BOOTSTRAP 1)
30 unset(CMAKE_BOOTSTRAP CACHE)
33 if(CMake_TEST_HOST_CMAKE)
34 get_filename_component(CMake_TEST_EXTERNAL_CMAKE "${CMAKE_COMMAND}" DIRECTORY)
37 if(NOT CMake_TEST_EXTERNAL_CMAKE)
38 if(CMAKE_SYSTEM_NAME STREQUAL "HP-UX")
40 "CMake no longer compiles on HP-UX. See\n"
41 " https://gitlab.kitware.com/cmake/cmake/-/issues/17137\n"
42 "Use CMake 3.9 or lower instead."
46 set(CMake_BIN_DIR ${CMake_BINARY_DIR}/bin)
49 if(CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL)
50 if(CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL MATCHES "^3|2\\.1$")
51 set(USE_LGPL "${CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL}")
59 # Use most-recent available language dialects with GNU and Clang
60 if(NOT DEFINED CMAKE_C_STANDARD AND NOT CMake_NO_C_STANDARD)
61 include(${CMake_SOURCE_DIR}/Source/Checks/cm_c11_thread_local.cmake)
62 if(NOT CMake_C11_THREAD_LOCAL_BROKEN)
63 set(CMAKE_C_STANDARD 11)
65 set(CMAKE_C_STANDARD 99)
68 if(NOT DEFINED CMAKE_CXX_STANDARD AND NOT CMake_NO_CXX_STANDARD)
69 if(CMAKE_CXX_COMPILER_ID STREQUAL SunPro AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.14)
70 set(CMAKE_CXX_STANDARD 98)
72 include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx17_check.cmake)
73 if(NOT CMake_CXX17_BROKEN)
74 set(CMAKE_CXX_STANDARD 17)
76 include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx14_check.cmake)
77 if(NOT CMake_CXX14_BROKEN)
78 set(CMAKE_CXX_STANDARD 14)
80 set(CMAKE_CXX_STANDARD 11)
85 if(NOT CMake_TEST_EXTERNAL_CMAKE)
86 # include special compile flags for some compilers
87 include(CompileFlags.cmake)
89 # check for available C++ features
90 include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx_features.cmake)
92 if(NOT CMake_HAVE_CXX_UNIQUE_PTR)
93 message(FATAL_ERROR "The C++ compiler does not support C++11 (e.g. std::unique_ptr).")
97 # Inform STL library header wrappers whether to use system versions.
98 configure_file(Utilities/std/cmSTL.hxx.in Utilities/cmSTL.hxx @ONLY)
100 # set the internal encoding of CMake to UTF-8
101 set(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_UTF8)
103 # option to use COMPONENT with install command
104 option(CMake_INSTALL_COMPONENTS "Using components when installing" OFF)
105 mark_as_advanced(CMake_INSTALL_COMPONENTS)
106 macro(CMake_OPTIONAL_COMPONENT NAME)
107 if(CMake_INSTALL_COMPONENTS)
108 set(COMPONENT COMPONENT ${NAME})
114 # option to disable installing 3rd-party dependencies
115 option(CMake_INSTALL_DEPENDENCIES
116 "Whether to install 3rd-party runtime dependencies" OFF)
117 mark_as_advanced(CMake_INSTALL_DEPENDENCIES)
119 # option to build reference for CMake developers
120 option(CMake_BUILD_DEVELOPER_REFERENCE
121 "Build CMake Developer Reference" OFF)
122 mark_as_advanced(CMake_BUILD_DEVELOPER_REFERENCE)
124 # option to build using interprocedural optimizations (IPO/LTO)
125 option(CMake_BUILD_LTO "Compile CMake with link-time optimization if supported" OFF)
127 include(CheckIPOSupported)
128 check_ipo_supported(RESULT HAVE_IPO)
130 set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
134 option(CMake_BUILD_PCH "Compile CMake with precompiled headers" OFF)
136 # Check whether to build support for the debugger mode.
137 if(NOT CMake_TEST_EXTERNAL_CMAKE)
138 if(NOT DEFINED CMake_ENABLE_DEBUGGER)
139 # The debugger uses cppdap, which does not compile everywhere.
140 if(CMAKE_SYSTEM_NAME MATCHES "Windows|Darwin|Linux|BSD|DragonFly|CYGWIN|MSYS"
141 AND NOT (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.16)
142 AND NOT (CMAKE_CXX_COMPILER_ID STREQUAL "XLClang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16.1)
143 AND NOT (CMAKE_CXX_COMPILER_ID STREQUAL "LCC" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 1.23)
145 set(CMake_ENABLE_DEBUGGER 1)
147 set(CMake_ENABLE_DEBUGGER 0)
151 set(CMake_ENABLE_DEBUGGER 0)
154 #-----------------------------------------------------------------------
155 # a macro to deal with system libraries, implemented as a macro
156 # simply to improve readability of the main script
157 #-----------------------------------------------------------------------
158 macro(CMAKE_HANDLE_SYSTEM_LIBRARIES)
159 include(CMakeDependentOption)
161 # Allow the user to enable/disable all system utility library options by
162 # defining CMAKE_USE_SYSTEM_LIBRARIES or CMAKE_USE_SYSTEM_LIBRARY_${util}.
163 set(UTILITIES BZIP2 CPPDAP CURL EXPAT FORM JSONCPP LIBARCHIVE LIBLZMA LIBRHASH LIBUV NGHTTP2 ZLIB ZSTD)
164 foreach(util IN LISTS UTILITIES)
165 if(NOT DEFINED CMAKE_USE_SYSTEM_LIBRARY_${util}
166 AND DEFINED CMAKE_USE_SYSTEM_LIBRARIES)
167 set(CMAKE_USE_SYSTEM_LIBRARY_${util} "${CMAKE_USE_SYSTEM_LIBRARIES}")
169 if(DEFINED CMAKE_USE_SYSTEM_LIBRARY_${util})
170 if(CMAKE_USE_SYSTEM_LIBRARY_${util})
171 set(CMAKE_USE_SYSTEM_LIBRARY_${util} ON)
173 set(CMAKE_USE_SYSTEM_LIBRARY_${util} OFF)
176 unset(CMAKE_USE_SYSTEM_LIBRARY_${util} CACHE)
178 string(TOLOWER "${util}" lutil)
179 set(CMAKE_USE_SYSTEM_${util} "${CMAKE_USE_SYSTEM_LIBRARY_${util}}"
180 CACHE BOOL "Use system-installed ${lutil}" FORCE)
181 elseif(util STREQUAL "CURL" AND APPLE)
182 # macOS provides a curl with backends configured by Apple.
183 set(CMAKE_USE_SYSTEM_LIBRARY_${util} ON)
185 set(CMAKE_USE_SYSTEM_LIBRARY_${util} OFF)
189 unset(CMAKE_USE_SYSTEM_LIBRARIES CACHE)
192 # Optionally use system utility libraries.
193 option(CMAKE_USE_SYSTEM_LIBARCHIVE "Use system-installed libarchive" "${CMAKE_USE_SYSTEM_LIBRARY_LIBARCHIVE}")
194 if(CMake_ENABLE_DEBUGGER)
195 option(CMAKE_USE_SYSTEM_CPPDAP "Use system-installed cppdap" "${CMAKE_USE_SYSTEM_LIBRARY_CPPDAP}")
197 option(CMAKE_USE_SYSTEM_CURL "Use system-installed curl" "${CMAKE_USE_SYSTEM_LIBRARY_CURL}")
198 option(CMAKE_USE_SYSTEM_EXPAT "Use system-installed expat" "${CMAKE_USE_SYSTEM_LIBRARY_EXPAT}")
199 cmake_dependent_option(CMAKE_USE_SYSTEM_ZLIB "Use system-installed zlib"
200 "${CMAKE_USE_SYSTEM_LIBRARY_ZLIB}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE;NOT CMAKE_USE_SYSTEM_CURL" ON)
201 cmake_dependent_option(CMAKE_USE_SYSTEM_BZIP2 "Use system-installed bzip2"
202 "${CMAKE_USE_SYSTEM_LIBRARY_BZIP2}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE" ON)
203 cmake_dependent_option(CMAKE_USE_SYSTEM_ZSTD "Use system-installed zstd"
204 "${CMAKE_USE_SYSTEM_LIBRARY_ZSTD}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE" ON)
205 cmake_dependent_option(CMAKE_USE_SYSTEM_LIBLZMA "Use system-installed liblzma"
206 "${CMAKE_USE_SYSTEM_LIBRARY_LIBLZMA}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE" ON)
207 cmake_dependent_option(CMAKE_USE_SYSTEM_NGHTTP2 "Use system-installed nghttp2"
208 "${CMAKE_USE_SYSTEM_LIBRARY_NGHTTP2}" "NOT CMAKE_USE_SYSTEM_CURL" ON)
209 option(CMAKE_USE_SYSTEM_FORM "Use system-installed libform" "${CMAKE_USE_SYSTEM_LIBRARY_FORM}")
210 cmake_dependent_option(CMAKE_USE_SYSTEM_JSONCPP "Use system-installed jsoncpp"
211 "${CMAKE_USE_SYSTEM_LIBRARY_JSONCPP}" "NOT CMAKE_USE_SYSTEM_CPPDAP" ON)
212 option(CMAKE_USE_SYSTEM_LIBRHASH "Use system-installed librhash" "${CMAKE_USE_SYSTEM_LIBRARY_LIBRHASH}")
213 option(CMAKE_USE_SYSTEM_LIBUV "Use system-installed libuv" "${CMAKE_USE_SYSTEM_LIBRARY_LIBUV}")
215 # For now use system KWIML only if explicitly requested rather
216 # than activating via the general system libs options.
217 option(CMAKE_USE_SYSTEM_KWIML "Use system-installed KWIML" OFF)
218 mark_as_advanced(CMAKE_USE_SYSTEM_KWIML)
220 # Mention to the user what system libraries are being used.
221 if(CMAKE_USE_SYSTEM_CURL)
222 # Avoid messaging about curl-only dependencies.
223 list(REMOVE_ITEM UTILITIES NGHTTP2)
225 foreach(util IN LISTS UTILITIES ITEMS KWIML)
226 if(CMAKE_USE_SYSTEM_${util})
227 message(STATUS "Using system-installed ${util}")
231 # Inform utility library header wrappers whether to use system versions.
232 configure_file(Utilities/cmThirdParty.h.in Utilities/cmThirdParty.h @ONLY)
236 #-----------------------------------------------------------------------
237 # a macro to determine the generator and ctest executable to use
238 # for testing. Simply to improve readability of the main script.
239 #-----------------------------------------------------------------------
240 macro(CMAKE_SETUP_TESTING)
242 set(CMAKE_TEST_SYSTEM_LIBRARIES 0)
243 foreach(util IN ITEMS CURL EXPAT ZLIB)
244 if(CMAKE_USE_SYSTEM_${util})
245 set(CMAKE_TEST_SYSTEM_LIBRARIES 1)
249 # This variable is set by cmake, however to
250 # test cmake we want to make sure that
251 # the ctest from this cmake is used for testing
252 # and not the ctest from the cmake building and testing
254 if(CMake_TEST_EXTERNAL_CMAKE)
255 set(CMAKE_CTEST_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/ctest")
256 set(CMAKE_CMAKE_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/cmake")
257 set(CMAKE_CPACK_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/cpack")
258 foreach(exe IN ITEMS cmake ctest cpack)
259 add_executable(${exe} IMPORTED)
260 set_property(TARGET ${exe} PROPERTY IMPORTED_LOCATION ${CMake_TEST_EXTERNAL_CMAKE}/${exe})
263 set(CMAKE_CTEST_COMMAND "${CMake_BIN_DIR}/ctest")
264 set(CMAKE_CMAKE_COMMAND "${CMake_BIN_DIR}/cmake")
265 set(CMAKE_CPACK_COMMAND "${CMake_BIN_DIR}/cpack")
269 # configure some files for testing
270 configure_file(Tests/.NoDartCoverage Tests/.NoDartCoverage)
271 configure_file(CTestCustom.cmake.in CTestCustom.cmake @ONLY)
275 # Provide a way for Visual Studio Express users to turn OFF the new FOLDER
276 # organization feature. Default to ON for non-Express users. Express users must
277 # explicitly turn off this option to build CMake in the Express IDE...
279 option(CMAKE_USE_FOLDERS "Enable folder grouping of projects in IDEs." ON)
280 mark_as_advanced(CMAKE_USE_FOLDERS)
283 option(CMake_RUN_CLANG_TIDY "Run clang-tidy with the compiler." OFF)
284 if(CMake_RUN_CLANG_TIDY)
285 if(CMake_SOURCE_DIR STREQUAL CMake_BINARY_DIR)
286 message(FATAL_ERROR "CMake_RUN_CLANG_TIDY requires an out-of-source build!")
288 find_program(CLANG_TIDY_COMMAND NAMES clang-tidy)
289 if(NOT CLANG_TIDY_COMMAND)
290 message(FATAL_ERROR "CMake_RUN_CLANG_TIDY is ON but clang-tidy is not found!")
292 set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
294 option(CMake_USE_CLANG_TIDY_MODULE "Use CMake's clang-tidy module." OFF)
295 if(CMake_USE_CLANG_TIDY_MODULE)
296 find_library(CMake_CLANG_TIDY_MODULE NAMES cmake-clang-tidy-module DOC "Location of the clang-tidy module")
297 if(NOT CMake_CLANG_TIDY_MODULE)
298 message(FATAL_ERROR "CMake_USE_CLANG_TIDY_MODULE is ON but cmake-clang-tidy-module is not found!")
300 list(APPEND CMAKE_CXX_CLANG_TIDY "--load=${CMake_CLANG_TIDY_MODULE}")
301 set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMake_CLANG_TIDY_MODULE}")
304 set(CMake_CLANG_TIDY_EXPORT_FIXES_DIR "" CACHE PATH "Directory to put clang-tidy fix files in.")
305 mark_as_advanced(CMake_CLANG_TIDY_EXPORT_FIXES_DIR)
306 if(CMake_CLANG_TIDY_EXPORT_FIXES_DIR)
307 if(NOT IS_ABSOLUTE "${CMake_CLANG_TIDY_EXPORT_FIXES_DIR}")
308 message(FATAL_ERROR "CMake_CLANG_TIDY_EXPORT_FIXES_DIR must be an absolute path!")
310 set(CMAKE_CXX_CLANG_TIDY_EXPORT_FIXES_DIR "${CMake_CLANG_TIDY_EXPORT_FIXES_DIR}")
313 # Create a preprocessor definition that depends on .clang-tidy content so
314 # the compile command will change when .clang-tidy changes. This ensures
315 # that a subsequent build re-runs clang-tidy on all sources even if they
316 # do not otherwise need to be recompiled. Nothing actually uses this
317 # definition. We add it to targets on which we run clang-tidy just to
318 # get the build dependency on the .clang-tidy file.
319 file(SHA1 ${CMAKE_CURRENT_SOURCE_DIR}/.clang-tidy clang_tidy_sha1)
320 set(CLANG_TIDY_DEFINITIONS "CLANG_TIDY_SHA1=${clang_tidy_sha1}")
321 unset(clang_tidy_sha1)
322 if(CMake_USE_CLANG_TIDY_MODULE)
323 file(SHA1 "${CMake_CLANG_TIDY_MODULE}" clang_tidy_module_sha1)
324 list(APPEND CLANG_TIDY_DEFINITIONS "CLANG_TIDY_MODULE_SHA1=${clang_tidy_module_sha1}")
325 unset(clang_tidy_module_sha1)
329 configure_file(.clang-tidy .clang-tidy COPYONLY)
332 option(CMake_RUN_IWYU "Run include-what-you-use with the compiler." OFF)
335 message(FATAL_ERROR "CMake_RUN_IWYU and CMake_BUILD_PCH are ON, but they are incompatible!")
337 find_program(IWYU_COMMAND NAMES include-what-you-use iwyu)
339 message(FATAL_ERROR "CMake_RUN_IWYU is ON but include-what-you-use is not found!")
341 set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE
342 "${IWYU_COMMAND};-Xiwyu;--mapping_file=${CMake_SOURCE_DIR}/Utilities/IWYU/mapping.imp;-w")
343 option(CMake_IWYU_VERBOSE "Run include-what-you-use in verbose mode" OFF)
344 if (CMake_IWYU_VERBOSE)
345 list(APPEND CMAKE_CXX_INCLUDE_WHAT_YOU_USE
348 list(APPEND CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${CMake_IWYU_OPTIONS})
352 #-----------------------------------------------------------------------
353 # a macro that only sets the FOLDER target property if it's
355 #-----------------------------------------------------------------------
356 macro(CMAKE_SET_TARGET_FOLDER tgt folder)
357 if(CMAKE_USE_FOLDERS)
358 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
359 if(MSVC AND TARGET ${tgt})
360 set_property(TARGET "${tgt}" PROPERTY FOLDER "${folder}")
363 set_property(GLOBAL PROPERTY USE_FOLDERS OFF)
367 #-----------------------------------------------------------------------
368 if(NOT CMake_TEST_EXTERNAL_CMAKE)
369 if(CMAKE_CXX_PLATFORM_ID MATCHES "OpenBSD")
370 execute_process(COMMAND ${CMAKE_CXX_COMPILER}
371 ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
372 OUTPUT_VARIABLE _GXX_VERSION
374 string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
375 _GXX_VERSION_SHORT ${_GXX_VERSION})
376 if(_GXX_VERSION_SHORT EQUAL 33)
378 "GXX 3.3 on OpenBSD is known to cause CPack to Crash.\n"
379 "Please use GXX 4.2 or greater to build CMake on OpenBSD\n"
380 "${CMAKE_CXX_COMPILER} version is: ${_GXX_VERSION}")
385 #-----------------------------------------------------------------------
386 # The main section of the CMakeLists file
388 #-----------------------------------------------------------------------
389 include(Source/CMakeVersion.cmake)
393 # Set up test-time configuration.
394 set_directory_properties(PROPERTIES
395 TEST_INCLUDE_FILE "${CMake_BINARY_DIR}/Tests/EnforceConfig.cmake")
397 if(NOT CMake_TEST_EXTERNAL_CMAKE)
398 # where to write the resulting executables and libraries
399 set(BUILD_SHARED_LIBS OFF)
400 set(EXECUTABLE_OUTPUT_PATH "" CACHE INTERNAL "No configurable exe dir.")
401 set(LIBRARY_OUTPUT_PATH "" CACHE INTERNAL
402 "Where to put the libraries for CMake")
404 # Load install destinations.
405 include(Source/CMakeInstallDestinations.cmake)
408 include(${CMake_SOURCE_DIR}/Tests/CMakeInstall.cmake)
411 # Checks for cmSystemTools.
414 set(HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE 1)
416 include(CheckSymbolExists)
417 check_symbol_exists(unsetenv "stdlib.h" HAVE_UNSETENV)
418 check_symbol_exists(environ "stdlib.h" HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE)
422 # CMAKE_TESTS_CDASH_SERVER: CDash server used by CMake/Tests.
424 # If not defined or "", this variable defaults to the server at
425 # "http://open.cdash.org".
427 # If set explicitly to "NOTFOUND", curl tests and ctest tests that use
428 # the network are skipped.
430 # If set to something starting with "http://localhost/", the CDash is
431 # expected to be an instance of CDash used for CDash testing, pointing
432 # to a cdash4simpletest database. In these cases, the CDash dashboards
433 # should be run first.
435 if("x${CMAKE_TESTS_CDASH_SERVER}" STREQUAL "x" AND NOT CMake_TEST_NO_NETWORK)
436 set(CMAKE_TESTS_CDASH_SERVER "http://open.cdash.org")
439 if(CMake_TEST_EXTERNAL_CMAKE)
440 set(KWIML_TEST_ENABLE 1)
441 add_subdirectory(Utilities/KWIML)
444 if(NOT CMake_TEST_EXTERNAL_CMAKE)
445 find_package(Threads)
446 # build the utilities
447 include(CMakeBuildUtilities)
451 set(CMAKE_BUNDLE_VERSION
452 "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}")
453 set(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}")
454 # make sure CMAKE_INSTALL_PREFIX ends in /
455 if(NOT CMAKE_INSTALL_PREFIX MATCHES "/$")
456 string(APPEND CMAKE_INSTALL_PREFIX "/")
458 string(APPEND CMAKE_INSTALL_PREFIX "CMake.app/Contents")
463 # Install executables with the RPATH set for libraries outside the build tree.
464 # This is also suitable for binaries in the build tree. Avoid re-link on install.
465 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON CACHE BOOL "Install with RPATH set to find custom-built libraries.")
466 set(CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL "Build with RPATH set to match install-tree RPATH.")
467 mark_as_advanced(CMAKE_INSTALL_RPATH_USE_LINK_PATH CMAKE_BUILD_WITH_INSTALL_RPATH)
470 # add the uninstall support
471 configure_file(cmake_uninstall.cmake.in cmake_uninstall.cmake @ONLY)
472 add_custom_target(uninstall
473 "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
475 include(CMakeCPack.cmake)
479 # setup some Testing support (a macro defined in this file)
480 CMAKE_SETUP_TESTING()
482 if(NOT CMake_TEST_EXTERNAL_CMAKE)
483 if(NOT CMake_VERSION_IS_RELEASE)
484 if((CMAKE_C_COMPILER_ID STREQUAL "GNU" AND
485 NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 4.2) OR
486 (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND
487 NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 3.0 AND
488 NOT "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC") OR
489 CMAKE_C_COMPILER_ID STREQUAL "AppleClang" OR
490 CMAKE_C_COMPILER_ID STREQUAL "LCC")
491 set(C_FLAGS_LIST -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts
492 -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security
493 -Wmissing-format-attribute -fno-common -Wundef
495 set(CXX_FLAGS_LIST -Wnon-virtual-dtor -Wcast-align -Wchar-subscripts -Wall -W
496 -Wshadow -Wpointer-arith -Wformat-security -Wundef
499 foreach(FLAG_LANG IN ITEMS C CXX)
500 foreach(FLAG IN LISTS ${FLAG_LANG}_FLAGS_LIST)
501 if(NOT " ${CMAKE_${FLAG_LANG}_FLAGS} " MATCHES " ${FLAG} ")
502 string(APPEND CMAKE_${FLAG_LANG}_FLAGS " ${FLAG}")
508 unset(CXX_FLAGS_LIST)
512 # build the remaining subdirectories
513 add_subdirectory(Source)
514 add_subdirectory(Utilities)
517 add_subdirectory(Tests)
519 if(NOT CMake_TEST_EXTERNAL_CMAKE)
521 CMAKE_SET_TARGET_FOLDER(CMakeLibTests "Tests")
523 if(TARGET documentation)
524 CMAKE_SET_TARGET_FOLDER(documentation "Documentation")
529 add_test(SystemInformationNew "${CMAKE_CMAKE_COMMAND}"
530 --system-information -G "${CMAKE_GENERATOR}"
534 if(NOT CMake_TEST_EXTERNAL_CMAKE)
535 # Install license file as it requires.
536 install(FILES Copyright.txt DESTINATION ${CMAKE_DOC_DIR})
538 # Install script directories.
540 DIRECTORY Help Modules Templates
541 DESTINATION ${CMAKE_DATA_DIR}
542 FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
543 DIRECTORY_PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE
544 GROUP_READ GROUP_EXECUTE
545 WORLD_READ WORLD_EXECUTE
546 PATTERN "*.sh*" PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE
547 GROUP_READ GROUP_EXECUTE
548 WORLD_READ WORLD_EXECUTE
549 REGEX "/(ExportImportList|cpp)$"
550 PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE
551 GROUP_READ GROUP_EXECUTE
552 WORLD_READ WORLD_EXECUTE
553 REGEX "Help/(dev|guide)($|/)" EXCLUDE
556 # Install auxiliary files integrating with other tools.
557 add_subdirectory(Auxiliary)
559 # Optionally sign installed binaries.
560 if(CMake_INSTALL_SIGNTOOL)
561 configure_file(Source/CMakeInstallSignTool.cmake.in Source/CMakeInstallSignTool.cmake @ONLY)
562 install(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/Source/CMakeInstallSignTool.cmake)