diff options
33 files changed, 917 insertions, 929 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d77dfc..a4f533d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,8 +17,8 @@ unset(CMAKE_USER_MAKE_RULES_OVERRIDE_C) if(MSVC AND NOT CMAKE_VERSION VERSION_LESS 3.15) # Filter out MSVC runtime library flags that may have come from # the cache of an existing build tree or from scripts. - foreach(l C CXX) - foreach(c DEBUG MINSIZEREL RELEASE RELWITHDEBINFO) + foreach(l IN ITEMS C CXX) + foreach(c IN ITEMS DEBUG MINSIZEREL RELEASE RELWITHDEBINFO) string(REGEX REPLACE "[-/]M[DT]d?( |$)" "" "CMAKE_${l}_FLAGS_${c}" "${CMAKE_${l}_FLAGS_${c}}") endforeach() endforeach() @@ -81,7 +81,7 @@ if(NOT DEFINED CMAKE_C_STANDARD AND NOT CMake_NO_C_STANDARD) endif() endif() if(NOT DEFINED CMAKE_CXX_STANDARD AND NOT CMake_NO_CXX_STANDARD) - if (CMAKE_CXX_COMPILER_ID STREQUAL SunPro AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.14) + if(CMAKE_CXX_COMPILER_ID STREQUAL SunPro AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.14) set(CMAKE_CXX_STANDARD 98) else() if(NOT CMAKE_VERSION VERSION_LESS 3.8) @@ -114,9 +114,7 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) endif() # Inform STL library header wrappers whether to use system versions. -configure_file(${CMake_SOURCE_DIR}/Utilities/std/cmSTL.hxx.in - ${CMake_BINARY_DIR}/Utilities/cmSTL.hxx - @ONLY) +configure_file(Utilities/std/cmSTL.hxx.in Utilities/cmSTL.hxx @ONLY) # set the internal encoding of CMake to UTF-8 set(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_UTF8) @@ -143,7 +141,7 @@ option(CMake_BUILD_DEVELOPER_REFERENCE mark_as_advanced(CMake_BUILD_DEVELOPER_REFERENCE) # option to build using interprocedural optimizations (IPO/LTO) -if (NOT CMAKE_VERSION VERSION_LESS 3.12.2) +if(NOT CMAKE_VERSION VERSION_LESS 3.12.2) option(CMake_BUILD_LTO "Compile CMake with link-time optimization if supported" OFF) if(CMake_BUILD_LTO) include(CheckIPOSupported) @@ -165,7 +163,7 @@ macro(CMAKE_HANDLE_SYSTEM_LIBRARIES) # Allow the user to enable/disable all system utility library options by # defining CMAKE_USE_SYSTEM_LIBRARIES or CMAKE_USE_SYSTEM_LIBRARY_${util}. set(UTILITIES BZIP2 CURL EXPAT FORM JSONCPP LIBARCHIVE LIBLZMA LIBRHASH LIBUV NGHTTP2 ZLIB ZSTD) - foreach(util ${UTILITIES}) + foreach(util IN LISTS UTILITIES) if(NOT DEFINED CMAKE_USE_SYSTEM_LIBRARY_${util} AND DEFINED CMAKE_USE_SYSTEM_LIBRARIES) set(CMAKE_USE_SYSTEM_LIBRARY_${util} "${CMAKE_USE_SYSTEM_LIBRARIES}") @@ -215,16 +213,14 @@ macro(CMAKE_HANDLE_SYSTEM_LIBRARIES) mark_as_advanced(CMAKE_USE_SYSTEM_KWIML) # Mention to the user what system libraries are being used. - foreach(util ${UTILITIES} KWIML) + foreach(util IN LISTS UTILITIES ITEMS KWIML) if(CMAKE_USE_SYSTEM_${util}) message(STATUS "Using system-installed ${util}") endif() endforeach() # Inform utility library header wrappers whether to use system versions. - configure_file(${CMake_SOURCE_DIR}/Utilities/cmThirdParty.h.in - ${CMake_BINARY_DIR}/Utilities/cmThirdParty.h - @ONLY) + configure_file(Utilities/cmThirdParty.h.in Utilities/cmThirdParty.h @ONLY) endmacro() @@ -235,7 +231,7 @@ endmacro() macro(CMAKE_SETUP_TESTING) if(BUILD_TESTING) set(CMAKE_TEST_SYSTEM_LIBRARIES 0) - foreach(util CURL EXPAT ZLIB) + foreach(util IN ITEMS CURL EXPAT ZLIB) if(CMAKE_USE_SYSTEM_${util}) set(CMAKE_TEST_SYSTEM_LIBRARIES 1) endif() @@ -250,7 +246,7 @@ macro(CMAKE_SETUP_TESTING) set(CMAKE_CTEST_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/ctest") set(CMAKE_CMAKE_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/cmake") set(CMAKE_CPACK_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/cpack") - foreach(exe cmake ctest cpack) + foreach(exe IN ITEMS cmake ctest cpack) add_executable(${exe} IMPORTED) set_property(TARGET ${exe} PROPERTY IMPORTED_LOCATION ${CMake_TEST_EXTERNAL_CMAKE}/${exe}) endforeach() @@ -262,18 +258,12 @@ macro(CMAKE_SETUP_TESTING) endif() # configure some files for testing - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Templates/CTestScript.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/CTestScript.cmake" - @ONLY) - configure_file(${CMake_SOURCE_DIR}/Tests/.NoDartCoverage - ${CMake_BINARY_DIR}/Tests/.NoDartCoverage) - configure_file(${CMake_SOURCE_DIR}/Tests/.NoDartCoverage - ${CMake_BINARY_DIR}/Modules/.NoDartCoverage) - configure_file(${CMake_SOURCE_DIR}/CTestCustom.cmake.in - ${CMake_BINARY_DIR}/CTestCustom.cmake @ONLY) + configure_file(Templates/CTestScript.cmake.in CTestScript.cmake @ONLY) + configure_file(Tests/.NoDartCoverage Tests/.NoDartCoverage) + configure_file(Tests/.NoDartCoverage Modules/.NoDartCoverage) + configure_file(CTestCustom.cmake.in CTestCustom.cmake @ONLY) if(BUILD_TESTING AND DART_ROOT) - configure_file(${CMake_SOURCE_DIR}/CMakeLogo.gif - ${CMake_BINARY_DIR}/Testing/HTML/TestingResults/Icons/Logo.gif COPYONLY) + configure_file(CMakeLogo.gif Testing/HTML/TestingResults/Icons/Logo.gif COPYONLY) endif() mark_as_advanced(DART_ROOT) endmacro() @@ -339,390 +329,6 @@ macro(CMAKE_SET_TARGET_FOLDER tgt folder) endif() endmacro() - -#----------------------------------------------------------------------- -# a macro to build the utilities used by CMake -# Simply to improve readability of the main script. -#----------------------------------------------------------------------- -macro (CMAKE_BUILD_UTILITIES) - find_package(Threads) - - # Suppress unnecessary checks in third-party code. - include(Utilities/cmThirdPartyChecks.cmake) - - #--------------------------------------------------------------------- - # Create the kwsys library for CMake. - set(KWSYS_NAMESPACE cmsys) - set(KWSYS_USE_SystemTools 1) - set(KWSYS_USE_Directory 1) - set(KWSYS_USE_RegularExpression 1) - set(KWSYS_USE_Base64 1) - set(KWSYS_USE_MD5 1) - set(KWSYS_USE_Process 1) - set(KWSYS_USE_CommandLineArguments 1) - set(KWSYS_USE_ConsoleBuf 1) - set(KWSYS_HEADER_ROOT ${CMake_BINARY_DIR}/Source) - set(KWSYS_INSTALL_DOC_DIR "${CMAKE_DOC_DIR}") - if(CMake_NO_CXX_STANDARD) - set(KWSYS_CXX_STANDARD "") - endif() - if(CMake_NO_SELF_BACKTRACE) - set(KWSYS_NO_EXECINFO 1) - endif() - if(WIN32) - # FIXME: Teach KWSys to hard-code these checks on Windows. - set(KWSYS_C_HAS_CLOCK_GETTIME_MONOTONIC_COMPILED 0) - set(KWSYS_C_HAS_PTRDIFF_T_COMPILED 1) - set(KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H_COMPILED 1) - set(KWSYS_CXX_HAS_RLIMIT64_COMPILED 0) - set(KWSYS_CXX_HAS_SETENV_COMPILED 0) - set(KWSYS_CXX_HAS_UNSETENV_COMPILED 0) - set(KWSYS_CXX_HAS_UTIMENSAT_COMPILED 0) - set(KWSYS_CXX_HAS_UTIMES_COMPILED 0) - set(KWSYS_CXX_STAT_HAS_ST_MTIM_COMPILED 0) - set(KWSYS_CXX_STAT_HAS_ST_MTIMESPEC_COMPILED 0) - set(KWSYS_STL_HAS_WSTRING_COMPILED 1) - set(KWSYS_SYS_HAS_IFADDRS_H 0) - endif() - add_subdirectory(Source/kwsys) - set(kwsys_folder "Utilities/KWSys") - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE} "${kwsys_folder}") - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}_c "${kwsys_folder}") - if(BUILD_TESTING) - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestDynload "${kwsys_folder}") - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestProcess "${kwsys_folder}") - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestsC "${kwsys_folder}") - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestsCxx "${kwsys_folder}") - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestSharedForward "${kwsys_folder}") - endif() - - #--------------------------------------------------------------------- - # Setup third-party libraries. - # Everything in the tree should be able to include files from the - # Utilities directory. - if ((CMAKE_SYSTEM_NAME STREQUAL "AIX" OR CMAKE_SYSTEM_NAME STREQUAL "OS400") AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - # using -isystem option generate error "template with C linkage" - include_directories("${CMake_SOURCE_DIR}/Utilities/std") - else() - include_directories(SYSTEM "${CMake_SOURCE_DIR}/Utilities/std") - endif() - - include_directories("${CMake_BINARY_DIR}/Utilities") - if ((CMAKE_SYSTEM_NAME STREQUAL "AIX" OR CMAKE_SYSTEM_NAME STREQUAL "OS400") AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - # using -isystem option generate error "template with C linkage" - include_directories("${CMake_SOURCE_DIR}/Utilities") - else() - include_directories(SYSTEM "${CMake_SOURCE_DIR}/Utilities") - endif() - - #--------------------------------------------------------------------- - # Build CMake std library for CMake and CTest. - set(CMAKE_STD_LIBRARY cmstd) - add_subdirectory(Utilities/std) - CMAKE_SET_TARGET_FOLDER(cmstd "Utilities/std") - - # check for the use of system libraries versus builtin ones - # (a macro defined in this file) - CMAKE_HANDLE_SYSTEM_LIBRARIES() - - if(CMAKE_USE_SYSTEM_KWIML) - find_package(KWIML 1.0) - if(NOT KWIML_FOUND) - message(FATAL_ERROR "CMAKE_USE_SYSTEM_KWIML is ON but KWIML is not found!") - endif() - set(CMake_KWIML_LIBRARIES kwiml::kwiml) - else() - set(CMake_KWIML_LIBRARIES "") - if(BUILD_TESTING) - set(KWIML_TEST_ENABLE 1) - endif() - add_subdirectory(Utilities/KWIML) - endif() - - if(CMAKE_USE_SYSTEM_LIBRHASH) - find_package(LibRHash) - if(NOT LibRHash_FOUND) - message(FATAL_ERROR - "CMAKE_USE_SYSTEM_LIBRHASH is ON but LibRHash is not found!") - endif() - set(CMAKE_LIBRHASH_LIBRARIES LibRHash::LibRHash) - else() - set(CMAKE_LIBRHASH_LIBRARIES cmlibrhash) - add_subdirectory(Utilities/cmlibrhash) - CMAKE_SET_TARGET_FOLDER(cmlibrhash "Utilities/3rdParty") - endif() - - #--------------------------------------------------------------------- - # Build zlib library for Curl, CMake, and CTest. - set(CMAKE_ZLIB_HEADER "cm_zlib.h") - if(CMAKE_USE_SYSTEM_ZLIB) - find_package(ZLIB) - if(NOT ZLIB_FOUND) - message(FATAL_ERROR - "CMAKE_USE_SYSTEM_ZLIB is ON but a zlib is not found!") - endif() - set(CMAKE_ZLIB_INCLUDES ${ZLIB_INCLUDE_DIR}) - set(CMAKE_ZLIB_LIBRARIES ${ZLIB_LIBRARIES}) - else() - set(CMAKE_ZLIB_INCLUDES ${CMake_SOURCE_DIR}/Utilities) - set(CMAKE_ZLIB_LIBRARIES cmzlib) - set(WITHOUT_ZLIB_DLL "") - set(WITHOUT_ZLIB_DLL_WITH_LIB cmzlib) - set(ZLIB_DLL "") - set(ZLIB_DLL_WITH_LIB cmzlib) - set(ZLIB_WINAPI "") - set(ZLIB_WINAPI_COMPILED 0) - set(ZLIB_WINAPI_WITH_LIB cmzlib) - add_subdirectory(Utilities/cmzlib) - CMAKE_SET_TARGET_FOLDER(cmzlib "Utilities/3rdParty") - endif() - - #--------------------------------------------------------------------- - # Build Curl library for CTest. - if(CMAKE_USE_SYSTEM_CURL) - find_package(CURL) - if(NOT CURL_FOUND) - message(FATAL_ERROR - "CMAKE_USE_SYSTEM_CURL is ON but a curl is not found!") - endif() - set(CMAKE_CURL_INCLUDES ${CURL_INCLUDE_DIRS}) - set(CMAKE_CURL_LIBRARIES ${CURL_LIBRARIES}) - else() - set(CURL_SPECIAL_ZLIB_H ${CMAKE_ZLIB_HEADER}) - set(CURL_SPECIAL_LIBZ_INCLUDES ${CMAKE_ZLIB_INCLUDES}) - set(CURL_SPECIAL_LIBZ ${CMAKE_ZLIB_LIBRARIES}) - set(CMAKE_CURL_INCLUDES) - set(CMAKE_CURL_LIBRARIES cmcurl) - if(CMAKE_TESTS_CDASH_SERVER) - set(CMAKE_CURL_TEST_URL "${CMAKE_TESTS_CDASH_SERVER}/user.php") - endif() - set(_CMAKE_USE_OPENSSL_DEFAULT OFF) - if(NOT DEFINED CMAKE_USE_OPENSSL AND NOT WIN32 AND NOT APPLE - AND CMAKE_SYSTEM_NAME MATCHES "(Linux|FreeBSD)") - set(_CMAKE_USE_OPENSSL_DEFAULT ON) - endif() - option(CMAKE_USE_OPENSSL "Use OpenSSL." ${_CMAKE_USE_OPENSSL_DEFAULT}) - mark_as_advanced(CMAKE_USE_OPENSSL) - if(CMAKE_USE_OPENSSL) - set(CURL_CA_BUNDLE "" CACHE FILEPATH "Path to SSL CA Certificate Bundle") - set(CURL_CA_PATH "" CACHE PATH "Path to SSL CA Certificate Directory") - mark_as_advanced(CURL_CA_BUNDLE CURL_CA_PATH) - endif() - if(NOT CMAKE_USE_SYSTEM_NGHTTP2) - # Tell curl's FindNGHTTP2 module to use our library. - set(NGHTTP2_LIBRARY cmnghttp2) - set(NGHTTP2_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmnghttp2/lib/includes) - endif() - add_subdirectory(Utilities/cmcurl) - CMAKE_SET_TARGET_FOLDER(cmcurl "Utilities/3rdParty") - CMAKE_SET_TARGET_FOLDER(LIBCURL "Utilities/3rdParty") - if(NOT CMAKE_USE_SYSTEM_NGHTTP2) - # Configure after curl to re-use some check results. - add_subdirectory(Utilities/cmnghttp2) - CMAKE_SET_TARGET_FOLDER(cmnghttp2 "Utilities/3rdParty") - endif() - endif() - - #--------------------------------------------------------------------- - # Build expat library for CMake, CTest, and libarchive. - if(CMAKE_USE_SYSTEM_EXPAT) - find_package(EXPAT) - if(NOT EXPAT_FOUND) - message(FATAL_ERROR - "CMAKE_USE_SYSTEM_EXPAT is ON but a expat is not found!") - endif() - set(CMAKE_EXPAT_INCLUDES ${EXPAT_INCLUDE_DIRS}) - set(CMAKE_EXPAT_LIBRARIES ${EXPAT_LIBRARIES}) - else() - set(CMAKE_EXPAT_INCLUDES) - set(CMAKE_EXPAT_LIBRARIES cmexpat) - add_subdirectory(Utilities/cmexpat) - CMAKE_SET_TARGET_FOLDER(cmexpat "Utilities/3rdParty") - endif() - - #--------------------------------------------------------------------- - # Build or use system libbz2 for libarchive. - if(NOT CMAKE_USE_SYSTEM_LIBARCHIVE) - if(CMAKE_USE_SYSTEM_BZIP2) - find_package(BZip2) - else() - set(BZIP2_INCLUDE_DIR - "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmbzip2") - set(BZIP2_LIBRARIES cmbzip2) - set(BZIP2_NEED_PREFIX "") - set(USE_BZIP2_DLL "") - set(USE_BZIP2_DLL_WITH_LIB cmbzip2) - set(USE_BZIP2_STATIC "") - set(USE_BZIP2_STATIC_WITH_LIB cmbzip2) - add_subdirectory(Utilities/cmbzip2) - CMAKE_SET_TARGET_FOLDER(cmbzip2 "Utilities/3rdParty") - endif() - endif() - - #--------------------------------------------------------------------- - # Build or use system zstd for libarchive. - if(NOT CMAKE_USE_SYSTEM_LIBARCHIVE) - if(NOT CMAKE_USE_SYSTEM_ZSTD) - set(ZSTD_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmzstd") - set(ZSTD_LIBRARY cmzstd) - add_subdirectory(Utilities/cmzstd) - CMAKE_SET_TARGET_FOLDER(cmzstd "Utilities/3rdParty") - endif() - endif() - - #--------------------------------------------------------------------- - # Build or use system liblzma for libarchive. - if(NOT CMAKE_USE_SYSTEM_LIBARCHIVE) - if(CMAKE_USE_SYSTEM_LIBLZMA) - find_package(LibLZMA) - if(NOT LIBLZMA_FOUND) - message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBLZMA is ON but LibLZMA is not found!") - endif() - else() - add_subdirectory(Utilities/cmliblzma) - CMAKE_SET_TARGET_FOLDER(cmliblzma "Utilities/3rdParty") - set(LIBLZMA_HAS_AUTO_DECODER 1) - set(LIBLZMA_HAS_EASY_ENCODER 1) - set(LIBLZMA_HAS_LZMA_PRESET 1) - set(LIBLZMA_INCLUDE_DIR - "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmliblzma/liblzma/api") - set(LIBLZMA_LIBRARY cmliblzma) - set(HAVE_LZMA_STREAM_ENCODER_MT 1) - endif() - endif() - - #--------------------------------------------------------------------- - # Build or use system libarchive for CMake and CTest. - if(CMAKE_USE_SYSTEM_LIBARCHIVE) - find_package(LibArchive 3.3.3) - if(NOT LibArchive_FOUND) - message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBARCHIVE is ON but LibArchive is not found!") - endif() - set(CMAKE_TAR_INCLUDES ${LibArchive_INCLUDE_DIRS}) - set(CMAKE_TAR_LIBRARIES ${LibArchive_LIBRARIES}) - else() - set(EXPAT_INCLUDE_DIR ${CMAKE_EXPAT_INCLUDES}) - set(EXPAT_LIBRARY ${CMAKE_EXPAT_LIBRARIES}) - set(ZLIB_INCLUDE_DIR ${CMAKE_ZLIB_INCLUDES}) - set(ZLIB_LIBRARY ${CMAKE_ZLIB_LIBRARIES}) - add_definitions(-DLIBARCHIVE_STATIC) - set(ENABLE_MBEDTLS OFF) - set(ENABLE_NETTLE OFF) - if(DEFINED CMAKE_USE_OPENSSL) - set(ENABLE_OPENSSL "${CMAKE_USE_OPENSSL}") - else() - set(ENABLE_OPENSSL OFF) - endif() - set(ENABLE_LIBB2 OFF) - set(ENABLE_LZ4 OFF) - set(ENABLE_LZO OFF) - set(ENABLE_LZMA ON) - set(ENABLE_ZSTD ON) - set(ENABLE_ZLIB ON) - set(ENABLE_BZip2 ON) - set(ENABLE_LIBXML2 OFF) - set(ENABLE_EXPAT OFF) - set(ENABLE_PCREPOSIX OFF) - set(ENABLE_LibGCC OFF) - set(ENABLE_CNG OFF) - set(ENABLE_TAR OFF) - set(ENABLE_TAR_SHARED OFF) - set(ENABLE_CPIO OFF) - set(ENABLE_CPIO_SHARED OFF) - set(ENABLE_CAT OFF) - set(ENABLE_CAT_SHARED OFF) - set(ENABLE_XATTR OFF) - set(ENABLE_ACL OFF) - set(ENABLE_ICONV OFF) - set(ENABLE_TEST OFF) - set(ENABLE_COVERAGE OFF) - set(ENABLE_INSTALL OFF) - set(POSIX_REGEX_LIB "" CACHE INTERNAL "libarchive: No POSIX regular expression support") - set(ENABLE_SAFESEH "" CACHE INTERNAL "libarchive: No /SAFESEH linker flag") - set(WINDOWS_VERSION "WIN7" CACHE INTERNAL "libarchive: Set Windows version to use (Windows only)") - add_subdirectory(Utilities/cmlibarchive) - CMAKE_SET_TARGET_FOLDER(cmlibarchive "Utilities/3rdParty") - set(CMAKE_TAR_LIBRARIES cmlibarchive ${BZIP2_LIBRARIES}) - endif() - - #--------------------------------------------------------------------- - # Build jsoncpp library. - if(CMAKE_USE_SYSTEM_JSONCPP) - find_package(JsonCpp 1.6.0) - if(NOT JsonCpp_FOUND) - message(FATAL_ERROR - "CMAKE_USE_SYSTEM_JSONCPP is ON but a JsonCpp is not found!") - endif() - if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|LCC|Clang") - set_property(TARGET JsonCpp::JsonCpp APPEND PROPERTY - INTERFACE_COMPILE_OPTIONS -Wno-deprecated-declarations) - endif() - set(CMAKE_JSONCPP_LIBRARIES JsonCpp::JsonCpp) - else() - set(CMAKE_JSONCPP_LIBRARIES cmjsoncpp) - add_subdirectory(Utilities/cmjsoncpp) - CMAKE_SET_TARGET_FOLDER(cmjsoncpp "Utilities/3rdParty") - endif() - - #--------------------------------------------------------------------- - # Build libuv library. - if(CMAKE_USE_SYSTEM_LIBUV) - if(WIN32) - find_package(LibUV 1.38.0) - else() - find_package(LibUV 1.28.0) - endif() - if(NOT LIBUV_FOUND) - message(FATAL_ERROR - "CMAKE_USE_SYSTEM_LIBUV is ON but a libuv is not found!") - endif() - set(CMAKE_LIBUV_LIBRARIES LibUV::LibUV) - else() - set(CMAKE_LIBUV_LIBRARIES cmlibuv) - add_subdirectory(Utilities/cmlibuv) - CMAKE_SET_TARGET_FOLDER(cmlibuv "Utilities/3rdParty") - endif() - - #--------------------------------------------------------------------- - # Use curses? - if(NOT DEFINED BUILD_CursesDialog) - if (UNIX) - include(${CMake_SOURCE_DIR}/Source/Checks/Curses.cmake) - set(BUILD_CursesDialog_DEFAULT "${CMakeCheckCurses_COMPILED}") - elseif(WIN32) - set(BUILD_CursesDialog_DEFAULT "OFF") - endif() - option(BUILD_CursesDialog "Build the CMake Curses Dialog ccmake" "${BUILD_CursesDialog_DEFAULT}") - endif () - if(BUILD_CursesDialog) - if(UNIX) - set(CURSES_NEED_NCURSES TRUE) - find_package(Curses) - if(NOT CURSES_FOUND) - message(WARNING - "'ccmake' will not be built because Curses was not found.\n" - "Turn off BUILD_CursesDialog to suppress this message." - ) - set(BUILD_CursesDialog 0) - endif() - elseif(WIN32) - # FIXME: Add support for system-provided pdcurses. - add_subdirectory(Utilities/cmpdcurses) - set(CURSES_LIBRARY cmpdcurses) - set(CURSES_INCLUDE_PATH "") # cmpdcurses has usage requirements - set(CMAKE_USE_SYSTEM_FORM 0) - set(HAVE_CURSES_USE_DEFAULT_COLORS 1) - endif() - endif() - if(BUILD_CursesDialog) - if(NOT CMAKE_USE_SYSTEM_FORM) - add_subdirectory(Source/CursesDialog/form) - elseif(NOT CURSES_FORM_LIBRARY) - message( FATAL_ERROR "CMAKE_USE_SYSTEM_FORM in ON but CURSES_FORM_LIBRARY is not set!" ) - endif() - endif() -endmacro () - #----------------------------------------------------------------------- if(NOT CMake_TEST_EXTERNAL_CMAKE) if(CMAKE_CXX_PLATFORM_ID MATCHES "OpenBSD") @@ -749,7 +355,7 @@ include(Source/CMakeVersion.cmake) # Include the standard Dart testing module enable_testing() -include (${CMAKE_ROOT}/Modules/Dart.cmake) +include(${CMAKE_ROOT}/Modules/Dart.cmake) # Set up test-time configuration. set_directory_properties(PROPERTIES @@ -803,8 +409,9 @@ if(CMake_TEST_EXTERNAL_CMAKE) endif() if(NOT CMake_TEST_EXTERNAL_CMAKE) - # build the utilities (a macro defined in this file) - CMAKE_BUILD_UTILITIES() + find_package(Threads) + # build the utilities + include(CMakeBuildUtilities) if(BUILD_QtDialog) if(APPLE) @@ -813,10 +420,9 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) set(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}") # make sure CMAKE_INSTALL_PREFIX ends in / if(NOT CMAKE_INSTALL_PREFIX MATCHES "/$") - set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/") + string(APPEND CMAKE_INSTALL_PREFIX "/") endif() - set(CMAKE_INSTALL_PREFIX - "${CMAKE_INSTALL_PREFIX}CMake.app/Contents") + string(APPEND CMAKE_INSTALL_PREFIX "CMake.app/Contents") endif() endif() @@ -829,14 +435,11 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) endif() # add the uninstall support - configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" - @ONLY) + configure_file(cmake_uninstall.cmake.in cmake_uninstall.cmake @ONLY) add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") - include (CMakeCPack.cmake) + include(CMakeCPack.cmake) endif() @@ -860,10 +463,10 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) -Wshadow -Wpointer-arith -Wformat-security -Wundef ) - foreach(FLAG_LANG C CXX) - foreach(FLAG ${${FLAG_LANG}_FLAGS_LIST}) + foreach(FLAG_LANG IN ITEMS C CXX) + foreach(FLAG IN LISTS ${FLAG_LANG}_FLAGS_LIST) if(NOT " ${CMAKE_${FLAG_LANG}_FLAGS} " MATCHES " ${FLAG} ") - set(CMAKE_${FLAG_LANG}_FLAGS "${CMAKE_${FLAG_LANG}_FLAGS} ${FLAG}") + string(APPEND CMAKE_${FLAG_LANG}_FLAGS " ${FLAG}") endif() endforeach() endforeach() @@ -891,7 +494,8 @@ endif() if(BUILD_TESTING) add_test(SystemInformationNew "${CMAKE_CMAKE_COMMAND}" - --system-information -G "${CMAKE_GENERATOR}" ) + --system-information -G "${CMAKE_GENERATOR}" + ) endif() if(NOT CMake_TEST_EXTERNAL_CMAKE) diff --git a/CompileFlags.cmake b/CompileFlags.cmake index 47c8352..bf8a082 100644 --- a/CompileFlags.cmake +++ b/CompileFlags.cmake @@ -18,7 +18,7 @@ endif() # not hurt other versions, and this will work into the # future if(MSVC OR _INTEL_WINDOWS OR _CLANG_MSVC_WINDOWS) - add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) + add_compile_definitions(_CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE) else() endif() @@ -62,7 +62,7 @@ endif() # Use 64-bit off_t on 32-bit Linux if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SIZEOF_VOID_P EQUAL 4) # ensure 64bit offsets are used for filesystem accesses for 32bit compilation - add_definitions(-D_FILE_OFFSET_BITS=64) + add_compile_definitions(_FILE_OFFSET_BITS=64) endif() # Workaround for TOC Overflow on ppc64 @@ -98,7 +98,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL SunPro AND endif() endif() -foreach(lang C CXX) +foreach(lang IN ITEMS C CXX) # Suppress warnings from PGI compiler. if (CMAKE_${lang}_COMPILER_ID STREQUAL "PGI") set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} -w") @@ -138,9 +138,9 @@ OFF to disable /MP completely." ) endif() # Get rid of excess -Wunused-but-set-variable on release builds with LCC >= 1.26 -foreach(l C CXX) +foreach(l IN ITEMS C CXX) if(CMAKE_${l}_COMPILER_ID STREQUAL "LCC" AND NOT CMAKE_${l}_COMPILER_VERSION VERSION_LESS 1.26) - foreach(c MINSIZEREL RELEASE RELWITHDEBINFO) + foreach(c IN ITEMS MINSIZEREL RELEASE RELWITHDEBINFO) string(APPEND "CMAKE_${l}_FLAGS_${c}" " -Wno-unused-but-set-variable") endforeach() endif() diff --git a/Modules/FindLibArchive.cmake b/Modules/FindLibArchive.cmake index 08078a2..9d3ac13 100644 --- a/Modules/FindLibArchive.cmake +++ b/Modules/FindLibArchive.cmake @@ -26,6 +26,9 @@ The module defines the following ``IMPORTED`` targets: .. versionadded:: 3.6 Support for new libarchive 3.2 version string format. +.. versionadded:: 3.17 + Provides an imported target. + #]=======================================================================] find_path(LibArchive_INCLUDE_DIR diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 86f8116..32bd341 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -4,7 +4,7 @@ # To ensure maximum portability across various compilers and platforms # deactivate any compiler extensions. Skip this for QNX, where additional # work is needed to build without compiler extensions. -if (NOT CMAKE_SYSTEM_NAME STREQUAL "QNX") +if(NOT CMAKE_SYSTEM_NAME STREQUAL "QNX") set(CMAKE_C_EXTENSIONS FALSE) set(CMAKE_CXX_EXTENSIONS FALSE) endif() @@ -31,70 +31,48 @@ if(CMAKE_SYSTEM_NAME STREQUAL "AIX") set(CMake_USE_XCOFF_PARSER 1) endif() +# Watcom support +if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(CMAKE_USE_WMAKE 1) +endif() + +set(CMake_STAT_HAS_ST_MTIM ${KWSYS_CXX_STAT_HAS_ST_MTIM_COMPILED}) +set(CMake_STAT_HAS_ST_MTIMESPEC ${KWSYS_CXX_STAT_HAS_ST_MTIMESPEC_COMPILED}) + set(EXECUTABLE_OUTPUT_PATH ${CMake_BIN_DIR}) if(WIN32) # ensure Unicode friendly APIs are used on Windows - add_definitions(-DUNICODE -D_UNICODE) + add_compile_definitions(UNICODE _UNICODE) # minimize windows.h content - add_definitions(-DWIN32_LEAN_AND_MEAN) + add_compile_definitions(WIN32_LEAN_AND_MEAN) endif() # configure the .dox.in file if(CMake_BUILD_DEVELOPER_REFERENCE) - configure_file( - "${CMake_SOURCE_DIR}/Source/dir.dox.in" - "${CMake_BINARY_DIR}/Source/dir.dox" - @ONLY - ) + configure_file(dir.dox.in dir.dox @ONLY) endif() # configure the .h file -configure_file( - "${CMake_SOURCE_DIR}/Source/cmConfigure.cmake.h.in" - "${CMake_BINARY_DIR}/Source/cmConfigure.h" - ) -configure_file( - "${CMake_SOURCE_DIR}/Source/cmVersionConfig.h.in" - "${CMake_BINARY_DIR}/Source/cmVersionConfig.h" - ) -configure_file( - "${CMake_SOURCE_DIR}/Source/CPack/cmCPackConfigure.h.in" - "${CMake_BINARY_DIR}/Source/CPack/cmCPackConfigure.h" - ) +configure_file(cmConfigure.cmake.h.in cmConfigure.h) +configure_file(cmVersionConfig.h.in cmVersionConfig.h) # Tell CMake executable in the build tree where to find the source tree. configure_file( - "${CMake_SOURCE_DIR}/Source/CMakeSourceDir.txt.in" - "${CMake_BINARY_DIR}/CMakeFiles/CMakeSourceDir.txt" @ONLY - ) - -# add the include path to find the .h -include_directories( - "${CMake_BINARY_DIR}/Source" - "${CMake_SOURCE_DIR}/Source" - "${CMake_SOURCE_DIR}/Source/LexerParser" - ${CMAKE_ZLIB_INCLUDES} - ${CMAKE_EXPAT_INCLUDES} - ${CMAKE_TAR_INCLUDES} - ${CMake_HAIKU_INCLUDE_DIRS} + CMakeSourceDir.txt.in + "${CMake_BINARY_DIR}/CMakeFiles/CMakeSourceDir.txt" + @ONLY ) -# Check if we can build the Mach-O parser. -if(CMake_USE_MACH_PARSER) - set(MACH_SRCS cmMachO.h cmMachO.cxx) -endif() - -# Check if we can build the XCOFF parser. -if(CMake_USE_XCOFF_PARSER) - set(XCOFF_SRCS cmXCOFF.h cmXCOFF.cxx) -endif() +# Add a dummy library and add sources later depends on condition +add_library(ManifestLib INTERFACE) # -# Sources for CMakeLib +# create a library used by the command line and the GUI # -set(SRCS +add_library( + CMakeLib # Lexers/Parsers LexerParser/cmCommandArgumentLexer.cxx LexerParser/cmCommandArgumentLexer.h @@ -370,7 +348,6 @@ set(SRCS cmRulePlaceholderExpander.h cmLocalUnixMakefileGenerator3.cxx cmLocale.h - ${MACH_SRCS} cmMakefile.cxx cmMakefile.h cmMakefileTargetGenerator.cxx @@ -470,7 +447,6 @@ set(SRCS cmWorkerPool.h cmWorkingDirectory.cxx cmWorkingDirectory.h - ${XCOFF_SRCS} cmXMLParser.cxx cmXMLParser.h cmXMLSafe.cxx @@ -730,6 +706,23 @@ set(SRCS cmWhileCommand.h cmWriteFileCommand.cxx cmWriteFileCommand.h + # Ninja support + cmScanDepFormat.cxx + cmGlobalNinjaGenerator.cxx + cmGlobalNinjaGenerator.h + cmNinjaTypes.h + cmLocalNinjaGenerator.cxx + cmLocalNinjaGenerator.h + cmNinjaTargetGenerator.cxx + cmNinjaTargetGenerator.h + cmNinjaNormalTargetGenerator.cxx + cmNinjaNormalTargetGenerator.h + cmNinjaUtilityTargetGenerator.cxx + cmNinjaUtilityTargetGenerator.h + cmNinjaLinkLineComputer.cxx + cmNinjaLinkLineComputer.h + cmNinjaLinkLineDeviceComputer.cxx + cmNinjaLinkLineDeviceComputer.h cm_get_date.h cm_get_date.c @@ -743,102 +736,152 @@ set(SRCS bindexplib.cxx ) +target_include_directories( + CMakeLib + PUBLIC + # add the include path to find the .h + "${CMAKE_CURRENT_BINARY_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}/LexerParser" + ${CMake_HAIKU_INCLUDE_DIRS} + ) +target_link_libraries( + CMakeLib + PUBLIC + cmstd + cmsys + CURL::libcurl + EXPAT::EXPAT + JsonCpp::JsonCpp + $<TARGET_NAME_IF_EXISTS:kwiml::kwiml> + LibArchive::LibArchive + LibRHash::LibRHash + LibUV::LibUV + Threads::Threads + ZLIB::ZLIB + ) -SET_PROPERTY(SOURCE cmProcessOutput.cxx cmWindowsRegistry.cxx APPEND PROPERTY COMPILE_DEFINITIONS - KWSYS_ENCODING_DEFAULT_CODEPAGE=${KWSYS_ENCODING_DEFAULT_CODEPAGE}) +# Check if we can build the Mach-O parser. +if(CMake_USE_MACH_PARSER) + target_sources( + CMakeLib + PUBLIC + cmMachO.h + cmMachO.cxx + ) +endif() + +# Check if we can build the XCOFF parser. +if(CMake_USE_XCOFF_PARSER) + target_sources( + CMakeLib + PUBLIC + cmXCOFF.h + cmXCOFF.cxx + ) +endif() # Xcode only works on Apple if(APPLE) - set(SRCS ${SRCS} - cmXCodeObject.cxx - cmXCode21Object.cxx - cmXCodeScheme.cxx - cmGlobalXCodeGenerator.cxx - cmGlobalXCodeGenerator.h - cmLocalXCodeGenerator.cxx - cmLocalXCodeGenerator.h) + target_sources( + CMakeLib + PUBLIC + cmXCodeObject.cxx + cmXCode21Object.cxx + cmXCodeScheme.cxx + cmGlobalXCodeGenerator.cxx + cmGlobalXCodeGenerator.h + cmLocalXCodeGenerator.cxx + cmLocalXCodeGenerator.h + ) endif() - -if (WIN32) - set(SRCS ${SRCS} - cmCallVisualStudioMacro.cxx - cmCallVisualStudioMacro.h +if(WIN32) + target_sources( + CMakeLib + PUBLIC + cmCallVisualStudioMacro.cxx + cmCallVisualStudioMacro.h ) if(NOT UNIX) - set(SRCS ${SRCS} - cmGlobalBorlandMakefileGenerator.cxx - cmGlobalBorlandMakefileGenerator.h - cmGlobalMSYSMakefileGenerator.cxx - cmGlobalMinGWMakefileGenerator.cxx - cmGlobalNMakeMakefileGenerator.cxx - cmGlobalNMakeMakefileGenerator.h - cmGlobalJOMMakefileGenerator.cxx - cmGlobalJOMMakefileGenerator.h - cmGlobalVisualStudio71Generator.cxx - cmGlobalVisualStudio71Generator.h - cmGlobalVisualStudio7Generator.cxx - cmGlobalVisualStudio7Generator.h - cmGlobalVisualStudio8Generator.cxx - cmGlobalVisualStudio8Generator.h - cmGlobalVisualStudio9Generator.cxx - cmGlobalVisualStudio9Generator.h - cmVisualStudioGeneratorOptions.h - cmVisualStudioGeneratorOptions.cxx - cmVsProjectType.h - cmVisualStudio10TargetGenerator.h - cmVisualStudio10TargetGenerator.cxx - cmLocalVisualStudio10Generator.cxx - cmLocalVisualStudio10Generator.h - cmGlobalVisualStudio10Generator.h - cmGlobalVisualStudio10Generator.cxx - cmGlobalVisualStudio11Generator.h - cmGlobalVisualStudio11Generator.cxx - cmGlobalVisualStudio12Generator.h - cmGlobalVisualStudio12Generator.cxx - cmGlobalVisualStudio14Generator.h - cmGlobalVisualStudio14Generator.cxx - cmGlobalVisualStudioGenerator.cxx - cmGlobalVisualStudioGenerator.h - cmGlobalVisualStudioVersionedGenerator.h - cmGlobalVisualStudioVersionedGenerator.cxx - cmIDEFlagTable.h - cmIDEOptions.cxx - cmIDEOptions.h - cmLocalVisualStudio7Generator.cxx - cmLocalVisualStudio7Generator.h - cmLocalVisualStudioGenerator.cxx - cmLocalVisualStudioGenerator.h - cmVisualStudioSlnData.h - cmVisualStudioSlnData.cxx - cmVisualStudioSlnParser.h - cmVisualStudioSlnParser.cxx - cmVisualStudioWCEPlatformParser.h - cmVisualStudioWCEPlatformParser.cxx - cmVSSetupHelper.cxx - cmVSSetupHelper.h + target_sources( + CMakeLib + PUBLIC + cmGlobalBorlandMakefileGenerator.cxx + cmGlobalBorlandMakefileGenerator.h + cmGlobalMSYSMakefileGenerator.cxx + cmGlobalMinGWMakefileGenerator.cxx + cmGlobalNMakeMakefileGenerator.cxx + cmGlobalNMakeMakefileGenerator.h + cmGlobalJOMMakefileGenerator.cxx + cmGlobalJOMMakefileGenerator.h + cmGlobalVisualStudio71Generator.cxx + cmGlobalVisualStudio71Generator.h + cmGlobalVisualStudio7Generator.cxx + cmGlobalVisualStudio7Generator.h + cmGlobalVisualStudio8Generator.cxx + cmGlobalVisualStudio8Generator.h + cmGlobalVisualStudio9Generator.cxx + cmGlobalVisualStudio9Generator.h + cmVisualStudioGeneratorOptions.h + cmVisualStudioGeneratorOptions.cxx + cmVsProjectType.h + cmVisualStudio10TargetGenerator.h + cmVisualStudio10TargetGenerator.cxx + cmLocalVisualStudio10Generator.cxx + cmLocalVisualStudio10Generator.h + cmGlobalVisualStudio10Generator.h + cmGlobalVisualStudio10Generator.cxx + cmGlobalVisualStudio11Generator.h + cmGlobalVisualStudio11Generator.cxx + cmGlobalVisualStudio12Generator.h + cmGlobalVisualStudio12Generator.cxx + cmGlobalVisualStudio14Generator.h + cmGlobalVisualStudio14Generator.cxx + cmGlobalVisualStudioGenerator.cxx + cmGlobalVisualStudioGenerator.h + cmGlobalVisualStudioVersionedGenerator.h + cmGlobalVisualStudioVersionedGenerator.cxx + cmIDEFlagTable.h + cmIDEOptions.cxx + cmIDEOptions.h + cmLocalVisualStudio7Generator.cxx + cmLocalVisualStudio7Generator.h + cmLocalVisualStudioGenerator.cxx + cmLocalVisualStudioGenerator.h + cmVisualStudioSlnData.h + cmVisualStudioSlnData.cxx + cmVisualStudioSlnParser.h + cmVisualStudioSlnParser.cxx + cmVisualStudioWCEPlatformParser.h + cmVisualStudioWCEPlatformParser.cxx + cmVSSetupHelper.cxx + cmVSSetupHelper.h ) # Add a manifest file to executables on Windows to allow for # GetVersion to work properly on Windows 8 and above. - set(MANIFEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake.version.manifest) + target_sources(ManifestLib INTERFACE cmake.version.manifest) endif() -endif () +endif() # Watcom support -if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin") - set_property(SOURCE cmake.cxx APPEND PROPERTY COMPILE_DEFINITIONS CMAKE_USE_WMAKE) - list(APPEND SRCS - cmGlobalWatcomWMakeGenerator.cxx - cmGlobalWatcomWMakeGenerator.h +if(CMAKE_USE_WMAKE) + target_sources( + CMakeLib + PUBLIC + cmGlobalWatcomWMakeGenerator.cxx + cmGlobalWatcomWMakeGenerator.h ) endif() # GHS support # Works only for windows and linux if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux") - set(SRCS ${SRCS} + target_sources( + CMakeLib + PUBLIC cmGlobalGhsMultiGenerator.cxx cmGlobalGhsMultiGenerator.h cmLocalGhsMultiGenerator.cxx @@ -850,104 +893,45 @@ if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux") ) endif() - -# Ninja support -set(SRCS ${SRCS} - cmScanDepFormat.cxx - cmGlobalNinjaGenerator.cxx - cmGlobalNinjaGenerator.h - cmNinjaTypes.h - cmLocalNinjaGenerator.cxx - cmLocalNinjaGenerator.h - cmNinjaTargetGenerator.cxx - cmNinjaTargetGenerator.h - cmNinjaNormalTargetGenerator.cxx - cmNinjaNormalTargetGenerator.h - cmNinjaUtilityTargetGenerator.cxx - cmNinjaUtilityTargetGenerator.h - cmNinjaLinkLineComputer.cxx - cmNinjaLinkLineComputer.h - cmNinjaLinkLineDeviceComputer.cxx - cmNinjaLinkLineDeviceComputer.h - ) - # Temporary variable for tools targets set(_tools) if(WIN32 AND NOT CYGWIN) set_source_files_properties(cmcldeps.cxx PROPERTIES COMPILE_DEFINITIONS _WIN32_WINNT=0x0501) - add_executable(cmcldeps cmcldeps.cxx ${MANIFEST_FILE}) + add_executable(cmcldeps cmcldeps.cxx) + target_link_libraries(cmcldeps PRIVATE CMakeLib ManifestLib) list(APPEND _tools cmcldeps) - target_link_libraries(cmcldeps CMakeLib) endif() -foreach(v CURL_CA_BUNDLE CURL_CA_PATH) - if(${v}) - set_property(SOURCE cmCurl.cxx APPEND PROPERTY COMPILE_DEFINITIONS ${v}="${${v}}") - endif() -endforeach() - -foreach(check - STAT_HAS_ST_MTIM - STAT_HAS_ST_MTIMESPEC - ) - if(KWSYS_CXX_${check}_COMPILED) # abuse KWSys check cache entry - set(CMake_${check} 1) - else() - set(CMake_${check} 0) - endif() - set_property(SOURCE cmFileTime.cxx APPEND PROPERTY - COMPILE_DEFINITIONS CMake_${check}=${CMake_${check}}) -endforeach() - -# create a library used by the command line and the GUI -add_library(CMakeLib ${SRCS}) -target_link_libraries(CMakeLib cmsys - ${CMAKE_STD_LIBRARY} - ${CMAKE_EXPAT_LIBRARIES} ${CMAKE_ZLIB_LIBRARIES} - ${CMAKE_TAR_LIBRARIES} - ${CMAKE_CURL_LIBRARIES} - ${CMAKE_JSONCPP_LIBRARIES} - ${CMAKE_LIBUV_LIBRARIES} - ${CMAKE_LIBRHASH_LIBRARIES} - ${CMake_KWIML_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} - ) - if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR MATCHES "sparc") # the atomic instructions are implemented using libatomic on some platforms, # so linking to that may be required check_library_exists(atomic __atomic_fetch_add_4 "" LIBATOMIC_NEEDED) if(LIBATOMIC_NEEDED) - target_link_libraries(CMakeLib atomic) + target_link_libraries(CMakeLib PUBLIC atomic) endif() endif() # On Apple we need CoreFoundation and CoreServices if(APPLE) - target_link_libraries(CMakeLib "-framework CoreFoundation") - target_link_libraries(CMakeLib "-framework CoreServices") + target_link_libraries(CMakeLib PUBLIC "-framework CoreFoundation") + target_link_libraries(CMakeLib PUBLIC "-framework CoreServices") endif() if(WIN32 AND NOT UNIX) # We need the rpcrt4 library on Windows. # We need the crypt32 library on Windows for crypto/cert APIs. - target_link_libraries(CMakeLib rpcrt4 crypt32) + target_link_libraries(CMakeLib PUBLIC rpcrt4 crypt32) endif() target_compile_definitions(CMakeLib PUBLIC ${CLANG_TIDY_DEFINITIONS}) # -# CTestLib -# -include_directories( - "${CMake_SOURCE_DIR}/Source/CTest" - ${CMAKE_CURL_INCLUDES} - ) -# -# Sources for CTestLib +# Build CTestLib # -set(CTEST_SRCS cmCTest.cxx +add_library( + CTestLib + cmCTest.cxx CTest/cmProcess.cxx CTest/cmCTestBinPacker.cxx CTest/cmCTestBuildAndTestHandler.cxx @@ -1014,21 +998,18 @@ set(CTEST_SRCS cmCTest.cxx LexerParser/cmCTestResourceGroupsLexer.h LexerParser/cmCTestResourceGroupsLexer.in.l ) - -# Build CTestLib -add_library(CTestLib ${CTEST_SRCS}) -target_link_libraries(CTestLib CMakeLib ${CMAKE_CURL_LIBRARIES}) - -# -# CPack -# -include_directories( - "${CMake_SOURCE_DIR}/Source/CPack" +target_include_directories( + CTestLib + PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}/CTest" ) +target_link_libraries(CTestLib PUBLIC CMakeLib) + # -# Sources for CPack +# Build CPackLib # -set(CPACK_SRCS +add_library( + CPackLib CPack/cmCPackArchiveGenerator.cxx CPack/cmCPackComponentGroup.cxx CPack/cmCPackDebGenerator.cxx @@ -1039,9 +1020,7 @@ set(CPACK_SRCS CPack/cmCPackNSISGenerator.cxx CPack/cmCPackNuGetGenerator.cxx CPack/cmCPackSTGZGenerator.cxx - ) -# CPack IFW generator -set(CPACK_SRCS ${CPACK_SRCS} + # CPack IFW generator CPack/IFW/cmCPackIFWCommon.cxx CPack/IFW/cmCPackIFWCommon.h CPack/IFW/cmCPackIFWGenerator.cxx @@ -1053,19 +1032,20 @@ set(CPACK_SRCS ${CPACK_SRCS} CPack/IFW/cmCPackIFWRepository.cxx CPack/IFW/cmCPackIFWRepository.h ) - -if(CYGWIN) - set(CPACK_SRCS ${CPACK_SRCS} - CPack/cmCPackCygwinBinaryGenerator.cxx - CPack/cmCPackCygwinSourceGenerator.cxx - ) -endif() +target_include_directories( + CPackLib + PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}/CPack" + "${CMAKE_CURRENT_BINARY_DIR}/CPack" + ) +target_link_libraries(CPackLib PUBLIC CMakeLib) option(CPACK_ENABLE_FREEBSD_PKG "Add FreeBSD pkg(8) generator to CPack." OFF) - if(UNIX) - set(CPACK_SRCS ${CPACK_SRCS} - CPack/cmCPackRPMGenerator.cxx + target_sources( + CPackLib + PUBLIC + CPack/cmCPackRPMGenerator.cxx ) # Optionally, try to use pkg(8) @@ -1081,13 +1061,14 @@ if(UNIX) pkg DOC "FreeBSD pkg(8) library") if(FREEBSD_PKG_LIBRARIES) - set(CPACK_SRCS ${CPACK_SRCS} - CPack/cmCPackFreeBSDGenerator.cxx - ) + set(ENABLE_BUILD_FREEBSD_PKG 1) + target_sources(CPackLib PUBLIC CPack/cmCPackFreeBSDGenerator.cxx) + target_include_directories(CPackLib PUBLIC ${FREEBSD_PKG_INCLUDE_DIRS}) + target_link_libraries(CPackLib PUBLIC ${FREEBSD_PKG_LIBRARIES}) endif() endif() - if (NOT FREEBSD_PKG_INCLUDE_DIRS OR NOT FREEBSD_PKG_LIBRARIES) + if(NOT FREEBSD_PKG_INCLUDE_DIRS OR NOT FREEBSD_PKG_LIBRARIES) message(FATAL_ERROR "CPack needs libpkg(3) to produce FreeBSD packages natively.") endif() else() @@ -1097,47 +1078,57 @@ if(UNIX) endif() if(CYGWIN) + target_sources( + CPackLib + PUBLIC + CPack/cmCPackCygwinBinaryGenerator.cxx + CPack/cmCPackCygwinSourceGenerator.cxx + ) find_package(LibUUID) endif() -if(WIN32 OR (CYGWIN AND LibUUID_FOUND)) - set(CPACK_SRCS ${CPACK_SRCS} - CPack/WiX/cmCMakeToWixPath.cxx - CPack/WiX/cmCMakeToWixPath.h - CPack/WiX/cmCPackWIXGenerator.cxx - CPack/WiX/cmCPackWIXGenerator.h - CPack/WiX/cmWIXAccessControlList.cxx - CPack/WiX/cmWIXAccessControlList.h - CPack/WiX/cmWIXDirectoriesSourceWriter.cxx - CPack/WiX/cmWIXDirectoriesSourceWriter.h - CPack/WiX/cmWIXFeaturesSourceWriter.cxx - CPack/WiX/cmWIXFeaturesSourceWriter.h - CPack/WiX/cmWIXFilesSourceWriter.cxx - CPack/WiX/cmWIXFilesSourceWriter.h - CPack/WiX/cmWIXPatch.cxx - CPack/WiX/cmWIXPatch.h - CPack/WiX/cmWIXPatchParser.cxx - CPack/WiX/cmWIXPatchParser.h - CPack/WiX/cmWIXRichTextFormatWriter.cxx - CPack/WiX/cmWIXRichTextFormatWriter.h - CPack/WiX/cmWIXShortcut.cxx - CPack/WiX/cmWIXShortcut.h - CPack/WiX/cmWIXSourceWriter.cxx - CPack/WiX/cmWIXSourceWriter.h + +if(WIN32 OR (CYGWIN AND TARGET LibUUID::LibUUID)) + set(ENABLE_BUILD_WIX_GENERATOR 1) + target_sources( + CPackLib + PUBLIC + CPack/WiX/cmCMakeToWixPath.cxx + CPack/WiX/cmCMakeToWixPath.h + CPack/WiX/cmCPackWIXGenerator.cxx + CPack/WiX/cmCPackWIXGenerator.h + CPack/WiX/cmWIXAccessControlList.cxx + CPack/WiX/cmWIXAccessControlList.h + CPack/WiX/cmWIXDirectoriesSourceWriter.cxx + CPack/WiX/cmWIXDirectoriesSourceWriter.h + CPack/WiX/cmWIXFeaturesSourceWriter.cxx + CPack/WiX/cmWIXFeaturesSourceWriter.h + CPack/WiX/cmWIXFilesSourceWriter.cxx + CPack/WiX/cmWIXFilesSourceWriter.h + CPack/WiX/cmWIXPatch.cxx + CPack/WiX/cmWIXPatch.h + CPack/WiX/cmWIXPatchParser.cxx + CPack/WiX/cmWIXPatchParser.h + CPack/WiX/cmWIXRichTextFormatWriter.cxx + CPack/WiX/cmWIXRichTextFormatWriter.h + CPack/WiX/cmWIXShortcut.cxx + CPack/WiX/cmWIXShortcut.h + CPack/WiX/cmWIXSourceWriter.cxx + CPack/WiX/cmWIXSourceWriter.h ) + target_link_libraries(CPackLib PUBLIC $<TARGET_NAME_IF_EXISTS:LibUUID::LibUUID>) endif() if(APPLE) - set(CPACK_SRCS ${CPACK_SRCS} - CPack/cmCPackBundleGenerator.cxx - CPack/cmCPackDragNDropGenerator.cxx - CPack/cmCPackPKGGenerator.cxx - CPack/cmCPackProductBuildGenerator.cxx + target_sources( + CPackLib + PUBLIC + CPack/cmCPackBundleGenerator.cxx + CPack/cmCPackDragNDropGenerator.cxx + CPack/cmCPackPKGGenerator.cxx + CPack/cmCPackProductBuildGenerator.cxx ) endif() -# Build CPackLib -add_library(CPackLib ${CPACK_SRCS}) -target_link_libraries(CPackLib CMakeLib) if(APPLE) # Some compilers produce errors in the CoreServices framework headers. # Ideally such errors should be fixed by either the compiler vendor @@ -1145,8 +1136,7 @@ if(APPLE) # If it does not work, build with reduced functionality and warn. check_include_file("CoreServices/CoreServices.h" HAVE_CoreServices) if(HAVE_CoreServices) - set_property(SOURCE CPack/cmCPackDragNDropGenerator.cxx PROPERTY COMPILE_DEFINITIONS HAVE_CoreServices) - target_link_libraries(CPackLib "-framework CoreServices") + target_link_libraries(CPackLib PUBLIC "-framework CoreServices") else() message(WARNING "This compiler does not appear to support\n" " #include <CoreServices/CoreServices.h>\n" @@ -1154,31 +1144,25 @@ if(APPLE) "See CMakeFiles/CMakeError.log for details of the failure.") endif() endif() -if(CYGWIN AND LibUUID_FOUND) - target_link_libraries(CPackLib ${LibUUID_LIBRARIES}) - include_directories(CPackLib ${LibUUID_INCLUDE_DIRS}) - set_property(SOURCE CPack/cmCPackGeneratorFactory.cxx PROPERTY COMPILE_DEFINITIONS HAVE_LIBUUID) -endif() -if(CPACK_ENABLE_FREEBSD_PKG AND FREEBSD_PKG_INCLUDE_DIRS AND FREEBSD_PKG_LIBRARIES) - target_link_libraries(CPackLib ${FREEBSD_PKG_LIBRARIES}) - include_directories(${FREEBSD_PKG_INCLUDE_DIRS}) - add_definitions(-DHAVE_FREEBSD_PKG) -endif() + +# Render config header file for CPackLib +configure_file(CPack/cmCPackConfigure.h.in CPack/cmCPackConfigure.h) + # Build CMake executable -add_executable(cmake cmakemain.cxx cmcmd.cxx cmcmd.h ${MANIFEST_FILE}) +add_executable(cmake cmakemain.cxx cmcmd.cxx cmcmd.h) +target_link_libraries(cmake PRIVATE CMakeLib ManifestLib) list(APPEND _tools cmake) -target_link_libraries(cmake CMakeLib) # Build CTest executable -add_executable(ctest ctest.cxx ${MANIFEST_FILE}) +add_executable(ctest ctest.cxx) +target_link_libraries(ctest PRIVATE CTestLib ManifestLib) list(APPEND _tools ctest) -target_link_libraries(ctest CTestLib) # Build CPack executable -add_executable(cpack CPack/cpack.cxx ${MANIFEST_FILE}) +add_executable(cpack CPack/cpack.cxx) +target_link_libraries(cpack PRIVATE CPackLib ManifestLib) list(APPEND _tools cpack) -target_link_libraries(cpack CPackLib) # Curses GUI if(BUILD_CursesDialog) @@ -1191,8 +1175,8 @@ if(BUILD_QtDialog) add_subdirectory(QtDialog) endif() -include (${CMake_BINARY_DIR}/Source/LocalUserOptions.cmake OPTIONAL) -include (${CMake_SOURCE_DIR}/Source/LocalUserOptions.cmake OPTIONAL) +include(${CMAKE_CURRENT_BINARY_DIR}/LocalUserOptions.cmake OPTIONAL) +include(${CMAKE_CURRENT_SOURCE_DIR}/LocalUserOptions.cmake OPTIONAL) if(WIN32) # Compute the binary version that appears in the RC file. Version @@ -1211,14 +1195,14 @@ if(WIN32) set(CMake_RCVERSION_STR ${CMake_VERSION}) # Add Windows executable version information. - configure_file("CMakeVersion.rc.in" "CMakeVersion.rc" @ONLY) + configure_file(CMakeVersion.rc.in CMakeVersion.rc @ONLY) # We use a separate object library for this to work around a limitation of # MinGW's windres tool with spaces in the path to the include directories. add_library(CMakeVersion OBJECT "${CMAKE_CURRENT_BINARY_DIR}/CMakeVersion.rc") set_property(TARGET CMakeVersion PROPERTY INCLUDE_DIRECTORIES "") - foreach(_tool ${_tools}) - target_sources(${_tool} PRIVATE $<TARGET_OBJECTS:CMakeVersion>) + foreach(_tool IN LISTS _tools) + target_link_libraries(${_tool} PRIVATE CMakeVersion) endforeach() endif() @@ -1229,7 +1213,7 @@ endif() # Install tools -foreach(_tool ${_tools}) +foreach(_tool IN LISTS _tools) CMake_OPTIONAL_COMPONENT(${_tool}) install(TARGETS ${_tool} DESTINATION ${CMAKE_BIN_DIR} ${COMPONENT}) endforeach() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index b4a08cd..13c69c8 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -9,7 +9,7 @@ set(CMake_VERSION_IS_DIRTY 0) set(CMake_VERSION "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}") if(DEFINED CMake_VERSION_RC) - set(CMake_VERSION "${CMake_VERSION}-rc${CMake_VERSION_RC}") + string(APPEND CMake_VERSION "-rc${CMake_VERSION_RC}") endif() # Releases define a small patch level. @@ -53,7 +53,7 @@ if(NOT CMake_VERSION_NO_GIT) # If this is not the exact commit of a release, add dev info. if(NOT "${git_subject}" MATCHES "^[Cc][Mm]ake ${CMake_VERSION}$") - set(CMake_VERSION "${CMake_VERSION}-g${git_hash}") + string(APPEND CMake_VERSION "-g${git_hash}") endif() # If this is a work tree, check whether it is dirty. @@ -68,7 +68,7 @@ if(NOT CMake_VERSION_NO_GIT) # No commit information. if(NOT CMake_VERSION_IS_RELEASE) # Generic development version. - set(CMake_VERSION "${CMake_VERSION}-git") + string(APPEND CMake_VERSION "-git") endif() endif() endif() @@ -80,5 +80,5 @@ else() set(CMake_VERSION_SUFFIX "") endif() if(CMake_VERSION_IS_DIRTY) - set(CMake_VERSION ${CMake_VERSION}-dirty) + string(APPEND CMake_VERSION "-dirty") endif() diff --git a/Source/CPack/cmCPackConfigure.h.in b/Source/CPack/cmCPackConfigure.h.in index 8ac1661..2c1302d 100644 --- a/Source/CPack/cmCPackConfigure.h.in +++ b/Source/CPack/cmCPackConfigure.h.in @@ -1,2 +1,7 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ +#pragma once + +#cmakedefine01 ENABLE_BUILD_WIX_GENERATOR +#cmakedefine01 ENABLE_BUILD_FREEBSD_PKG +#cmakedefine01 HAVE_CoreServices diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index 0f7acfb..0579066 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -14,6 +14,7 @@ #include "cmsys/FStream.hxx" #include "cmsys/RegularExpression.hxx" +#include "cmCPackConfigure.h" #include "cmCPackGenerator.h" #include "cmCPackLog.h" #include "cmDuration.h" @@ -23,7 +24,7 @@ #include "cmValue.h" #include "cmXMLWriter.h" -#ifdef HAVE_CoreServices +#if HAVE_CoreServices // For the old LocaleStringToLangAndRegionCodes() function, to convert // to the old Script Manager RegionCode values needed for the 'LPic' data // structure used for generating multi-lingual SLAs. @@ -590,7 +591,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, kCFStringEncodingMacRoman); LangCode lang = 0; RegionCode region = 0; -#ifdef HAVE_CoreServices +#if HAVE_CoreServices OSStatus err = LocaleStringToLangAndRegionCodes(iso_language_cstr, &lang, ®ion); if (err != noErr) @@ -601,7 +602,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, << iso_language_cstr << std::endl); return 0; } -#ifdef HAVE_CoreServices +#if HAVE_CoreServices header_data.push_back(region); header_data.push_back(i); header_data.push_back(0); diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index 725ea8a..efb94b9 100644 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -6,7 +6,7 @@ #include <utility> #include "IFW/cmCPackIFWGenerator.h" -#ifdef HAVE_FREEBSD_PKG +#if ENABLE_BUILD_FREEBSD_PKG # include "cmCPackFreeBSDGenerator.h" #endif #include "cmCPackArchiveGenerator.h" @@ -34,7 +34,7 @@ # include "cmCPackRPMGenerator.h" #endif -#if defined(_WIN32) || (defined(__CYGWIN__) && defined(HAVE_LIBUUID)) +#if ENABLE_BUILD_WIX_GENERATOR # include "WiX/cmCPackWIXGenerator.h" #endif @@ -80,7 +80,7 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() cmCPackCygwinSourceGenerator::CreateGenerator); } #endif -#if defined(_WIN32) || (defined(__CYGWIN__) && defined(HAVE_LIBUUID)) +#if ENABLE_BUILD_WIX_GENERATOR if (cmCPackWIXGenerator::CanGenerate()) { this->RegisterGenerator("WIX", "MSI file format via WiX tools", cmCPackWIXGenerator::CreateGenerator); @@ -119,7 +119,7 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() cmCPackRPMGenerator::CreateGenerator); } #endif -#ifdef HAVE_FREEBSD_PKG +#if ENABLE_BUILD_FREEBSD_PKG if (cmCPackFreeBSDGenerator::CanGenerate()) { this->RegisterGenerator("FREEBSD", "FreeBSD pkg(8) packages", cmCPackFreeBSDGenerator::CreateGenerator); diff --git a/Source/CPack/cmCPackGeneratorFactory.h b/Source/CPack/cmCPackGeneratorFactory.h index f3e25a6..52c1b5c 100644 --- a/Source/CPack/cmCPackGeneratorFactory.h +++ b/Source/CPack/cmCPackGeneratorFactory.h @@ -8,6 +8,8 @@ #include <memory> #include <string> +#include "cmCPackConfigure.h" // IWYU pragma: keep + class cmCPackGenerator; class cmCPackLog; diff --git a/Source/CursesDialog/form/CMakeLists.txt b/Source/CursesDialog/form/CMakeLists.txt index 68d28c8..63214e3 100644 --- a/Source/CursesDialog/form/CMakeLists.txt +++ b/Source/CursesDialog/form/CMakeLists.txt @@ -11,7 +11,7 @@ elseif(CMAKE_C_COMPILER_ID STREQUAL "PathScale") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall") endif() -configure_file(cmFormConfigure.h.in "${CMAKE_CURRENT_BINARY_DIR}/cmFormConfigure.h") +configure_file(cmFormConfigure.h.in cmFormConfigure.h) add_library(cmForm fld_arg.c diff --git a/Source/Modules/CMakeBuildUtilities.cmake b/Source/Modules/CMakeBuildUtilities.cmake new file mode 100644 index 0000000..5cfb0e7 --- /dev/null +++ b/Source/Modules/CMakeBuildUtilities.cmake @@ -0,0 +1,379 @@ +#----------------------------------------------------------------------- +# Build the utilities used by CMake +# +# Originally it was a macro in the root `CMakeLists.txt` with the comment +# "Simply to improve readability...". +# However, as part of the modernization refactoring it was moved into a +# separate file cuz adding library alises wasn't possible inside the +# macro. +#----------------------------------------------------------------------- + +# Suppress unnecessary checks in third-party code. +include(Utilities/cmThirdPartyChecks.cmake) + +#--------------------------------------------------------------------- +# Create the kwsys library for CMake. +set(KWSYS_NAMESPACE cmsys) +set(KWSYS_USE_SystemTools 1) +set(KWSYS_USE_Directory 1) +set(KWSYS_USE_RegularExpression 1) +set(KWSYS_USE_Base64 1) +set(KWSYS_USE_MD5 1) +set(KWSYS_USE_Process 1) +set(KWSYS_USE_CommandLineArguments 1) +set(KWSYS_USE_ConsoleBuf 1) +set(KWSYS_HEADER_ROOT ${CMake_BINARY_DIR}/Source) +set(KWSYS_INSTALL_DOC_DIR "${CMAKE_DOC_DIR}") +if(CMake_NO_CXX_STANDARD) + set(KWSYS_CXX_STANDARD "") +endif() +if(CMake_NO_SELF_BACKTRACE) + set(KWSYS_NO_EXECINFO 1) +endif() +if(WIN32) + # FIXME: Teach KWSys to hard-code these checks on Windows. + set(KWSYS_C_HAS_CLOCK_GETTIME_MONOTONIC_COMPILED 0) + set(KWSYS_C_HAS_PTRDIFF_T_COMPILED 1) + set(KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H_COMPILED 1) + set(KWSYS_CXX_HAS_RLIMIT64_COMPILED 0) + set(KWSYS_CXX_HAS_SETENV_COMPILED 0) + set(KWSYS_CXX_HAS_UNSETENV_COMPILED 0) + set(KWSYS_CXX_HAS_UTIMENSAT_COMPILED 0) + set(KWSYS_CXX_HAS_UTIMES_COMPILED 0) + set(KWSYS_CXX_STAT_HAS_ST_MTIM_COMPILED 0) + set(KWSYS_CXX_STAT_HAS_ST_MTIMESPEC_COMPILED 0) + set(KWSYS_STL_HAS_WSTRING_COMPILED 1) + set(KWSYS_SYS_HAS_IFADDRS_H 0) +endif() +add_subdirectory(Source/kwsys) +set(kwsys_folder "Utilities/KWSys") +CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE} "${kwsys_folder}") +CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}_c "${kwsys_folder}") +if(BUILD_TESTING) + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestDynload "${kwsys_folder}") + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestProcess "${kwsys_folder}") + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestsC "${kwsys_folder}") + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestsCxx "${kwsys_folder}") + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestSharedForward "${kwsys_folder}") +endif() + +#--------------------------------------------------------------------- +# Setup third-party libraries. +# Everything in the tree should be able to include files from the +# Utilities directory. +if((CMAKE_SYSTEM_NAME STREQUAL "AIX" OR CMAKE_SYSTEM_NAME STREQUAL "OS400") AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # using -isystem option generate error "template with C linkage" + include_directories("${CMake_SOURCE_DIR}/Utilities/std") +else() + include_directories(SYSTEM "${CMake_SOURCE_DIR}/Utilities/std") +endif() + +include_directories("${CMake_BINARY_DIR}/Utilities") +if((CMAKE_SYSTEM_NAME STREQUAL "AIX" OR CMAKE_SYSTEM_NAME STREQUAL "OS400") AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # using -isystem option generate error "template with C linkage" + include_directories("${CMake_SOURCE_DIR}/Utilities") +else() + include_directories(SYSTEM "${CMake_SOURCE_DIR}/Utilities") +endif() + +#--------------------------------------------------------------------- +# Build CMake std library for CMake and CTest. +add_subdirectory(Utilities/std) +CMAKE_SET_TARGET_FOLDER(cmstd "Utilities/std") + +# check for the use of system libraries versus builtin ones +# (a macro defined in this file) +CMAKE_HANDLE_SYSTEM_LIBRARIES() + +if(CMAKE_USE_SYSTEM_KWIML) + find_package(KWIML 1.0) + if(NOT KWIML_FOUND) + message(FATAL_ERROR "CMAKE_USE_SYSTEM_KWIML is ON but KWIML is not found!") + endif() +else() + if(BUILD_TESTING) + set(KWIML_TEST_ENABLE 1) + endif() + add_subdirectory(Utilities/KWIML) +endif() + +if(CMAKE_USE_SYSTEM_LIBRHASH) + find_package(LibRHash) + if(NOT LibRHash_FOUND) + message(FATAL_ERROR + "CMAKE_USE_SYSTEM_LIBRHASH is ON but LibRHash is not found!") + endif() +else() + add_subdirectory(Utilities/cmlibrhash) + add_library(LibRHash::LibRHash ALIAS cmlibrhash) + CMAKE_SET_TARGET_FOLDER(cmlibrhash "Utilities/3rdParty") +endif() + +#--------------------------------------------------------------------- +# Build zlib library for Curl, CMake, and CTest. +if(CMAKE_USE_SYSTEM_ZLIB) + find_package(ZLIB) + if(NOT ZLIB_FOUND) + message(FATAL_ERROR + "CMAKE_USE_SYSTEM_ZLIB is ON but a zlib is not found!") + endif() +else() + if(NOT POLICY CMP0102) # CMake < 3.17 + # Store in cache to protect from mark_as_advanced. + set(ZLIB_INCLUDE_DIR ${CMake_SOURCE_DIR}/Utilities CACHE PATH "") + else() + set(ZLIB_INCLUDE_DIR ${CMake_SOURCE_DIR}/Utilities) + endif() + set(ZLIB_LIBRARY cmzlib) + set(WITHOUT_ZLIB_DLL "") + set(WITHOUT_ZLIB_DLL_WITH_LIB cmzlib) + set(ZLIB_DLL "") + set(ZLIB_DLL_WITH_LIB cmzlib) + set(ZLIB_WINAPI "") + set(ZLIB_WINAPI_COMPILED 0) + set(ZLIB_WINAPI_WITH_LIB cmzlib) + add_subdirectory(Utilities/cmzlib) + add_library(ZLIB::ZLIB ALIAS cmzlib) + CMAKE_SET_TARGET_FOLDER(cmzlib "Utilities/3rdParty") +endif() + +#--------------------------------------------------------------------- +# Build Curl library for CTest. +if(CMAKE_USE_SYSTEM_CURL) + find_package(CURL) + if(NOT CURL_FOUND) + message(FATAL_ERROR + "CMAKE_USE_SYSTEM_CURL is ON but a curl is not found!") + endif() +else() + if(CMAKE_TESTS_CDASH_SERVER) + set(CMAKE_CURL_TEST_URL "${CMAKE_TESTS_CDASH_SERVER}/user.php") + endif() + set(_CMAKE_USE_OPENSSL_DEFAULT OFF) + if(NOT DEFINED CMAKE_USE_OPENSSL AND NOT WIN32 AND NOT APPLE + AND CMAKE_SYSTEM_NAME MATCHES "(Linux|FreeBSD)") + set(_CMAKE_USE_OPENSSL_DEFAULT ON) + endif() + option(CMAKE_USE_OPENSSL "Use OpenSSL." ${_CMAKE_USE_OPENSSL_DEFAULT}) + mark_as_advanced(CMAKE_USE_OPENSSL) + if(CMAKE_USE_OPENSSL) + set(CURL_CA_BUNDLE "" CACHE FILEPATH "Path to SSL CA Certificate Bundle") + set(CURL_CA_PATH "" CACHE PATH "Path to SSL CA Certificate Directory") + mark_as_advanced(CURL_CA_BUNDLE CURL_CA_PATH) + endif() + if(NOT CMAKE_USE_SYSTEM_NGHTTP2) + # Tell curl's FindNGHTTP2 module to use our library. + set(NGHTTP2_LIBRARY cmnghttp2) + set(NGHTTP2_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmnghttp2/lib/includes) + endif() + add_subdirectory(Utilities/cmcurl) + add_library(CURL::libcurl ALIAS cmcurl) + CMAKE_SET_TARGET_FOLDER(cmcurl "Utilities/3rdParty") + CMAKE_SET_TARGET_FOLDER(LIBCURL "Utilities/3rdParty") + if(NOT CMAKE_USE_SYSTEM_NGHTTP2) + # Configure after curl to re-use some check results. + add_subdirectory(Utilities/cmnghttp2) + CMAKE_SET_TARGET_FOLDER(cmnghttp2 "Utilities/3rdParty") + endif() +endif() + +#--------------------------------------------------------------------- +# Build expat library for CMake, CTest, and libarchive. +if(CMAKE_USE_SYSTEM_EXPAT) + find_package(EXPAT) + if(NOT EXPAT_FOUND) + message(FATAL_ERROR + "CMAKE_USE_SYSTEM_EXPAT is ON but a expat is not found!") + endif() + set(CMAKE_EXPAT_INCLUDES ${EXPAT_INCLUDE_DIRS}) + set(CMAKE_EXPAT_LIBRARIES ${EXPAT_LIBRARIES}) +else() + set(CMAKE_EXPAT_INCLUDES) + set(CMAKE_EXPAT_LIBRARIES cmexpat) + add_subdirectory(Utilities/cmexpat) + add_library(EXPAT::EXPAT ALIAS cmexpat) + CMAKE_SET_TARGET_FOLDER(cmexpat "Utilities/3rdParty") +endif() + +#--------------------------------------------------------------------- +# Build or use system libbz2 for libarchive. +if(NOT CMAKE_USE_SYSTEM_LIBARCHIVE) + if(CMAKE_USE_SYSTEM_BZIP2) + find_package(BZip2) + else() + set(BZIP2_INCLUDE_DIR + "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmbzip2") + set(BZIP2_LIBRARIES cmbzip2) + set(BZIP2_NEED_PREFIX "") + set(USE_BZIP2_DLL "") + set(USE_BZIP2_DLL_WITH_LIB cmbzip2) + set(USE_BZIP2_STATIC "") + set(USE_BZIP2_STATIC_WITH_LIB cmbzip2) + add_subdirectory(Utilities/cmbzip2) + CMAKE_SET_TARGET_FOLDER(cmbzip2 "Utilities/3rdParty") + endif() +endif() + +#--------------------------------------------------------------------- +# Build or use system zstd for libarchive. +if(NOT CMAKE_USE_SYSTEM_LIBARCHIVE) + if(NOT CMAKE_USE_SYSTEM_ZSTD) + set(ZSTD_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmzstd") + set(ZSTD_LIBRARY cmzstd) + add_subdirectory(Utilities/cmzstd) + CMAKE_SET_TARGET_FOLDER(cmzstd "Utilities/3rdParty") + endif() +endif() + +#--------------------------------------------------------------------- +# Build or use system liblzma for libarchive. +if(NOT CMAKE_USE_SYSTEM_LIBARCHIVE) + if(CMAKE_USE_SYSTEM_LIBLZMA) + find_package(LibLZMA) + if(NOT LIBLZMA_FOUND) + message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBLZMA is ON but LibLZMA is not found!") + endif() + else() + add_subdirectory(Utilities/cmliblzma) + CMAKE_SET_TARGET_FOLDER(cmliblzma "Utilities/3rdParty") + set(LIBLZMA_HAS_AUTO_DECODER 1) + set(LIBLZMA_HAS_EASY_ENCODER 1) + set(LIBLZMA_HAS_LZMA_PRESET 1) + set(LIBLZMA_INCLUDE_DIR + "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmliblzma/liblzma/api") + set(LIBLZMA_LIBRARY cmliblzma) + set(HAVE_LZMA_STREAM_ENCODER_MT 1) + endif() +endif() + +#--------------------------------------------------------------------- +# Build or use system libarchive for CMake and CTest. +if(CMAKE_USE_SYSTEM_LIBARCHIVE) + find_package(LibArchive 3.3.3) + if(NOT LibArchive_FOUND) + message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBARCHIVE is ON but LibArchive is not found!") + endif() + # NOTE `FindLibArchive` got imported targets support since 3.17 + if (NOT TARGET LibArchive::LibArchive) + add_library(LibArchive::LibArchive UNKNOWN IMPORTED) + set_target_properties(LibArchive::LibArchive PROPERTIES + IMPORTED_LOCATION "${LibArchive_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${LibArchive_INCLUDE_DIRS}") + endif () +else() + set(EXPAT_INCLUDE_DIR ${CMAKE_EXPAT_INCLUDES}) + set(EXPAT_LIBRARY ${CMAKE_EXPAT_LIBRARIES}) + set(ENABLE_MBEDTLS OFF) + set(ENABLE_NETTLE OFF) + if(DEFINED CMAKE_USE_OPENSSL) + set(ENABLE_OPENSSL "${CMAKE_USE_OPENSSL}") + else() + set(ENABLE_OPENSSL OFF) + endif() + set(ENABLE_LIBB2 OFF) + set(ENABLE_LZ4 OFF) + set(ENABLE_LZO OFF) + set(ENABLE_LZMA ON) + set(ENABLE_ZSTD ON) + set(ENABLE_ZLIB ON) + set(ENABLE_BZip2 ON) + set(ENABLE_LIBXML2 OFF) + set(ENABLE_EXPAT OFF) + set(ENABLE_PCREPOSIX OFF) + set(ENABLE_LibGCC OFF) + set(ENABLE_CNG OFF) + set(ENABLE_TAR OFF) + set(ENABLE_TAR_SHARED OFF) + set(ENABLE_CPIO OFF) + set(ENABLE_CPIO_SHARED OFF) + set(ENABLE_CAT OFF) + set(ENABLE_CAT_SHARED OFF) + set(ENABLE_XATTR OFF) + set(ENABLE_ACL OFF) + set(ENABLE_ICONV OFF) + set(ENABLE_TEST OFF) + set(ENABLE_COVERAGE OFF) + set(ENABLE_INSTALL OFF) + set(POSIX_REGEX_LIB "" CACHE INTERNAL "libarchive: No POSIX regular expression support") + set(ENABLE_SAFESEH "" CACHE INTERNAL "libarchive: No /SAFESEH linker flag") + set(WINDOWS_VERSION "WIN7" CACHE INTERNAL "libarchive: Set Windows version to use (Windows only)") + add_subdirectory(Utilities/cmlibarchive) + add_library(LibArchive::LibArchive ALIAS cmlibarchive) + target_compile_definitions(cmlibarchive INTERFACE LIBARCHIVE_STATIC) + CMAKE_SET_TARGET_FOLDER(cmlibarchive "Utilities/3rdParty") +endif() + +#--------------------------------------------------------------------- +# Build jsoncpp library. +if(CMAKE_USE_SYSTEM_JSONCPP) + find_package(JsonCpp 1.6.0) + if(NOT JsonCpp_FOUND) + message(FATAL_ERROR + "CMAKE_USE_SYSTEM_JSONCPP is ON but a JsonCpp is not found!") + endif() + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|LCC|Clang") + set_property(TARGET JsonCpp::JsonCpp APPEND PROPERTY + INTERFACE_COMPILE_OPTIONS -Wno-deprecated-declarations) + endif() +else() + add_subdirectory(Utilities/cmjsoncpp) + add_library(JsonCpp::JsonCpp ALIAS cmjsoncpp) + CMAKE_SET_TARGET_FOLDER(cmjsoncpp "Utilities/3rdParty") +endif() + +#--------------------------------------------------------------------- +# Build libuv library. +if(CMAKE_USE_SYSTEM_LIBUV) + if(WIN32) + find_package(LibUV 1.38.0) + else() + find_package(LibUV 1.28.0) + endif() + if(NOT LIBUV_FOUND) + message(FATAL_ERROR + "CMAKE_USE_SYSTEM_LIBUV is ON but a libuv is not found!") + endif() +else() + add_subdirectory(Utilities/cmlibuv) + add_library(LibUV::LibUV ALIAS cmlibuv) + CMAKE_SET_TARGET_FOLDER(cmlibuv "Utilities/3rdParty") +endif() + +#--------------------------------------------------------------------- +# Use curses? +if(NOT DEFINED BUILD_CursesDialog) + if(UNIX) + include(${CMake_SOURCE_DIR}/Source/Checks/Curses.cmake) + set(BUILD_CursesDialog_DEFAULT "${CMakeCheckCurses_COMPILED}") + elseif(WIN32) + set(BUILD_CursesDialog_DEFAULT "OFF") + endif() + option(BUILD_CursesDialog "Build the CMake Curses Dialog ccmake" "${BUILD_CursesDialog_DEFAULT}") +endif() +if(BUILD_CursesDialog) + if(UNIX) + set(CURSES_NEED_NCURSES TRUE) + find_package(Curses) + if(NOT CURSES_FOUND) + message(WARNING + "'ccmake' will not be built because Curses was not found.\n" + "Turn off BUILD_CursesDialog to suppress this message." + ) + set(BUILD_CursesDialog 0) + endif() + elseif(WIN32) + # FIXME: Add support for system-provided pdcurses. + add_subdirectory(Utilities/cmpdcurses) + set(CURSES_LIBRARY cmpdcurses) + set(CURSES_INCLUDE_PATH "") # cmpdcurses has usage requirements + set(CMAKE_USE_SYSTEM_FORM 0) + set(HAVE_CURSES_USE_DEFAULT_COLORS 1) + endif() +endif() +if(BUILD_CursesDialog) + if(NOT CMAKE_USE_SYSTEM_FORM) + add_subdirectory(Source/CursesDialog/form) + elseif(NOT CURSES_FORM_LIBRARY) + message(FATAL_ERROR "CMAKE_USE_SYSTEM_FORM in ON but CURSES_FORM_LIBRARY is not set!") + endif() +endif() diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 0c263bb..989a929 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -3,7 +3,7 @@ project(QtDialog) CMake_OPTIONAL_COMPONENT(cmake-gui) -set (QT_COMPONENTS +set(QT_COMPONENTS Core Widgets Gui @@ -41,8 +41,8 @@ set(CMake_QT_EXTRA_LIBRARIES) # Try to find the package WinExtras for the task bar progress if(WIN32) find_package(Qt${INSTALLED_QT_VERSION}WinExtras QUIET) - if (Qt${INSTALLED_QT_VERSION}WinExtras_FOUND) - add_definitions(-DQT_WINEXTRAS) + if(Qt${INSTALLED_QT_VERSION}WinExtras_FOUND) + add_compile_definitions(QT_WINEXTRAS) list(APPEND CMake_QT_EXTRA_LIBRARIES Qt${INSTALLED_QT_VERSION}::WinExtras) list(APPEND QT_COMPONENTS WinExtras) endif() @@ -100,14 +100,14 @@ if(CMake_INSTALL_DEPENDENCIES AND (APPLE OR WIN32)) endif() endmacro() macro(install_qt_plugins _comps _plugins_var) - foreach(_qt_comp ${${_comps}}) - if (INSTALLED_QT_VERSION VERSION_LESS 6) + foreach(_qt_comp IN LISTS ${_comps}) + if(INSTALLED_QT_VERSION VERSION_LESS 6) set(_qt_module_plugins ${Qt${INSTALLED_QT_VERSION}${_qt_comp}_PLUGINS}) else() get_target_property(_qt_module_plugins Qt${INSTALLED_QT_VERSION}::${_qt_comp} QT_PLUGINS) endif() - foreach(_qt_plugin ${_qt_module_plugins}) - if (INSTALLED_QT_VERSION VERSION_GREATER_EQUAL 6) + foreach(_qt_plugin IN LISTS _qt_module_plugins) + if(INSTALLED_QT_VERSION VERSION_GREATER_EQUAL 6) # Qt6 provides the plugins as individual packages that need to be found. find_package(Qt${INSTALLED_QT_VERSION}${_qt_plugin} QUIET PATHS ${Qt${INSTALLED_QT_VERSION}${_qt_comp}_DIR}) @@ -117,7 +117,7 @@ if(CMake_INSTALL_DEPENDENCIES AND (APPLE OR WIN32)) endforeach() endmacro() if(APPLE) - if (INSTALLED_QT_VERSION VERSION_EQUAL 5) + if(INSTALLED_QT_VERSION VERSION_EQUAL 5) install_qt_plugin("Qt5::QCocoaIntegrationPlugin" QT_PLUGINS) if(TARGET Qt5::QMacStylePlugin) install_qt_plugin("Qt5::QMacStylePlugin" QT_PLUGINS) @@ -132,7 +132,7 @@ if(CMake_INSTALL_DEPENDENCIES AND (APPLE OR WIN32)) DESTINATION "${CMAKE_INSTALL_PREFIX}/Resources" ${COMPONENT}) elseif(WIN32 AND NOT CMake_QT_STATIC_QWindowsIntegrationPlugin_LIBRARIES) - if (INSTALLED_QT_VERSION VERSION_EQUAL 5) + if(INSTALLED_QT_VERSION VERSION_EQUAL 5) install_qt_plugin("Qt5::QWindowsIntegrationPlugin" QT_PLUGINS) else() # FIXME: Minimize plugins for Qt6. @@ -152,7 +152,10 @@ if(APPLE) get_filename_component(Qt_BIN_DIR "${Qt_BIN_DIR}" PATH) endif() -set(SRCS +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +add_library( + CMakeGUILib STATIC AddCacheEntry.cxx AddCacheEntry.h CMakeSetupDialog.cxx @@ -179,6 +182,16 @@ set(SRCS WarningMessagesDialog.cxx WarningMessagesDialog.h ) +# CMake_QT_EXTRA_LIBRARIES have to come before the main libraries on the link line +target_link_libraries( + CMakeGUILib + PUBLIC + CMakeLib + ${CMake_QT_EXTRA_LIBRARIES} + Qt${INSTALLED_QT_VERSION}::Core + Qt${INSTALLED_QT_VERSION}::Widgets + ) + set(UI_SRCS CMakeSetupDialog.ui Compilers.ui @@ -204,7 +217,7 @@ set(MOC_SRCS ) set(QRC_SRCS CMakeSetup.qrc) -if (INSTALLED_QT_VERSION VERSION_LESS 6) +if(INSTALLED_QT_VERSION VERSION_LESS 6) qt5_wrap_ui(UI_BUILT_SRCS ${UI_SRCS}) qt5_wrap_cpp(MOC_BUILT_SRCS ${MOC_SRCS}) qt5_add_resources(QRC_BUILT_SRCS ${QRC_SRCS}) @@ -215,15 +228,18 @@ else() endif() add_library(CMakeGUIQRCLib OBJECT ${QRC_BUILT_SRCS}) -if (FALSE) # CMake's bootstrap binary does not support automoc +if(FALSE) # CMake's bootstrap binary does not support automoc set(CMAKE_AUTOMOC 1) set(CMAKE_AUTORCC 1) set(CMAKE_AUTOUIC 1) -else () - list(APPEND SRCS - ${UI_BUILT_SRCS} - ${MOC_BUILT_SRCS}) -endif () +else() + target_sources( + CMakeGUILib + PUBLIC + ${UI_BUILT_SRCS} + ${MOC_BUILT_SRCS} + ) +endif() if(USE_LGPL) install(FILES ${CMake_SOURCE_DIR}/Licenses/LGPLv${USE_LGPL}.txt @@ -233,22 +249,20 @@ if(USE_LGPL) PROPERTY COMPILE_DEFINITIONS USE_LGPL="${USE_LGPL}") endif() -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -add_library(CMakeGUILib STATIC ${SRCS}) -# CMake_QT_EXTRA_LIBRARIES have to come before the main libraries on the link line -target_link_libraries(CMakeGUILib PUBLIC CMakeLib ${CMake_QT_EXTRA_LIBRARIES} - Qt${INSTALLED_QT_VERSION}::Core Qt${INSTALLED_QT_VERSION}::Widgets) - add_library(CMakeGUIMainLib STATIC CMakeSetup.cxx) -target_link_libraries(CMakeGUIMainLib PUBLIC CMakeGUILib) +target_link_libraries( + CMakeGUIMainLib + PUBLIC + CMakeGUILib + CMakeGUIQRCLib + $<TARGET_NAME_IF_EXISTS:CMakeVersion> + ) -add_executable(cmake-gui WIN32 MACOSX_BUNDLE CMakeGUIExec.cxx ${MANIFEST_FILE}) -target_link_libraries(cmake-gui CMakeGUIMainLib Qt${INSTALLED_QT_VERSION}::Core) +add_executable(cmake-gui WIN32 MACOSX_BUNDLE CMakeGUIExec.cxx) +target_link_libraries(cmake-gui CMakeGUIMainLib ManifestLib Qt${INSTALLED_QT_VERSION}::Core) -target_sources(CMakeGUIMainLib INTERFACE $<TARGET_OBJECTS:CMakeGUIQRCLib>) if(WIN32) - target_sources(CMakeGUIMainLib INTERFACE $<TARGET_OBJECTS:CMakeVersion> CMakeSetup.rc) + target_sources(CMakeGUIMainLib INTERFACE CMakeSetup.rc) endif() if(APPLE) target_sources(CMakeGUIMainLib INTERFACE CMakeSetup.icns) @@ -300,21 +314,19 @@ if(APPLE) $<TARGET_FILE_DIR:cmake>/cmake-gui ) endif() -set(CMAKE_INSTALL_DESTINATION_ARGS - BUNDLE DESTINATION "${CMAKE_BUNDLE_LOCATION}" ${COMPONENT}) install(TARGETS cmake-gui RUNTIME DESTINATION bin ${COMPONENT} - ${CMAKE_INSTALL_DESTINATION_ARGS}) + BUNDLE DESTINATION "${CMAKE_BUNDLE_LOCATION}" ${COMPONENT}) if(UNIX AND NOT APPLE) - foreach (size IN ITEMS 32 128) + foreach(size IN ITEMS 32 128) install( FILES "${CMAKE_CURRENT_SOURCE_DIR}/CMakeSetup${size}.png" DESTINATION "${CMAKE_XDGDATA_DIR}/icons/hicolor/${size}x${size}/apps" ${COMPONENT} RENAME "CMakeSetup.png") - endforeach () + endforeach() # install a desktop file so CMake appears in the application start menu # with an icon @@ -348,5 +360,4 @@ if(CMake_INSTALL_DEPENDENCIES AND (APPLE OR WIN32)) endif() set(CMAKE_PACKAGE_QTGUI TRUE) -configure_file("${QtDialog_SOURCE_DIR}/QtDialogCPack.cmake.in" - "${QtDialog_BINARY_DIR}/QtDialogCPack.cmake" @ONLY) +configure_file(QtDialogCPack.cmake.in QtDialogCPack.cmake @ONLY) diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 3bc4f0e..27f2156 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -225,6 +225,8 @@ void GetScriptingCommands(cmState* state) void GetProjectCommands(cmState* state) { + state->AddBuiltinCommand("add_compile_definitions", + cmAddCompileDefinitionsCommand); state->AddBuiltinCommand("add_custom_command", cmAddCustomCommandCommand); state->AddBuiltinCommand("add_custom_target", cmAddCustomTargetCommand); state->AddBuiltinCommand("add_definitions", cmAddDefinitionsCommand); @@ -275,8 +277,6 @@ void GetProjectCommands(cmState* state) cmTargetPrecompileHeadersCommand); #if !defined(CMAKE_BOOTSTRAP) - state->AddBuiltinCommand("add_compile_definitions", - cmAddCompileDefinitionsCommand); state->AddBuiltinCommand("add_compile_options", cmAddCompileOptionsCommand); state->AddBuiltinCommand("aux_source_directory", cmAuxSourceDirectoryCommand); diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index 31d03da..90f3de0 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -22,6 +22,7 @@ #cmakedefine HAVE_UNSETENV #cmakedefine CMake_USE_MACH_PARSER #cmakedefine CMake_USE_XCOFF_PARSER +#cmakedefine CMAKE_USE_WMAKE #define CMake_DEFAULT_RECURSION_LIMIT @CMake_DEFAULT_RECURSION_LIMIT@ #define CMAKE_BIN_DIR "/@CMAKE_BIN_DIR@" #define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@" @@ -32,3 +33,11 @@ #if defined(_WIN32) && !defined(NOMINMAX) # define NOMINMAX #endif + +#cmakedefine CURL_CA_BUNDLE "@CURL_CA_BUNDLE@" +#cmakedefine CURL_CA_PATH "@CURL_CA_PATH@" + +#cmakedefine01 CMake_STAT_HAS_ST_MTIM +#cmakedefine01 CMake_STAT_HAS_ST_MTIMESPEC + +#cmakedefine KWSYS_ENCODING_DEFAULT_CODEPAGE @KWSYS_ENCODING_DEFAULT_CODEPAGE@ diff --git a/Source/cmWindowsRegistry.h b/Source/cmWindowsRegistry.h index 2eed297..f4a0e7b 100644 --- a/Source/cmWindowsRegistry.h +++ b/Source/cmWindowsRegistry.h @@ -2,6 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #pragma once +#include "cmConfigure.h" // IWYU pragma: keep + #include <cstdint> // IWYU pragma: keep #include <string> #include <vector> diff --git a/Source/cmake.version.manifest b/Source/cmake.version.manifest index e7010c9..79e3d19 100644 --- a/Source/cmake.version.manifest +++ b/Source/cmake.version.manifest @@ -1,6 +1,6 @@ <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" - xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" > + xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" > <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <application> <!-- Windows Vista --> diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt index 1d45162..612d4b4 100644 --- a/Tests/CMakeLib/CMakeLists.txt +++ b/Tests/CMakeLib/CMakeLists.txt @@ -47,12 +47,10 @@ if(WIN32) list(APPEND CMakeLib_TESTS testVisualStudioSlnParser.cxx ) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/testVisualStudioSlnParser.h.in - ${CMAKE_CURRENT_BINARY_DIR}/testVisualStudioSlnParser.h @ONLY) + configure_file(testVisualStudioSlnParser.h.in testVisualStudioSlnParser.h @ONLY) endif() -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/testXMLParser.h.in - ${CMAKE_CURRENT_BINARY_DIR}/testXMLParser.h @ONLY) +configure_file(testXMLParser.h.in testXMLParser.h @ONLY) create_test_sourcelist(CMakeLib_TEST_SRCS CMakeLibTests.cxx ${CMakeLib_TESTS}) add_executable(CMakeLibTests ${CMakeLib_TEST_SRCS}) diff --git a/Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt b/Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt index 4bef6c5..b4bc921 100644 --- a/Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt +++ b/Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt @@ -1,6 +1,6 @@ -foreach (_retval 0 1) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/memtester.cxx.in" "${CMAKE_CURRENT_BINARY_DIR}/ret${_retval}.cxx" @ONLY) -endforeach () +foreach(_retval IN ITEMS 0 1) + configure_file(memtester.cxx.in ret${_retval}.cxx @ONLY) +endforeach() include_directories(${CMake_SOURCE_DIR}/Source ${CMake_BINARY_DIR}/Source) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 3540aaa..a58c7e9 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -89,7 +89,7 @@ if(BUILD_TESTING) endif() endif() - set(MAKE_IS_GNU ) + set(MAKE_IS_GNU) if(CMAKE_MAKE_PROGRAM MATCHES make) execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} no_such_target --version RESULT_VARIABLE res OUTPUT_VARIABLE out ERROR_VARIABLE out) @@ -101,7 +101,7 @@ if(BUILD_TESTING) endif() # some old versions of make simply cannot handle spaces in paths - if (MAKE_IS_GNU OR + if(MAKE_IS_GNU OR CMAKE_MAKE_PROGRAM MATCHES "nmake|gmake|wmake" OR CMAKE_GENERATOR MATCHES "Visual Studio|Xcode|Borland|Ninja") set(MAKE_SUPPORTS_SPACES 1) @@ -181,7 +181,7 @@ if(BUILD_TESTING) ERROR_VARIABLE my_err) string(REGEX REPLACE "HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Wow6432Node\\\\Microsoft\\\\Windows CE Tools\\\\SDKs\\\\" ";" sdk_list "${sdk_reg}") list(LENGTH sdk_list sdk_list_len) - if (${sdk_list_len} GREATER 1) + if(${sdk_list_len} GREATER 1) list(GET sdk_list 1 _sdk) # The first entry is always empty due to the regex replace above string(STRIP ${_sdk} _sdk) # Make sure there is no newline in the SDK name endif() @@ -205,7 +205,7 @@ if(BUILD_TESTING) select_wince_sdk(reg_wince wince_sdk) set(reg_tegra "[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Nsight Tegra;sdkRoot]") set(reg_nasm "[HKEY_CURRENT_USER\\SOFTWARE\\nasm]") - foreach(reg vs10 vs11 vs12 vs14 ws80 ws81 ws10_0 wp80 wp81 wince tegra nasm) + foreach(reg IN ITEMS vs10 vs11 vs12 vs14 ws80 ws81 ws10_0 wp80 wp81 wince tegra nasm) get_filename_component(r "${reg_${reg}}" ABSOLUTE) if(IS_DIRECTORY "${r}" AND NOT "${r}" STREQUAL "/registry") set(${reg} 1) @@ -227,7 +227,7 @@ if(BUILD_TESTING) set(vs_versions vs15) endif() endif() - foreach(info ${vs_versions}) + foreach(info IN LISTS vs_versions) cmake_host_system_information(RESULT found QUERY "${info_${info}}") if(found) set(${info} 1) @@ -287,12 +287,12 @@ if(BUILD_TESTING) "Should the long tests be run (such as Bootstrap)." ON) mark_as_advanced(CMAKE_RUN_LONG_TESTS) - if (CMAKE_RUN_LONG_TESTS) + if(CMAKE_RUN_LONG_TESTS) option(CTEST_TEST_CTEST "Should the tests that run a full sub ctest process be run?" OFF) mark_as_advanced(CTEST_TEST_CTEST) - endif () + endif() option(CTEST_TEST_CPACK "Should the tests that use '--build-target package' be run?" @@ -367,9 +367,9 @@ if(BUILD_TESTING) if(CMake_TEST_RESOURCES) ADD_TEST_MACRO(VSResource VSResource) - if (CMAKE_GENERATOR MATCHES "Ninja") + if(CMAKE_GENERATOR MATCHES "Ninja") add_test_macro(VSResourceNinjaForceRSP VSResourceNinjaForceRSP) - endif () + endif() endif() if(_isMultiConfig) set(MSManifest_CTEST_OPTIONS -C $<CONFIGURATION>) @@ -502,7 +502,7 @@ if(BUILD_TESTING) endif() ADD_TEST_MACRO(SourcesProperty SourcesProperty) ADD_TEST_MACRO(SourceFileProperty SourceFileProperty) - if (NOT CMAKE_GENERATOR STREQUAL "Xcode") + if(NOT CMAKE_GENERATOR STREQUAL "Xcode") ADD_TEST_MACRO(SourceFileIncludeDirProperty SourceFileIncludeDirProperty) endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "LCC" OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" @@ -649,11 +649,11 @@ if(BUILD_TESTING) ADD_TEST_MACRO(Module.WriteCompilerDetectionHeader WriteCompilerDetectionHeader) - if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "LCC") + if(APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "LCC") include(CheckCXXCompilerFlag) check_cxx_compiler_flag(-fPIE run_pic_test) else() - if (CMAKE_CXX_COMPILER_ID MATCHES "PGI" + if(CMAKE_CXX_COMPILER_ID MATCHES "PGI" OR CMAKE_CXX_COMPILER_ID MATCHES "PathScale" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") set(run_pic_test 0) @@ -662,7 +662,7 @@ if(BUILD_TESTING) endif() endif() - if (run_pic_test) + if(run_pic_test) ADD_TEST_MACRO(PositionIndependentTargets PositionIndependentTargets) endif() @@ -733,13 +733,15 @@ if(BUILD_TESTING) # mainly it tests that cmake doesn't crash when generating these project files. if(CMAKE_GENERATOR MATCHES "^(Unix Makefiles|Ninja)$" AND NOT "${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") - foreach(extraGenerator + foreach( + extraGenerator + IN ITEMS "CodeBlocks" "CodeLite" "Eclipse CDT4" "Kate" "Sublime Text 2" - ) + ) string(REPLACE " " "" extraGeneratorTestName "Simple_${extraGenerator}Generator") add_test(${extraGeneratorTestName} ${CMAKE_CTEST_COMMAND} --build-and-test @@ -794,7 +796,7 @@ if(BUILD_TESTING) --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubProject/foo" --test-command foo ) - set_tests_properties ( SubProject-Stage2 PROPERTIES DEPENDS SubProject) + set_tests_properties(SubProject-Stage2 PROPERTIES DEPENDS SubProject) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubProject") endif() @@ -1130,7 +1132,7 @@ if(BUILD_TESTING) set(CPACK_GENERATOR_STRING_${CPackGen} ${CPackGen}) endif() set(CPackRun_CPackGen "-DCPackGen=${CPACK_GENERATOR_STRING_${CPackGen}}") - foreach(CPackComponentWay ${CWAYLST}) + foreach(CPackComponentWay IN LISTS CWAYLST) set(CPackRun_CPackComponentWay "-DCPackComponentWay=${CPackComponentWay}") add_test(CPackComponentsForAll-${CPackGen}-${CPackComponentWay} ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} @@ -1353,7 +1355,7 @@ if(BUILD_TESTING) --test-command complex) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ComplexOneConfig") # because of the registry write these tests depend on each other - set_tests_properties ( complex PROPERTIES DEPENDS complexOneConfig) + set_tests_properties(complex PROPERTIES DEPENDS complexOneConfig) add_test(Environment ${CMAKE_CTEST_COMMAND} --build-and-test @@ -1436,64 +1438,66 @@ if(BUILD_TESTING) endif() # test for Find modules, simple cases - foreach(_mod IN ITEMS - ALSA - Boost - BLAS - BZip2 - CURL - Cups - Doxygen - DevIL - EnvModules - EXPAT - Fontconfig - Freetype - GDAL - GIF - Git - GLEW - GLUT - GnuTLS - GSL - GTK2 - Iconv - ICU - Intl - Jasper - JNI - JPEG - JsonCpp - LAPACK - LibArchive - LibLZMA - LibRHash - Libinput - LibUV - LibXml2 - LibXslt - LTTngUST - ODBC - OpenACC - OpenAL - OpenCL - OpenGL - OpenMP - OpenSP - OpenSSL - MPI - PNG - Patch - PostgreSQL - Protobuf - SDL - SQLite3 - TIFF - Vulkan - X11 - XalanC - XercesC - ) + foreach( + _mod + IN ITEMS + ALSA + BLAS + Boost + BZip2 + Cups + CURL + DevIL + Doxygen + EnvModules + EXPAT + Fontconfig + Freetype + GDAL + GIF + Git + GLEW + GLUT + GnuTLS + GSL + GTK2 + Iconv + ICU + Intl + Jasper + JNI + JPEG + JsonCpp + LAPACK + LibArchive + Libinput + LibLZMA + LibRHash + LibUV + LibXml2 + LibXslt + LTTngUST + MPI + ODBC + OpenACC + OpenAL + OpenCL + OpenGL + OpenMP + OpenSP + OpenSSL + Patch + PNG + PostgreSQL + Protobuf + SDL + SQLite3 + TIFF + Vulkan + X11 + XalanC + XercesC + ) if(CMake_TEST_Find${_mod}) add_subdirectory(Find${_mod}) endif() @@ -1539,7 +1543,7 @@ if(BUILD_TESTING) # CMake_TEST_FindMatlab_MCR_ROOT_DIR: indicates an optional root directory for the MCR, required on Linux if(CMake_TEST_FindMatlab OR CMake_TEST_FindMatlab_ROOT_DIR OR CMake_TEST_FindMatlab_MCR OR CMake_TEST_FindMatlab_MCR_ROOT_DIR) - set(FindMatlab_additional_test_options ) + set(FindMatlab_additional_test_options) if(CMake_TEST_FindMatlab_MCR OR CMake_TEST_FindMatlab_MCR_ROOT_DIR) set(FindMatlab_additional_test_options -DIS_MCR=TRUE) endif() @@ -1573,7 +1577,7 @@ if(BUILD_TESTING) endif() set(ExternalProject_BUILD_OPTIONS "") - foreach(vcs CVS SVN GIT HG) + foreach(vcs IN ITEMS CVS SVN GIT HG) if(DEFINED CMake_TEST_ExternalProject_${vcs}) list(APPEND ExternalProject_BUILD_OPTIONS -DEP_TEST_${vcs}=${CMake_TEST_ExternalProject_${vcs}}) endif() @@ -1672,7 +1676,8 @@ if(BUILD_TESTING) RUN_SERIAL 1 TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT} WORKING_DIRECTORY ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate - DEPENDS ExternalProjectUpdateSetup ) + DEPENDS ExternalProjectUpdateSetup + ) execute_process( COMMAND ${CMAKE_COMMAND} @@ -1727,7 +1732,7 @@ if(BUILD_TESTING) function(add_tutorial_test step_name use_mymath tutorial_arg pass_regex) set(tutorial_test_name Tutorial${step_name}) set(tutorial_build_dir "${CMake_BINARY_DIR}/Tests/Tutorial/${step_name}") - if (use_mymath) + if(use_mymath) set(tutorial_build_options "") else() set(tutorial_test_name ${tutorial_test_name}_MYMATH) @@ -1751,7 +1756,7 @@ if(BUILD_TESTING) if(NOT CMake_TEST_EXTERNAL_CMAKE) foreach(STP RANGE 2 12) - if (STP EQUAL 8) + if(STP EQUAL 8) set(pass_regex ".*using log and exp") else() set(pass_regex "The square root of 25 is 5") @@ -2010,11 +2015,11 @@ if(BUILD_TESTING) --test-command Exec2 ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LinkLineOrder") - set_tests_properties ( qtwrapping PROPERTIES DEPENDS wrapping) - set_tests_properties ( testdriver1 PROPERTIES DEPENDS qtwrapping) - set_tests_properties ( testdriver2 PROPERTIES DEPENDS testdriver1) - set_tests_properties ( testdriver3 PROPERTIES DEPENDS testdriver2) - set_tests_properties ( linkorder2 PROPERTIES DEPENDS linkorder1) + set_tests_properties(qtwrapping PROPERTIES DEPENDS wrapping) + set_tests_properties(testdriver1 PROPERTIES DEPENDS qtwrapping) + set_tests_properties(testdriver2 PROPERTIES DEPENDS testdriver1) + set_tests_properties(testdriver3 PROPERTIES DEPENDS testdriver2) + set_tests_properties(linkorder2 PROPERTIES DEPENDS linkorder1) # Test static linking on toolchains known to support it. if((CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "LCC") @@ -2046,9 +2051,9 @@ if(BUILD_TESTING) "${CMake_BINARY_DIR}/Tests/SubDirSpaces/testfromsubdir.obj" ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubDirSpaces") - endif () + endif() - if (WIN32) + if(WIN32) add_test(SubDir ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/SubDir" @@ -2060,7 +2065,7 @@ if(BUILD_TESTING) "${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere" "${CMake_BINARY_DIR}/Tests/SubDir/testfromsubdir.obj" ) - else () + else() add_test(SubDir ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/SubDir" @@ -2072,7 +2077,7 @@ if(BUILD_TESTING) "${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere" "${CMake_BINARY_DIR}/Tests/SubDir/testfromsubdir.o" ) - endif () + endif() list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubDir") if(MSVC OR (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_C_SIMULATE_ID STREQUAL "MSVC")) @@ -2105,7 +2110,7 @@ if(BUILD_TESTING) ADD_TEST_MACRO(ModuleDefinition example_exe) endif() - if (CMAKE_C_COMPILER_ID MATCHES "Watcom" AND WIN32) + if(CMAKE_C_COMPILER_ID MATCHES "Watcom" AND WIN32) ADD_TEST_MACRO(WatcomRuntimeLibrary) endif() @@ -2182,7 +2187,7 @@ if(BUILD_TESTING) # The test (and tested property) works with .sln files, so it's skipped when: # * cmake --build is set up to use MSBuild, since the MSBuild invocation does not use the .sln file set(_last_test "") - foreach(config ${CMAKE_CONFIGURATION_TYPES}) + foreach(config IN LISTS CMAKE_CONFIGURATION_TYPES) add_test(NAME VSExcludeFromDefaultBuild-${config} COMMAND ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/VSExcludeFromDefaultBuild" @@ -2320,7 +2325,7 @@ if(BUILD_TESTING) ADD_TEST_MACRO(VSNASM VSNASM) endif() - if (CMake_TEST_GreenHillsMULTI) + if(CMake_TEST_GreenHillsMULTI) macro(add_test_GhsMulti test_name test_dir bin_sub_dir build_opts) separate_arguments(_ghs_build_opts UNIX_COMMAND ${build_opts}) separate_arguments(_ghs_toolset_extra UNIX_COMMAND ${ghs_toolset_extra}) @@ -2381,7 +2386,7 @@ if(BUILD_TESTING) set(ghs_config_name "__default__") endif() # test integrity build - if (NOT ghs_skip_integrity AND (NOT ghs_target_platform OR ghs_target_platform MATCHES "integrity")) + if(NOT ghs_skip_integrity AND (NOT ghs_target_platform OR ghs_target_platform MATCHES "integrity")) add_test_GhsMulti(integrityDDInt GhsMultiIntegrity/GhsMultiIntegrityDDInt "" "") add_test_GhsMulti(integrityMonolith GhsMultiIntegrity/GhsMultiIntegrityMonolith "" "") add_test_GhsMulti(integrityDD GhsMultiIntegrity/GhsMultiIntegrityDD "" "") @@ -2463,8 +2468,8 @@ if(BUILD_TESTING) add_test_VSAndroid(vs17 "Visual Studio 17 2022" "ARM") endif() - if (APPLE) - if (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + if(APPLE) + if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") set(BundleTestInstallDir "${CMake_BINARY_DIR}/Tests/BundleTest/InstallDirectory") add_test(BundleTest ${CMAKE_CTEST_COMMAND} @@ -2500,8 +2505,8 @@ if(BUILD_TESTING) add_subdirectory(ObjC) add_subdirectory(ObjCXX) - endif () - endif () + endif() + endif() if(APPLE AND CTEST_TEST_CPACK) add_test(BundleGeneratorTest ${CMAKE_CTEST_COMMAND} @@ -3222,24 +3227,24 @@ if(BUILD_TESTING) --output-log "${CMake_BINARY_DIR}/Tests/CTestTestFdSetSize/testOutput.log" ) - if (CMAKE_TESTS_CDASH_SERVER) + if(CMAKE_TESTS_CDASH_SERVER) set(regex "^([^:]+)://([^/]+)(.*)$") - if ("${CMAKE_TESTS_CDASH_SERVER}" MATCHES "${regex}") + if("${CMAKE_TESTS_CDASH_SERVER}" MATCHES "${regex}") set(protocol "${CMAKE_MATCH_1}") set(server "${CMAKE_MATCH_2}") set(path "${CMAKE_MATCH_3}") - else () + else() set(protocol "http") set(server "open.cdash.org") set(path "") message("warning: CMAKE_TESTS_CDASH_SERVER does not match expected regex...") message(" ...using default url='${protocol}://${server}${path}' for CTestTest[23]") - endif () - endif () + endif() + endif() - if (CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS AND CMAKE_TESTS_CDASH_SERVER) + if(CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS AND CMAKE_TESTS_CDASH_SERVER) configure_file("${CMake_SOURCE_DIR}/Tests/CTestTest/test.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestTest/test.cmake" @ONLY ESCAPE_QUOTES) add_test(CTestTest ${CMAKE_CTEST_COMMAND} @@ -3281,19 +3286,19 @@ if(BUILD_TESTING) # these tests take a long time, make sure they have it # if timeouts have not already been set get_test_property(CTestTest TIMEOUT PREVIOUS_TIMEOUT) - if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) - set_tests_properties ( CTestTest + if("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) + set_tests_properties(CTestTest PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) - endif () + endif() if(NOT CMake_TEST_EXTERNAL_CMAKE) get_test_property(CTestTest2 TIMEOUT PREVIOUS_TIMEOUT) if("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) - set_tests_properties ( CTestTest2 + set_tests_properties(CTestTest2 PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) endif() endif() - endif () + endif() if(CMake_TEST_EXTERNAL_CMAKE) set(CMAKE_SKIP_BOOTSTRAP_TEST 1) @@ -3329,10 +3334,9 @@ if(BUILD_TESTING) # provide more time for the bootstrap test get_test_property(BootstrapTest TIMEOUT PREVIOUS_TIMEOUT) - if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) - set_tests_properties ( BootstrapTest - PROPERTIES TIMEOUT 5400) - endif () + if("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) + set_tests_properties(BootstrapTest PROPERTIES TIMEOUT 5400) + endif() endif() if(CMAKE_Fortran_COMPILER) @@ -3411,7 +3415,7 @@ if(BUILD_TESTING) ) # E2K has broken Java RVM before 3.5.2 - if (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "e2k" AND _result EQUAL 0) + if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "e2k" AND _result EQUAL 0) string(REGEX MATCH "RVM ([0-9.]+)" RVMVER "${_version}") # Consider empty match a broken version too if("${CMAKE_MATCH_1}" VERSION_LESS "3.5.2") @@ -3434,7 +3438,7 @@ if(BUILD_TESTING) math(EXPR _object_mode "${CMAKE_SIZEOF_VOID_P} * 8") if(_result EQUAL 0 AND _version MATCHES "${_object_mode}-Bit") ## next test is valid only if Java version is less than 1.10 - if ("${Java_VERSION}" VERSION_LESS 1.10) + if("${Java_VERSION}" VERSION_LESS 1.10) add_test(NAME Java.Javah COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG> --build-and-test "${CMake_SOURCE_DIR}/Tests/JavaJavah" @@ -3446,7 +3450,7 @@ if(BUILD_TESTING) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJavah") endif() ## next test is valid only if Java is, at least, version 1.8 - if (NOT "${Java_VERSION}" VERSION_LESS 1.8) + if(NOT "${Java_VERSION}" VERSION_LESS 1.8) add_test(NAME Java.NativeHeaders COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG> --build-and-test "${CMake_SOURCE_DIR}/Tests/JavaNativeHeaders" @@ -3521,18 +3525,18 @@ if(BUILD_TESTING) endif() if(CMAKE_TEST_PLPLOT_DIR) - add_test(plplot ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_PLPLOT_DIR}/../../EasyDashboardScripts/plplot.cmake ) + add_test(plplot ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_PLPLOT_DIR}/../../EasyDashboardScripts/plplot.cmake) set_tests_properties ( plplot PROPERTIES TIMEOUT 5400) endif() if(CMAKE_TEST_CHICKEN_DIR) - add_test(Chicken ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_CHICKEN_DIR}/../../EasyDashboardScripts/Chicken.cmake ) - set_tests_properties ( Chicken PROPERTIES TIMEOUT 5400) + add_test(Chicken ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_CHICKEN_DIR}/../../EasyDashboardScripts/Chicken.cmake) + set_tests_properties(Chicken PROPERTIES TIMEOUT 5400) endif() if(CMAKE_TEST_KDELIBS_ALPHA_1_DIR) - add_test(KDELibsAlpha1 ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_KDELIBS_ALPHA_1_DIR}/../../EasyDashboardScripts/kdelibs.cmake ) - set_tests_properties ( KDELibsAlpha1 PROPERTIES TIMEOUT 5400) + add_test(KDELibsAlpha1 ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_KDELIBS_ALPHA_1_DIR}/../../EasyDashboardScripts/kdelibs.cmake) + set_tests_properties(KDELibsAlpha1 PROPERTIES TIMEOUT 5400) endif() # Define a set of "contract" tests, each activated by a cache entry @@ -3542,11 +3546,7 @@ if(BUILD_TESTING) # The directory should also contain a Configure.cmake file that # sets "CMake_TEST_CONTRACT_<project>_<var>" variables to configure # the code below. - foreach(project - PLplot - Trilinos - VTK - ) + foreach(project IN ITEMS PLplot Trilinos VTK) if(CMake_TEST_CONTRACT_${project}) include(Contracts/${project}/Configure.cmake) ADD_TEST_MACRO(Contracts.${project} ${CMake_TEST_CONTRACT_${project}_RUN_TEST}) diff --git a/Tests/CTestUpdateCommon.cmake b/Tests/CTestUpdateCommon.cmake index 0f8ec8e..467b41a 100644 --- a/Tests/CTestUpdateCommon.cmake +++ b/Tests/CTestUpdateCommon.cmake @@ -73,7 +73,7 @@ function(check_updates build) string(REGEX REPLACE "${rev_regex}" "\\1" element "${r}") set(element_${element} 1) endforeach() - foreach(element ${rev_elements}) + foreach(element IN LISTS rev_elements) if(NOT element_${element}) list(APPEND MISSING "global <${element}> element") endif() @@ -85,7 +85,7 @@ function(check_updates build) if(MISSING) # List the missing entries string(APPEND MSG "Update.xml is missing expected entries:\n") - foreach(f ${MISSING}) + foreach(f IN LISTS MISSING) string(APPEND MSG " ${f}\n") endforeach() else() @@ -97,7 +97,7 @@ function(check_updates build) if(EXTRA) # List the extra entries string(APPEND MSG "Update.xml has extra unexpected entries:\n") - foreach(f ${EXTRA}) + foreach(f IN LISTS EXTRA) string(APPEND MSG " ${f}\n") endforeach() else() diff --git a/Tests/CTestUpdateP4.cmake.in b/Tests/CTestUpdateP4.cmake.in index 8a99e67..2ac01e2 100644 --- a/Tests/CTestUpdateP4.cmake.in +++ b/Tests/CTestUpdateP4.cmake.in @@ -109,7 +109,7 @@ list(APPEND P4CMD ${P4_CLIENT}) message("Adding files to repository") file(GLOB_RECURSE files ${TOP}/user-source/*) -foreach(filename ${files}) +foreach(filename IN LISTS files) run_child( WORKING_DIRECTORY ${TOP}/user-source COMMAND ${P4CMD} add ${filename} @@ -140,14 +140,14 @@ run_child( # Make changes in the working tree. message("Changing content...") update_content(user-source files_added files_removed dirs_added) -foreach(filename ${files_added}) +foreach(filename IN LISTS files_added) message("add: ${filename}") run_child( WORKING_DIRECTORY ${TOP}/user-source COMMAND ${P4CMD} add ${TOP}/user-source/${filename} ) endforeach() -foreach(filename ${files_removed}) +foreach(filename IN LISTS files_removed) run_child( WORKING_DIRECTORY ${TOP}/user-source COMMAND ${P4CMD} delete ${TOP}/user-source/${filename} diff --git a/Tests/EnforceConfig.cmake.in b/Tests/EnforceConfig.cmake.in index 7c6f76a..10f8461 100644 --- a/Tests/EnforceConfig.cmake.in +++ b/Tests/EnforceConfig.cmake.in @@ -10,7 +10,7 @@ if(NOT CTEST_CONFIGURATION_TYPE) set(CTEST_CMD "@CMAKE_CTEST_COMMAND@@CMAKE_EXECUTABLE_SUFFIX@") get_filename_component(CTEST_DIR "${CTEST_CMD}" PATH) get_filename_component(CTEST_EXE "${CTEST_CMD}" NAME) - foreach(cfg Release Debug MinSizeRel RelWithDebInfo) + foreach(cfg IN ITEMS Release Debug MinSizeRel RelWithDebInfo) if(NOT CTEST_CONFIGURATION_TYPE) if(EXISTS "${CTEST_DIR}/${cfg}/${CTEST_EXE}") set(CTEST_CONFIGURATION_TYPE ${cfg}) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index d802e1f..2f5bc87 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -527,7 +527,9 @@ function(add_RunCMake_test_try_compile) set(CMAKE_CXX_STANDARD_DEFAULT 14) endif() endif() - foreach(var + foreach( + var + IN ITEMS CMAKE_SYSTEM_NAME CMAKE_C_COMPILER_ID CMAKE_C_COMPILER_VERSION @@ -541,7 +543,7 @@ function(add_RunCMake_test_try_compile) CMake_TEST_FILESYSTEM_1S CMAKE_OBJC_STANDARD_DEFAULT CMAKE_OBJCXX_STANDARD_DEFAULT - ) + ) if(DEFINED ${var}) list(APPEND try_compile_ARGS -D${var}=${${var}}) endif() @@ -958,7 +960,7 @@ if(CMake_TEST_ANDROID_NDK OR CMake_TEST_ANDROID_STANDALONE_TOOLCHAIN) if(NOT "${CMAKE_GENERATOR}" MATCHES "Make|Ninja|Visual Studio 1[456]") message(FATAL_ERROR "Android tests supported only by Makefile, Ninja, and Visual Studio >= 14 generators") endif() - foreach(v TEST_ANDROID_NDK TEST_ANDROID_STANDALONE_TOOLCHAIN) + foreach(v IN ITEMS TEST_ANDROID_NDK TEST_ANDROID_STANDALONE_TOOLCHAIN) if(CMake_${v}) string(REPLACE ";" "|" ${v} "${CMake_${v}}") list(APPEND Android_ARGS "-D${v}=${${v}}") diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index 1c92ca0..c329b46 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -1,8 +1,10 @@ -foreach(arg +foreach( + arg + IN ITEMS RunCMake_GENERATOR RunCMake_SOURCE_DIR RunCMake_BINARY_DIR - ) + ) if(NOT DEFINED ${arg}) message(FATAL_ERROR "${arg} not given!") endif() @@ -31,7 +33,7 @@ function(run_cmake test) set(platform_name msys) endif() - foreach(o out err) + foreach(o IN ITEMS out err) if(RunCMake-std${o}-file AND EXISTS ${top_src}/${RunCMake-std${o}-file}) file(READ ${top_src}/${RunCMake-std${o}-file} expect_std${o}) string(REGEX REPLACE "\n+$" "" expect_std${o} "${expect_std${o}}") @@ -176,7 +178,7 @@ function(run_cmake test) "|[^\n]*Bullseye Testing Technology" ")[^\n]*\n)+" ) - foreach(o out err) + foreach(o IN ITEMS out err) string(REGEX REPLACE "\r\n" "\n" actual_std${o} "${actual_std${o}}") string(REGEX REPLACE "${ignore_line_regex}" "\\1" actual_std${o} "${actual_std${o}}") string(REGEX REPLACE "\n+$" "" actual_std${o} "${actual_std${o}}") diff --git a/Tests/VSGNUFortran/CMakeLists.txt b/Tests/VSGNUFortran/CMakeLists.txt index 993d0d6..2b4f4fa 100644 --- a/Tests/VSGNUFortran/CMakeLists.txt +++ b/Tests/VSGNUFortran/CMakeLists.txt @@ -11,7 +11,7 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") # to be in the same directory. get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(_isMultiConfig) - foreach(config ${CMAKE_CONFIGURATION_TYPES}) + foreach(config IN LISTS CMAKE_CONFIGURATION_TYPES) string(TOUPPER "${config}" config) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${config} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) diff --git a/Tests/VSWinStorePhone/VerifyAppPackage.cmake b/Tests/VSWinStorePhone/VerifyAppPackage.cmake index f9440d7..52e8a54 100644 --- a/Tests/VSWinStorePhone/VerifyAppPackage.cmake +++ b/Tests/VSWinStorePhone/VerifyAppPackage.cmake @@ -26,7 +26,7 @@ if(NOT result EQUAL 0) message(FATAL_ERROR "Listing app package content failed with: ${error}") endif() -foreach(app_pkg_item ${EXPECTED_APP_PKG_CONTENT}) +foreach(app_pkg_item IN LISTS EXPECTED_APP_PKG_CONTENT) string(FIND ${APP_PKG_CONTENT_OUTPUT} ${app_pkg_item} _found) if(_found EQUAL -1) message(FATAL_ERROR "Generated app package is missing an expected item: ${app_pkg_item}") diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt index ffca624..886f4e0 100644 --- a/Utilities/Sphinx/CMakeLists.txt +++ b/Utilities/Sphinx/CMakeLists.txt @@ -161,7 +161,7 @@ endif() set(doc_format_outputs "") set(doc_format_last "") -foreach(format ${doc_formats}) +foreach(format IN LISTS doc_formats) set(doc_format_output "doc_format_${format}") set(doc_format_log "build-${format}.log") if(CMake_SPHINX_CMAKE_ORG) @@ -219,13 +219,7 @@ endforeach() add_custom_target(documentation ALL DEPENDS ${doc_format_outputs}) if(CMake_SPHINX_DEPEND_ON_EXECUTABLES) - foreach(t - cmake - ccmake - cmake-gui - cpack - ctest - ) + foreach(t IN ITEMS cmake ccmake cmake-gui cpack ctest) if(TARGET ${t}) # Build documentation after main executables. add_dependencies(documentation ${t}) @@ -248,7 +242,7 @@ endif() if(SPHINX_MAN) file(GLOB man_rst RELATIVE ${CMake_SOURCE_DIR}/Help/manual ${CMake_SOURCE_DIR}/Help/manual/*.[1-9].rst) - foreach(m ${man_rst}) + foreach(m IN LISTS man_rst) if("x${m}" MATCHES "^x(.+)\\.([1-9])\\.rst$") set(name "${CMAKE_MATCH_1}") set(sec "${CMAKE_MATCH_2}") diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt index b8cf412..9b468c3 100644 --- a/Utilities/cmcurl/CMakeLists.txt +++ b/Utilities/cmcurl/CMakeLists.txt @@ -852,11 +852,11 @@ endif() # Check for symbol dlopen (same as HAVE_LIBDL) check_library_exists("${CURL_LIBS}" dlopen "" HAVE_DLOPEN) -if(0) # This code not needed for building within CMake. set(HAVE_LIBZ OFF) set(HAVE_ZLIB_H OFF) set(USE_ZLIB OFF) -optional_dependency(ZLIB) +#optional_dependency(ZLIB) +find_package(ZLIB) if(ZLIB_FOUND) set(HAVE_ZLIB_H ON) set(HAVE_LIBZ ON) @@ -870,19 +870,8 @@ if(ZLIB_FOUND) else() list(APPEND CURL_LIBS ${ZLIB_LIBRARIES}) include_directories(${ZLIB_INCLUDE_DIRS}) + list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS}) endif() - list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS}) -endif() -endif() - -#----------------------------------------------------------------------------- -# CMake-specific curl code. - -if(CURL_SPECIAL_LIBZ) - set(CURL_LIBS ${CURL_LIBS} "${CURL_SPECIAL_LIBZ}") - include_directories(${CURL_SPECIAL_LIBZ_INCLUDES}) - set(HAVE_LIBZ 0) - set(HAVE_ZLIB_H 0) endif() option(CURL_BROTLI "Set to ON to enable building curl with brotli support." OFF) diff --git a/Utilities/cmcurl/lib/content_encoding.c b/Utilities/cmcurl/lib/content_encoding.c index c03637a..4c723c3 100644 --- a/Utilities/cmcurl/lib/content_encoding.c +++ b/Utilities/cmcurl/lib/content_encoding.c @@ -27,7 +27,7 @@ #include <stddef.h> #ifdef HAVE_ZLIB_H -#include <zlib.h> +#include <cm3p/zlib.h> #endif #ifdef HAVE_BROTLI diff --git a/Utilities/cmcurl/lib/version.c b/Utilities/cmcurl/lib/version.c index e37253d..5e3e428 100644 --- a/Utilities/cmcurl/lib/version.c +++ b/Utilities/cmcurl/lib/version.c @@ -51,7 +51,7 @@ #endif #ifdef HAVE_ZLIB_H -#include <zlib.h> +#include <cm3p/zlib.h> #endif #ifdef HAVE_BROTLI diff --git a/Utilities/cmjsoncpp/CMakeLists.txt b/Utilities/cmjsoncpp/CMakeLists.txt index c384f4e..09579d2 100644 --- a/Utilities/cmjsoncpp/CMakeLists.txt +++ b/Utilities/cmjsoncpp/CMakeLists.txt @@ -21,5 +21,5 @@ include_directories( ) add_library(cmjsoncpp ${JSONCPP_SOURCES}) -target_link_libraries(cmjsoncpp ${CMake_KWIML_LIBRARIES}) +target_link_libraries(cmjsoncpp $<TARGET_NAME_IF_EXISTS:kwiml::kwiml>) set_property(TARGET cmjsoncpp PROPERTY CXX_INCLUDE_WHAT_YOU_USE "") diff --git a/Utilities/cmlibarchive/CMakeLists.txt b/Utilities/cmlibarchive/CMakeLists.txt index eea472f..b38e653 100644 --- a/Utilities/cmlibarchive/CMakeLists.txt +++ b/Utilities/cmlibarchive/CMakeLists.txt @@ -442,6 +442,8 @@ SET(ADDITIONAL_LIBS "") # IF(ENABLE_ZLIB) FIND_PACKAGE(ZLIB) + SET(ZLIB_INCLUDE_DIR "") + SET(ZLIB_LIBRARIES ZLIB::ZLIB) ELSE() SET(ZLIB_FOUND FALSE) # Override cached value ENDIF() @@ -281,6 +281,7 @@ CMAKE_UNUSED_SOURCES="\ " CMAKE_CXX_SOURCES="\ + cmAddCompileDefinitionsCommand \ cmAddCustomCommandCommand \ cmAddCustomTargetCommand \ cmAddDefinitionsCommand \ |