CMake L
CMake L
CMake L
See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
project(CMake)
unset(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX)
unset(CMAKE_USER_MAKE_RULES_OVERRIDE_C)
# Make sure we can find internal find_package modules only used for
# building CMake and not for shipping externally
list(INSERT CMAKE_MODULE_PATH 0 ${CMake_SOURCE_DIR}/Source/Modules)
if(CMAKE_BOOTSTRAP)
# Running from bootstrap script. Set local variable and remove from cache.
set(CMAKE_BOOTSTRAP 1)
unset(CMAKE_BOOTSTRAP CACHE)
endif()
if(CMake_TEST_HOST_CMAKE)
get_filename_component(CMake_TEST_EXTERNAL_CMAKE "${CMAKE_COMMAND}" DIRECTORY)
endif()
if(NOT CMake_TEST_EXTERNAL_CMAKE)
if(CMAKE_SYSTEM_NAME STREQUAL "HP-UX")
message(FATAL_ERROR
"CMake no longer compiles on HP-UX. See\n"
" https://gitlab.kitware.com/cmake/cmake/-/issues/17137\n"
"Use CMake 3.9 or lower instead."
)
endif()
set(CMake_BIN_DIR ${CMake_BINARY_DIR}/bin)
endif()
if(CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL)
if(CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL MATCHES "^3|2\\.1$")
set(USE_LGPL "${CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL}")
else()
set(USE_LGPL "2.1")
endif()
else()
set(USE_LGPL "")
endif()
if(NOT CMake_HAVE_CXX_UNIQUE_PTR)
message(FATAL_ERROR "The C++ compiler does not support C++11 (e.g.
std::unique_ptr).")
endif()
endif()
#-----------------------------------------------------------------------
# a macro to deal with system libraries, implemented as a macro
# simply to improve readability of the main script
#-----------------------------------------------------------------------
macro(CMAKE_HANDLE_SYSTEM_LIBRARIES)
include(CMakeDependentOption)
endmacro()
#-----------------------------------------------------------------------
# a macro to determine the generator and ctest executable to use
# for testing. Simply to improve readability of the main script.
#-----------------------------------------------------------------------
macro(CMAKE_SETUP_TESTING)
if(BUILD_TESTING)
set(CMAKE_TEST_SYSTEM_LIBRARIES 0)
foreach(util IN ITEMS CURL EXPAT ZLIB)
if(CMAKE_USE_SYSTEM_${util})
set(CMAKE_TEST_SYSTEM_LIBRARIES 1)
endif()
endforeach()
# Provide a way for Visual Studio Express users to turn OFF the new FOLDER
# organization feature. Default to ON for non-Express users. Express users must
# explicitly turn off this option to build CMake in the Express IDE...
#
option(CMAKE_USE_FOLDERS "Enable folder grouping of projects in IDEs." ON)
mark_as_advanced(CMAKE_USE_FOLDERS)
endif()
configure_file(.clang-tidy .clang-tidy COPYONLY)
#-----------------------------------------------------------------------
# a macro that only sets the FOLDER target property if it's
# "appropriate"
#-----------------------------------------------------------------------
macro(CMAKE_SET_TARGET_FOLDER tgt folder)
if(CMAKE_USE_FOLDERS)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if(MSVC AND TARGET ${tgt})
set_property(TARGET "${tgt}" PROPERTY FOLDER "${folder}")
endif()
else()
set_property(GLOBAL PROPERTY USE_FOLDERS OFF)
endif()
endmacro()
#-----------------------------------------------------------------------
if(NOT CMake_TEST_EXTERNAL_CMAKE)
if(CMAKE_CXX_PLATFORM_ID MATCHES "OpenBSD")
execute_process(COMMAND ${CMAKE_CXX_COMPILER}
${CMAKE_CXX_COMPILER_ARG1} -dumpversion
OUTPUT_VARIABLE _GXX_VERSION
)
string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
_GXX_VERSION_SHORT ${_GXX_VERSION})
if(_GXX_VERSION_SHORT EQUAL 33)
message(FATAL_ERROR
"GXX 3.3 on OpenBSD is known to cause CPack to Crash.\n"
"Please use GXX 4.2 or greater to build CMake on OpenBSD\n"
"${CMAKE_CXX_COMPILER} version is: ${_GXX_VERSION}")
endif()
endif()
endif()
#-----------------------------------------------------------------------
# The main section of the CMakeLists file
#
#-----------------------------------------------------------------------
include(Source/CMakeVersion.cmake)
include(CTest)
if(NOT CMake_TEST_EXTERNAL_CMAKE)
# where to write the resulting executables and libraries
set(BUILD_SHARED_LIBS OFF)
set(EXECUTABLE_OUTPUT_PATH "" CACHE INTERNAL "No configurable exe dir.")
set(LIBRARY_OUTPUT_PATH "" CACHE INTERNAL
"Where to put the libraries for CMake")
if(BUILD_TESTING)
include(${CMake_SOURCE_DIR}/Tests/CMakeInstall.cmake)
endif()
if(CMake_TEST_EXTERNAL_CMAKE)
set(KWIML_TEST_ENABLE 1)
add_subdirectory(Utilities/KWIML)
endif()
if(NOT CMake_TEST_EXTERNAL_CMAKE)
find_package(Threads)
# build the utilities
include(CMakeBuildUtilities)
if(BUILD_QtDialog)
if(APPLE)
set(CMAKE_BUNDLE_VERSION
"${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}")
set(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}")
# make sure CMAKE_INSTALL_PREFIX ends in /
if(NOT CMAKE_INSTALL_PREFIX MATCHES "/$")
string(APPEND CMAKE_INSTALL_PREFIX "/")
endif()
string(APPEND CMAKE_INSTALL_PREFIX "CMake.app/Contents")
endif()
endif()
if(UNIX)
# Install executables with the RPATH set for libraries outside the build tree.
# This is also suitable for binaries in the build tree. Avoid re-link on
install.
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON CACHE BOOL "Install with RPATH set to
find custom-built libraries.")
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL "Build with RPATH set to match
install-tree RPATH.")
mark_as_advanced(CMAKE_INSTALL_RPATH_USE_LINK_PATH
CMAKE_BUILD_WITH_INSTALL_RPATH)
endif()
include(CMakeCPack.cmake)
endif()
if(NOT CMake_TEST_EXTERNAL_CMAKE)
if(NOT CMake_VERSION_IS_RELEASE)
if((CMAKE_C_COMPILER_ID STREQUAL "GNU" AND
NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 4.2) OR
(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND
NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 3.0 AND
NOT "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC") OR
CMAKE_C_COMPILER_ID STREQUAL "AppleClang" OR
CMAKE_C_COMPILER_ID STREQUAL "LCC")
set(C_FLAGS_LIST -Wcast-align -Werror-implicit-function-declaration -Wchar-
subscripts
-Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security
-Wmissing-format-attribute -fno-common -Wundef
)
set(CXX_FLAGS_LIST -Wnon-virtual-dtor -Wcast-align -Wchar-subscripts -Wall -W
-Wshadow -Wpointer-arith -Wformat-security -Wundef
)
foreach(FLAG_LANG IN ITEMS C CXX)
foreach(FLAG IN LISTS ${FLAG_LANG}_FLAGS_LIST)
if(NOT " ${CMAKE_${FLAG_LANG}_FLAGS} " MATCHES " ${FLAG} ")
string(APPEND CMAKE_${FLAG_LANG}_FLAGS " ${FLAG}")
endif()
endforeach()
endforeach()
unset(C_FLAGS_LIST)
unset(CXX_FLAGS_LIST)
endif()
endif()
add_subdirectory(Tests)
if(NOT CMake_TEST_EXTERNAL_CMAKE)
if(BUILD_TESTING)
CMAKE_SET_TARGET_FOLDER(CMakeLibTests "Tests")
endif()
if(TARGET documentation)
CMAKE_SET_TARGET_FOLDER(documentation "Documentation")
endif()
endif()
if(BUILD_TESTING)
add_test(SystemInformationNew "${CMAKE_CMAKE_COMMAND}"
--system-information -G "${CMAKE_GENERATOR}"
)
endif()
if(NOT CMake_TEST_EXTERNAL_CMAKE)
# Install license file as it requires.
install(FILES Copyright.txt DESTINATION ${CMAKE_DOC_DIR})