diff options
74 files changed, 677 insertions, 165 deletions
@@ -1,27 +1,30 @@ +/CMakeUserPresets.json + # Common build directories -build*/ +/build*/ -# Exclude MacOS Finder files. +# MacOS Finder files. .DS_Store -*.user* - +# Python compile output. *.pyc -Help/_generated -Testing -CMakeUserPresets.json +# See Utilities/Sphinx/tutorial_archive.cmake +/Help/_generated -# Visual Studio work directory -.vs/ -# Visual Studio build directory -out/ +# CLion work directory +/.idea/ +# CLion build directories +/cmake-build-*/ + +# QtCreator files. +/CMakeLists.txt.user* # Visual Studio Code -.vscode/ -.cache/ +/.vscode/ +/.cache/ -# CLion work directory -.idea/ -# CLion build directories -cmake-build-*/ +# Visual Studio work directory +/.vs/ +# Visual Studio build directory +/out/ diff --git a/.gitlab/ci/configure_macos_arm64_ninja.cmake b/.gitlab/ci/configure_macos_arm64_ninja.cmake index f59b43c..f2068a1 100644 --- a/.gitlab/ci/configure_macos_arm64_ninja.cmake +++ b/.gitlab/ci/configure_macos_arm64_ninja.cmake @@ -1,3 +1,4 @@ +set(CMake_TEST_FindOpenAL "ON" CACHE BOOL "") set(CMake_TEST_FindOpenMP "ON" CACHE BOOL "") set(CMake_TEST_FindOpenMP_C "ON" CACHE BOOL "") set(CMake_TEST_FindOpenMP_CXX "ON" CACHE BOOL "") diff --git a/.gitlab/ci/configure_macos_x86_64_makefiles.cmake b/.gitlab/ci/configure_macos_x86_64_makefiles.cmake index 3c5d8fe..5d1620d 100644 --- a/.gitlab/ci/configure_macos_x86_64_makefiles.cmake +++ b/.gitlab/ci/configure_macos_x86_64_makefiles.cmake @@ -1,3 +1,4 @@ +set(CMake_TEST_FindOpenAL "ON" CACHE BOOL "") set(CMake_TEST_FindOpenMP "ON" CACHE BOOL "") set(CMake_TEST_FindOpenMP_C "ON" CACHE BOOL "") set(CMake_TEST_FindOpenMP_CXX "ON" CACHE BOOL "") diff --git a/.gitlab/ci/configure_macos_x86_64_ninja.cmake b/.gitlab/ci/configure_macos_x86_64_ninja.cmake index 3c5d8fe..5d1620d 100644 --- a/.gitlab/ci/configure_macos_x86_64_ninja.cmake +++ b/.gitlab/ci/configure_macos_x86_64_ninja.cmake @@ -1,3 +1,4 @@ +set(CMake_TEST_FindOpenAL "ON" CACHE BOOL "") set(CMake_TEST_FindOpenMP "ON" CACHE BOOL "") set(CMake_TEST_FindOpenMP_C "ON" CACHE BOOL "") set(CMake_TEST_FindOpenMP_CXX "ON" CACHE BOOL "") diff --git a/Auxiliary/vim/syntax/cmake.vim b/Auxiliary/vim/syntax/cmake.vim index 1a47f67..3a44d7a 100644 --- a/Auxiliary/vim/syntax/cmake.vim +++ b/Auxiliary/vim/syntax/cmake.vim @@ -690,11 +690,14 @@ syn keyword cmakeVariable contained \ CMAKE_AUTOMOC_MOC_OPTIONS \ CMAKE_AUTOMOC_PATH_PREFIX \ CMAKE_AUTOMOC_RELAXED_MODE + \ CMAKE_AUTOMOC_EXECUTABLE \ CMAKE_AUTORCC \ CMAKE_AUTORCC_OPTIONS + \ CMAKE_AUTORCC_EXECUTABLE \ CMAKE_AUTOUIC \ CMAKE_AUTOUIC_OPTIONS \ CMAKE_AUTOUIC_SEARCH_PATHS + \ CMAKE_AUTOUIC_EXECUTABLE \ CMAKE_BACKWARDS_COMPATIBILITY \ CMAKE_BINARY_DIR \ CMAKE_BUILD_RPATH diff --git a/Help/command/UNSET_NOTE.txt b/Help/command/UNSET_NOTE.txt new file mode 100644 index 0000000..8dc9125 --- /dev/null +++ b/Help/command/UNSET_NOTE.txt @@ -0,0 +1,9 @@ +.. note:: + + When evaluating :ref:`Variable References` of the form ``${VAR}``, CMake + first searches for a normal variable with that name. If no such normal + variable exists, CMake will then search for a cache entry with that name. + Because of this, **unsetting a normal variable can expose a cache variable + that was previously hidden**. To force a variable reference of the form + ``${VAR}`` to return an empty string, use ``set(<variable> "")``, which + clears the normal variable but leaves it defined. diff --git a/Help/command/file.rst b/Help/command/file.rst index 25b762c..30a7f4d 100644 --- a/Help/command/file.rst +++ b/Help/command/file.rst @@ -341,12 +341,13 @@ Reading On Windows platforms, library resolution works as follows: - 1. The dependent DLL name is converted to lowercase. Windows DLL names are - case-insensitive, and some linkers mangle the case of the DLL dependency - names. However, this makes it more difficult for ``PRE_INCLUDE_REGEXES``, - ``PRE_EXCLUDE_REGEXES``, ``POST_INCLUDE_REGEXES``, and - ``POST_EXCLUDE_REGEXES`` to properly filter DLL names - every regex would - have to check for both uppercase and lowercase letters. For example: + 1. DLL dependency names are converted to lowercase for matching filters. + Windows DLL names are case-insensitive, and some linkers mangle the + case of the DLL dependency names. However, this makes it more difficult + for ``PRE_INCLUDE_REGEXES``, ``PRE_EXCLUDE_REGEXES``, + ``POST_INCLUDE_REGEXES``, and ``POST_EXCLUDE_REGEXES`` to properly + filter DLL names - every regex would have to check for both uppercase + and lowercase letters. For example: .. code-block:: cmake @@ -369,9 +370,15 @@ Reading either on disk or in the depending file. (For example, it will match ``mylibrary.dll``, ``MyLibrary.dll``, and ``MYLIBRARY.DLL``.) - Please note that the directory portion of any resolved DLLs retains its - casing and is not converted to lowercase. Only the filename portion is - converted. + .. versionchanged:: 3.27 + + The conversion to lowercase only applies while matching filters. + Results reported after filtering case-preserve each DLL name as it is + found on disk, if resolved, and otherwise as it is referenced by the + dependent binary. + + Prior to CMake 3.27, the results were reported with lowercase DLL + file names, but the directory portion retained its casing. 2. (**Not yet implemented**) If the depending file is a Windows Store app, and the dependency is listed as a dependency in the application's package diff --git a/Help/command/set.rst b/Help/command/set.rst index ee677c9..aeb88b3 100644 --- a/Help/command/set.rst +++ b/Help/command/set.rst @@ -8,9 +8,8 @@ and cache entries. Signatures of this command that specify a ``<value>...`` placeholder expect zero or more arguments. Multiple arguments will be joined as -a :ref:`semicolon-separated list <CMake Language Lists>` to form the actual variable -value to be set. Zero arguments will cause normal variables to be -unset. See the :command:`unset` command to unset variables explicitly. +a :ref:`semicolon-separated list <CMake Language Lists>` to form the +actual variable value to be set. Set Normal Variable ^^^^^^^^^^^^^^^^^^^ @@ -19,7 +18,11 @@ Set Normal Variable set(<variable> <value>... [PARENT_SCOPE]) :target: normal - Sets the given ``<variable>`` in the current function or directory scope. + Set or unset ``<variable>`` in the current function or directory scope: + + * If at least one ``<value>...`` is given, set the variable to that value. + * If no value is given, unset the variable. This is equivalent to + :command:`unset(<variable>) <unset>`. If the ``PARENT_SCOPE`` option is given the variable will be set in the scope above the current scope. Each new directory or :command:`function` @@ -34,6 +37,8 @@ Set Normal Variable can be used as an alternate method to the :command:`set(PARENT_SCOPE)` and :command:`unset(PARENT_SCOPE)` commands to update the parent scope. +.. include:: UNSET_NOTE.txt + Set Cache Entry ^^^^^^^^^^^^^^^ diff --git a/Help/command/target_compile_options.rst b/Help/command/target_compile_options.rst index 698f62d..f3ac97b 100644 --- a/Help/command/target_compile_options.rst +++ b/Help/command/target_compile_options.rst @@ -50,6 +50,10 @@ See Also * For file-specific settings, there is the source file property :prop_sf:`COMPILE_OPTIONS`. +* This command adds compile options for all languages in a target. + Use the :genex:`COMPILE_LANGUAGE` generator expression to specify + per-language compile options. + * :command:`target_compile_features` * :command:`target_link_libraries` * :command:`target_link_directories` diff --git a/Help/command/unset.rst b/Help/command/unset.rst index 1cd1398..522be89 100644 --- a/Help/command/unset.rst +++ b/Help/command/unset.rst @@ -12,19 +12,14 @@ Unset Normal Variable or Cache Entry Removes a normal variable from the current scope, causing it to become undefined. If ``CACHE`` is present, then a cache variable -is removed instead of a normal variable. Note that when evaluating -:ref:`Variable References` of the form ``${VAR}``, CMake first searches -for a normal variable with that name. If no such normal variable exists, -CMake will then search for a cache entry with that name. Because of this -unsetting a normal variable can expose a cache variable that was previously -hidden. To force a variable reference of the form ``${VAR}`` to return an -empty string, use ``set(<variable> "")``, which clears the normal variable -but leaves it defined. +is removed instead of a normal variable. If ``PARENT_SCOPE`` is present then the variable is removed from the scope above the current scope. See the same option in the :command:`set` command for further details. +.. include:: UNSET_NOTE.txt + Unset Environment Variable ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 1b7113e..f3212de 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -404,11 +404,14 @@ Variables that Control the Build /variable/CMAKE_AUTOMOC_MACRO_NAMES /variable/CMAKE_AUTOMOC_MOC_OPTIONS /variable/CMAKE_AUTOMOC_PATH_PREFIX + /variable/CMAKE_AUTOMOC_EXECUTABLE /variable/CMAKE_AUTORCC /variable/CMAKE_AUTORCC_OPTIONS + /variable/CMAKE_AUTORCC_EXECUTABLE /variable/CMAKE_AUTOUIC /variable/CMAKE_AUTOUIC_OPTIONS /variable/CMAKE_AUTOUIC_SEARCH_PATHS + /variable/CMAKE_AUTOUIC_EXECUTABLE /variable/CMAKE_BUILD_RPATH /variable/CMAKE_BUILD_RPATH_USE_ORIGIN /variable/CMAKE_BUILD_WITH_INSTALL_NAME_DIR diff --git a/Help/prop_tgt/COMPILE_OPTIONS.rst b/Help/prop_tgt/COMPILE_OPTIONS.rst index 0fd6aac..0dec250 100644 --- a/Help/prop_tgt/COMPILE_OPTIONS.rst +++ b/Help/prop_tgt/COMPILE_OPTIONS.rst @@ -11,6 +11,10 @@ The options will be added after after flags in the variables, but before those propagated from dependencies by the :prop_tgt:`INTERFACE_COMPILE_OPTIONS` property. +This property adds compile options for all languages in a target. +Use the :genex:`COMPILE_LANGUAGE` generator expression to specify +per-language compile options. + This property is initialized by the :prop_dir:`COMPILE_OPTIONS` directory property when a target is created, and is used by the generators to set the options for the compiler. diff --git a/Help/prop_tgt/LANG_CLANG_TIDY.rst b/Help/prop_tgt/LANG_CLANG_TIDY.rst index 31f1876..1e10933 100644 --- a/Help/prop_tgt/LANG_CLANG_TIDY.rst +++ b/Help/prop_tgt/LANG_CLANG_TIDY.rst @@ -25,3 +25,8 @@ command line. This property is initialized by the value of the :variable:`CMAKE_<LANG>_CLANG_TIDY` variable if it is set when a target is created. + +.. versionadded:: 3.27 + + This property supports + :manual:`generator expressions <cmake-generator-expressions(7)>`. diff --git a/Help/prop_tgt/LANG_CPPCHECK.rst b/Help/prop_tgt/LANG_CPPCHECK.rst index 80acbc0..0b2dee6 100644 --- a/Help/prop_tgt/LANG_CPPCHECK.rst +++ b/Help/prop_tgt/LANG_CPPCHECK.rst @@ -15,3 +15,8 @@ tool returns non-zero. This property is initialized by the value of the :variable:`CMAKE_<LANG>_CPPCHECK` variable if it is set when a target is created. + +.. versionadded:: 3.27 + + This property supports + :manual:`generator expressions <cmake-generator-expressions(7)>`. diff --git a/Help/prop_tgt/LANG_CPPLINT.rst b/Help/prop_tgt/LANG_CPPLINT.rst index be6db46..38a1669 100644 --- a/Help/prop_tgt/LANG_CPPLINT.rst +++ b/Help/prop_tgt/LANG_CPPLINT.rst @@ -13,3 +13,8 @@ and report any problems. This property is initialized by the value of the :variable:`CMAKE_<LANG>_CPPLINT` variable if it is set when a target is created. + +.. versionadded:: 3.27 + + This property supports + :manual:`generator expressions <cmake-generator-expressions(7)>`. diff --git a/Help/prop_tgt/LANG_INCLUDE_WHAT_YOU_USE.rst b/Help/prop_tgt/LANG_INCLUDE_WHAT_YOU_USE.rst index eebef56..19b97f7 100644 --- a/Help/prop_tgt/LANG_INCLUDE_WHAT_YOU_USE.rst +++ b/Help/prop_tgt/LANG_INCLUDE_WHAT_YOU_USE.rst @@ -13,3 +13,8 @@ compiler and report a warning if the tool reports any problems. This property is initialized by the value of the :variable:`CMAKE_<LANG>_INCLUDE_WHAT_YOU_USE` variable if it is set when a target is created. + +.. versionadded:: 3.27 + + This property supports + :manual:`generator expressions <cmake-generator-expressions(7)>`. diff --git a/Help/release/3.26.rst b/Help/release/3.26.rst index ee98a98..67ace4a 100644 --- a/Help/release/3.26.rst +++ b/Help/release/3.26.rst @@ -169,3 +169,15 @@ Other Changes * The :option:`cmake --trace` option now follows :command:`try_compile` and :command:`try_run` invocations. + +Updates +======= + +Changes made since CMake 3.26.0 include the following. + +3.26.1, 3.26.2 +-------------- + +* These versions made no changes to documented features or interfaces. + Some implementation updates were made to support ecosystem changes + and/or fix regressions. diff --git a/Help/release/dev/FindPython-Windows-ARM.rst b/Help/release/dev/FindPython-Windows-ARM.rst new file mode 100644 index 0000000..d88a65a --- /dev/null +++ b/Help/release/dev/FindPython-Windows-ARM.rst @@ -0,0 +1,5 @@ +FindPython-Windows-ARM +---------------------- + +* :module:`FindPython`, :module:`FindPython2` and :module:`FindPython3` modules + learn to manage ``Windows/ARM`` platform. diff --git a/Help/release/dev/autogen-exe-vars.rst b/Help/release/dev/autogen-exe-vars.rst new file mode 100644 index 0000000..a386b4f --- /dev/null +++ b/Help/release/dev/autogen-exe-vars.rst @@ -0,0 +1,7 @@ +autogen-exe-vars +---------------- + +* The :variable:`CMAKE_AUTOMOC_EXECUTABLE`, + :variable:`CMAKE_AUTORCC_EXECUTABLE`, and + :variable:`CMAKE_AUTOUIC_EXECUTABLE` variables were added to initialize the + corresponding target properties as targets are created. diff --git a/Help/release/dev/file-GET_RUNTIME_DEPENDENCIES-windows-casing.rst b/Help/release/dev/file-GET_RUNTIME_DEPENDENCIES-windows-casing.rst new file mode 100644 index 0000000..858f8b3 --- /dev/null +++ b/Help/release/dev/file-GET_RUNTIME_DEPENDENCIES-windows-casing.rst @@ -0,0 +1,7 @@ +file-GET_RUNTIME_DEPENDENCIES-windows-casing +-------------------------------------------- + + +* The :command:`file(GET_RUNTIME_DEPENDENCIES)` command now case-preserves + DLL names reported on Windows. They are still converted to lowercase + for filter matching. diff --git a/Help/release/dev/lint-genex.rst b/Help/release/dev/lint-genex.rst new file mode 100644 index 0000000..8da30b0 --- /dev/null +++ b/Help/release/dev/lint-genex.rst @@ -0,0 +1,7 @@ +lint-genex +---------- + +* The :prop_tgt:`<LANG>_CLANG_TIDY`, :prop_tgt:`<LANG>_CPPCHECK`, + :prop_tgt:`<LANG>_CPPLINT`, and :prop_tgt:`<LANG>_INCLUDE_WHAT_YOU_USE`, + target properties now support + :manual:`generator expressions <cmake-generator-expressions(7)>`. diff --git a/Help/variable/CMAKE_AUTOMOC_EXECUTABLE.rst b/Help/variable/CMAKE_AUTOMOC_EXECUTABLE.rst new file mode 100644 index 0000000..150a73a --- /dev/null +++ b/Help/variable/CMAKE_AUTOMOC_EXECUTABLE.rst @@ -0,0 +1,10 @@ +CMAKE_AUTOMOC_EXECUTABLE +------------------------ + +.. versionadded:: 3.27 + +This variable is used to initialize the :prop_tgt:`AUTOMOC_EXECUTABLE` +property on all the targets. See that target property for additional +information. + +By default it is empty. diff --git a/Help/variable/CMAKE_AUTORCC_EXECUTABLE.rst b/Help/variable/CMAKE_AUTORCC_EXECUTABLE.rst new file mode 100644 index 0000000..52d7faa --- /dev/null +++ b/Help/variable/CMAKE_AUTORCC_EXECUTABLE.rst @@ -0,0 +1,10 @@ +CMAKE_AUTORCC_EXECUTABLE +------------------------ + +.. versionadded:: 3.27 + +This variable is used to initialize the :prop_tgt:`AUTORCC_EXECUTABLE` +property on all the targets. See that target property for additional +information. + +By default it is empty. diff --git a/Help/variable/CMAKE_AUTOUIC_EXECUTABLE.rst b/Help/variable/CMAKE_AUTOUIC_EXECUTABLE.rst new file mode 100644 index 0000000..b2ebd7f --- /dev/null +++ b/Help/variable/CMAKE_AUTOUIC_EXECUTABLE.rst @@ -0,0 +1,10 @@ +CMAKE_AUTOUIC_EXECUTABLE +------------------------ + +.. versionadded:: 3.27 + +This variable is used to initialize the :prop_tgt:`AUTOUIC_EXECUTABLE` +property on all the targets. See that target property for additional +information. + +By default it is empty. diff --git a/Help/variable/CMAKE_CROSSCOMPILING.rst b/Help/variable/CMAKE_CROSSCOMPILING.rst index 7e6ec33..16dbfa5 100644 --- a/Help/variable/CMAKE_CROSSCOMPILING.rst +++ b/Help/variable/CMAKE_CROSSCOMPILING.rst @@ -1,15 +1,15 @@ CMAKE_CROSSCOMPILING -------------------- -Intended to indicate whether CMake is cross compiling, but note limitations -discussed below. +This variable is set by CMake to indicate whether it is cross compiling, +but note limitations discussed below. This variable will be set to true by CMake if the :variable:`CMAKE_SYSTEM_NAME` variable has been set manually (i.e. in a toolchain file or as a cache entry from the :manual:`cmake <cmake(1)>` command line). In most cases, manually -setting :variable:`CMAKE_SYSTEM_NAME` will only be done when cross compiling, -since it will otherwise be given the same value as -:variable:`CMAKE_HOST_SYSTEM_NAME` if not manually set, which is correct for +setting :variable:`CMAKE_SYSTEM_NAME` will only be done when cross compiling +since, if not manually set, it will be given the same value as +:variable:`CMAKE_HOST_SYSTEM_NAME`, which is correct for the non-cross-compiling case. In the event that :variable:`CMAKE_SYSTEM_NAME` is manually set to the same value as :variable:`CMAKE_HOST_SYSTEM_NAME`, then ``CMAKE_CROSSCOMPILING`` will still be set to true. diff --git a/Modules/CMakeDetermineSwiftCompiler.cmake b/Modules/CMakeDetermineSwiftCompiler.cmake index aaad560..f0a63a8 100644 --- a/Modules/CMakeDetermineSwiftCompiler.cmake +++ b/Modules/CMakeDetermineSwiftCompiler.cmake @@ -63,6 +63,65 @@ if(NOT CMAKE_Swift_COMPILER_ID_RUN) CMAKE_DETERMINE_COMPILER_ID(Swift "" CompilerId/main.swift) endif() +# Check if we are using the old compiler driver. +if(CMAKE_GENERATOR STREQUAL "Xcode") + # For Xcode, we can decide driver kind simply by Swift version. + if(CMAKE_Swift_COMPILER_VERSION VERSION_GREATER_EQUAL 5.5) + set(CMAKE_Swift_COMPILER_USE_OLD_DRIVER FALSE) + else() + set(CMAKE_Swift_COMPILER_USE_OLD_DRIVER TRUE) + endif() +elseif(NOT DEFINED CMAKE_Swift_COMPILER_USE_OLD_DRIVER) + # Dry-run a WMO build to identify the compiler driver. + + # Create a clean directory in which to run the test. + set(CMAKE_Swift_COMPILER_DRIVER_TEST_DIR ${CMAKE_PLATFORM_INFO_DIR}/SwiftCompilerDriver) + file(REMOVE_RECURSE "${CMAKE_Swift_COMPILER_DRIVER_TEST_DIR}") + file(MAKE_DIRECTORY "${CMAKE_Swift_COMPILER_DRIVER_TEST_DIR}") + + # Create a Swift file and an arbitrary linker resource. + file(WRITE ${CMAKE_Swift_COMPILER_DRIVER_TEST_DIR}/main.swift "print(\"Hello\")\n") + file(WRITE ${CMAKE_Swift_COMPILER_DRIVER_TEST_DIR}/lib.in "\n") + + # Honor user-specified compiler flags. + if(DEFINED CMAKE_Swift_FLAGS) + separate_arguments(_CMAKE_Swift_COMPILER_FLAGS_LIST NATIVE_COMMAND "${CMAKE_Swift_FLAGS}") + else() + separate_arguments(_CMAKE_Swift_COMPILER_FLAGS_LIST NATIVE_COMMAND "${CMAKE_Swift_FLAGS_INIT}") + endif() + set(_CMAKE_Swift_COMPILER_CHECK_COMMAND "${CMAKE_Swift_COMPILER}" ${_CMAKE_Swift_COMPILER_FLAGS_LIST} -wmo main.swift lib.in "-###") + unset(_CMAKE_Swift_COMPILER_FLAGS_LIST) + + # Execute in dry-run mode so no compilation will be actually performed. + execute_process(COMMAND ${_CMAKE_Swift_COMPILER_CHECK_COMMAND} + WORKING_DIRECTORY "${CMAKE_Swift_COMPILER_DRIVER_TEST_DIR}" + OUTPUT_VARIABLE _CMAKE_Swift_COMPILER_CHECK_OUTPUT) + + # Check the first frontend execution. It is on the first line of output. + # The old driver treats all inputs as Swift sources while the new driver + # can identify "lib.in" as a linker resource. + if("${_CMAKE_Swift_COMPILER_CHECK_OUTPUT}" MATCHES "^[^\n]* lib\\.in") + set(CMAKE_Swift_COMPILER_USE_OLD_DRIVER TRUE) + else() + set(CMAKE_Swift_COMPILER_USE_OLD_DRIVER FALSE) + endif() + + # Record the check results in the configure log. + list(TRANSFORM _CMAKE_Swift_COMPILER_CHECK_COMMAND PREPEND "\"") + list(TRANSFORM _CMAKE_Swift_COMPILER_CHECK_COMMAND APPEND "\"") + list(JOIN _CMAKE_Swift_COMPILER_CHECK_COMMAND " " _CMAKE_Swift_COMPILER_CHECK_COMMAND) + string(REPLACE "\n" "\n " _CMAKE_Swift_COMPILER_CHECK_OUTPUT " ${_CMAKE_Swift_COMPILER_CHECK_OUTPUT}") + message(CONFIGURE_LOG + "Detected CMAKE_Swift_COMPILER_USE_OLD_DRIVER=\"${CMAKE_Swift_COMPILER_USE_OLD_DRIVER}\" from:\n" + " ${_CMAKE_Swift_COMPILER_CHECK_COMMAND}\n" + "with output:\n" + "${_CMAKE_Swift_COMPILER_CHECK_OUTPUT}" + ) + + unset(_CMAKE_Swift_COMPILER_CHECK_COMMAND) + unset(_CMAKE_Swift_COMPILER_CHECK_OUTPUT) +endif() + if (NOT _CMAKE_TOOLCHAIN_LOCATION) get_filename_component(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_Swift_COMPILER}" PATH) endif () diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake index d4dcc62..386be73 100644 --- a/Modules/CMakeDetermineSystem.cmake +++ b/Modules/CMakeDetermineSystem.cmake @@ -176,6 +176,13 @@ else() set(CMAKE_SYSTEM_VERSION "${CMAKE_HOST_SYSTEM_VERSION}") endif() set(CMAKE_SYSTEM_PROCESSOR "${CMAKE_HOST_SYSTEM_PROCESSOR}") + if(CMAKE_CROSSCOMPILING) + message(AUTHOR_WARNING + "CMAKE_CROSSCOMPILING has been set by the project, toolchain file, or user. " + "CMake is resetting it to false because CMAKE_SYSTEM_NAME was not set. " + "To indicate cross compilation, only CMAKE_SYSTEM_NAME needs to be set." + ) + endif() set(CMAKE_CROSSCOMPILING FALSE) set(PRESET_CMAKE_SYSTEM_NAME FALSE) endif() diff --git a/Modules/CMakeSwiftCompiler.cmake.in b/Modules/CMakeSwiftCompiler.cmake.in index 47ada38..b385190 100644 --- a/Modules/CMakeSwiftCompiler.cmake.in +++ b/Modules/CMakeSwiftCompiler.cmake.in @@ -13,4 +13,6 @@ set(CMAKE_Swift_COMPILER_ENV_VAR "SWIFTC") set(CMAKE_Swift_COMPILER_ID_RUN 1) set(CMAKE_Swift_SOURCE_FILE_EXTENSIONS swift) +set(CMAKE_Swift_COMPILER_USE_OLD_DRIVER "@CMAKE_Swift_COMPILER_USE_OLD_DRIVER@") + set(CMAKE_Swift_IMPLICIT_INCLUDE_DIRECTORIES "@CMAKE_Swift_IMPLICIT_INCLUDE_DIRECTORIES@") diff --git a/Modules/CMakeSwiftInformation.cmake b/Modules/CMakeSwiftInformation.cmake index d27aa3f..777c680 100644 --- a/Modules/CMakeSwiftInformation.cmake +++ b/Modules/CMakeSwiftInformation.cmake @@ -78,9 +78,17 @@ if(CMAKE_GENERATOR STREQUAL "Xcode") set(CMAKE_Swift_FLAGS_MINSIZEREL_INIT "-Osize") else() set(CMAKE_Swift_FLAGS_DEBUG_INIT "-Onone -g -incremental") - set(CMAKE_Swift_FLAGS_RELEASE_INIT "-O -wmo") - set(CMAKE_Swift_FLAGS_RELWITHDEBINFO_INIT "-O -g -wmo") - set(CMAKE_Swift_FLAGS_MINSIZEREL_INIT "-Osize -wmo") + set(CMAKE_Swift_FLAGS_RELEASE_INIT "-O") + set(CMAKE_Swift_FLAGS_RELWITHDEBINFO_INIT "-O -g") + set(CMAKE_Swift_FLAGS_MINSIZEREL_INIT "-Osize") + + # Enable Whole Module Optimization by default unless the old + # C++ driver is being used, which behaves differently under WMO. + if(NOT CMAKE_Swift_COMPILER_USE_OLD_DRIVER) + string(APPEND CMAKE_Swift_FLAGS_RELEASE_INIT " -wmo") + string(APPEND CMAKE_Swift_FLAGS_RELWITHDEBINFO_INIT " -wmo") + string(APPEND CMAKE_Swift_FLAGS_MINSIZEREL_INIT " -wmo") + endif() endif() if(CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF") diff --git a/Modules/Compiler/IBMClang.cmake b/Modules/Compiler/IBMClang.cmake index a9d760f..169a0f0 100644 --- a/Modules/Compiler/IBMClang.cmake +++ b/Modules/Compiler/IBMClang.cmake @@ -43,7 +43,10 @@ macro(__compiler_ibmclang lang) set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES) set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES) - set(_CMAKE_LTO_THIN TRUE) + # Thin LTO is not yet supported on AIX. + if(NOT (CMAKE_SYSTEM_NAME STREQUAL "AIX")) + set(_CMAKE_LTO_THIN TRUE) + endif() if(_CMAKE_LTO_THIN) set(CMAKE_${lang}_COMPILE_OPTIONS_IPO "-flto=thin") diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 62c492c..96c71c2 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -217,16 +217,9 @@ endif() # Test first if the current compilers automatically wrap HDF5 function(_HDF5_test_regular_compiler_C success version is_parallel) - set(scratch_directory - ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5) if(NOT ${success} OR - NOT EXISTS ${scratch_directory}/compiler_has_h5_c) - set(test_file ${scratch_directory}/cmake_hdf5_test.c) - # CXX project without C enabled - if(CMAKE_CXX_COMPILER_LOADED AND NOT CMAKE_C_COMPILER_LOADED) - set(test_file ${scratch_directory}/cmake_hdf5_test.cpp) - endif() - file(WRITE ${test_file} + NOT EXISTS ${_HDF5_TEST_DIR}/compiler_has_h5_c) + file(WRITE "${_HDF5_TEST_SRC}" "#include <hdf5.h>\n" "const char* info_ver = \"INFO\" \":\" H5_VERSION;\n" "#ifdef H5_HAVE_PARALLEL\n" @@ -242,12 +235,12 @@ function(_HDF5_test_regular_compiler_C success version is_parallel) " fid = H5Fcreate(\"foo.h5\",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);\n" " return 0;\n" "}") - try_compile(${success} SOURCES ${test_file} - COPY_FILE ${scratch_directory}/compiler_has_h5_c + try_compile(${success} SOURCES "${_HDF5_TEST_SRC}" + COPY_FILE ${_HDF5_TEST_DIR}/compiler_has_h5_c ) endif() - if(${success} AND EXISTS ${scratch_directory}/compiler_has_h5_c) - file(STRINGS ${scratch_directory}/compiler_has_h5_c INFO_STRINGS + if(${success} AND EXISTS ${_HDF5_TEST_DIR}/compiler_has_h5_c) + file(STRINGS ${_HDF5_TEST_DIR}/compiler_has_h5_c INFO_STRINGS REGEX "^INFO:" ) string(REGEX MATCH "^INFO:([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?" @@ -268,11 +261,9 @@ function(_HDF5_test_regular_compiler_C success version is_parallel) endfunction() function(_HDF5_test_regular_compiler_CXX success version is_parallel) - set(scratch_directory ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5) if(NOT ${success} OR - NOT EXISTS ${scratch_directory}/compiler_has_h5_cxx) - set(test_file ${scratch_directory}/cmake_hdf5_test.cxx) - file(WRITE ${test_file} + NOT EXISTS ${_HDF5_TEST_DIR}/compiler_has_h5_cxx) + file(WRITE "${_HDF5_TEST_SRC}" "#include <H5Cpp.h>\n" "#ifndef H5_NO_NAMESPACE\n" "using namespace H5;\n" @@ -290,12 +281,12 @@ function(_HDF5_test_regular_compiler_CXX success version is_parallel) " H5File file(\"foo.h5\", H5F_ACC_TRUNC);\n" " return 0;\n" "}") - try_compile(${success} SOURCES ${test_file} - COPY_FILE ${scratch_directory}/compiler_has_h5_cxx + try_compile(${success} SOURCES "${_HDF5_TEST_SRC}" + COPY_FILE ${_HDF5_TEST_DIR}/compiler_has_h5_cxx ) endif() - if(${success} AND EXISTS ${scratch_directory}/compiler_has_h5_cxx) - file(STRINGS ${scratch_directory}/compiler_has_h5_cxx INFO_STRINGS + if(${success} AND EXISTS ${_HDF5_TEST_DIR}/compiler_has_h5_cxx) + file(STRINGS ${_HDF5_TEST_DIR}/compiler_has_h5_cxx INFO_STRINGS REGEX "^INFO:" ) string(REGEX MATCH "^INFO:([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?" @@ -317,17 +308,14 @@ endfunction() function(_HDF5_test_regular_compiler_Fortran success is_parallel) if(NOT ${success}) - set(scratch_directory - ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5) - set(test_file ${scratch_directory}/cmake_hdf5_test.f90) - file(WRITE ${test_file} + file(WRITE "${_HDF5_TEST_SRC}" "program hdf5_hello\n" " use hdf5\n" " integer error\n" " call h5open_f(error)\n" " call h5close_f(error)\n" "end\n") - try_compile(${success} SOURCES ${test_file}) + try_compile(${success} SOURCES "${_HDF5_TEST_SRC}") if(${success}) execute_process(COMMAND ${CMAKE_Fortran_COMPILER} -showconfig OUTPUT_VARIABLE config_output @@ -359,19 +347,11 @@ function( _HDF5_invoke_compiler language output_var return_value_var version_var else() set(lib_type_args -shlib) endif() - set(scratch_dir ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5) - if("${language}" STREQUAL "C") - set(test_file ${scratch_dir}/cmake_hdf5_test.c) - elseif("${language}" STREQUAL "CXX") - set(test_file ${scratch_dir}/cmake_hdf5_test.cxx) - elseif("${language}" STREQUAL "Fortran") - set(test_file ${scratch_dir}/cmake_hdf5_test.f90) - endif() # Verify that the compiler wrapper can actually compile: sometimes the compiler # wrapper exists, but not the compiler. E.g. Miniconda / Anaconda Python execute_process( - COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} ${test_file} - WORKING_DIRECTORY ${scratch_dir} + COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} "${_HDF5_TEST_SRC}" + WORKING_DIRECTORY ${_HDF5_TEST_DIR} OUTPUT_VARIABLE output ERROR_VARIABLE output RESULT_VARIABLE return_value @@ -381,8 +361,8 @@ function( _HDF5_invoke_compiler language output_var return_value_var version_var "HDF5 ${language} compiler wrapper is unable to compile a minimal HDF5 program.") else() execute_process( - COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} -show ${lib_type_args} ${test_file} - WORKING_DIRECTORY ${scratch_dir} + COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} -show ${lib_type_args} "${_HDF5_TEST_SRC}" + WORKING_DIRECTORY ${_HDF5_TEST_DIR} OUTPUT_VARIABLE output ERROR_VARIABLE output RESULT_VARIABLE return_value @@ -599,6 +579,7 @@ endif() if(NOT HDF5_FOUND) set(_HDF5_NEED_TO_SEARCH FALSE) + set(_HDF5_TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hdf5) set(HDF5_COMPILER_NO_INTERROGATE TRUE) # Only search for languages we've enabled foreach(_lang IN LISTS HDF5_LANGUAGE_BINDINGS) @@ -607,16 +588,23 @@ if(NOT HDF5_FOUND) # First check to see if our regular compiler is one of wrappers if(_lang STREQUAL "C") + set(_HDF5_TEST_SRC ${_HDF5_TEST_DIR}/cmake_hdf5_test.c) + if(CMAKE_CXX_COMPILER_LOADED AND NOT CMAKE_C_COMPILER_LOADED) + # CXX project without C enabled + set(_HDF5_TEST_SRC ${_HDF5_TEST_DIR}/cmake_hdf5_test.cxx) + endif() _HDF5_test_regular_compiler_C( HDF5_${_lang}_COMPILER_NO_INTERROGATE HDF5_${_lang}_VERSION HDF5_${_lang}_IS_PARALLEL) elseif(_lang STREQUAL "CXX") + set(_HDF5_TEST_SRC ${_HDF5_TEST_DIR}/cmake_hdf5_test.cxx) _HDF5_test_regular_compiler_CXX( HDF5_${_lang}_COMPILER_NO_INTERROGATE HDF5_${_lang}_VERSION HDF5_${_lang}_IS_PARALLEL) elseif(_lang STREQUAL "Fortran") + set(_HDF5_TEST_SRC ${_HDF5_TEST_DIR}/cmake_hdf5_test.f90) _HDF5_test_regular_compiler_Fortran( HDF5_${_lang}_COMPILER_NO_INTERROGATE HDF5_${_lang}_IS_PARALLEL) @@ -762,6 +750,8 @@ if(NOT HDF5_FOUND) endif() endif() endforeach() + unset(_HDF5_TEST_DIR) + unset(_HDF5_TEST_SRC) unset(_lib) else() set(_HDF5_NEED_TO_SEARCH TRUE) diff --git a/Modules/FindOpenAL.cmake b/Modules/FindOpenAL.cmake index 53aafdc..3d58569 100644 --- a/Modules/FindOpenAL.cmake +++ b/Modules/FindOpenAL.cmake @@ -105,18 +105,16 @@ find_package_handle_standard_args( mark_as_advanced(OPENAL_LIBRARY OPENAL_INCLUDE_DIR) -if(OPENAL_INCLUDE_DIR AND OPENAL_LIBRARY) - if(NOT TARGET OpenAL::OpenAL) - if(EXISTS "${OPENAL_LIBRARY}") - add_library(OpenAL::OpenAL UNKNOWN IMPORTED) - set_target_properties(OpenAL::OpenAL PROPERTIES - IMPORTED_LOCATION "${OPENAL_LIBRARY}") - else() - add_library(OpenAL::OpenAL INTERFACE IMPORTED) - set_target_properties(OpenAL::OpenAL PROPERTIES - IMPORTED_LIBNAME "${OPENAL_LIBRARY}") - endif() +if(OPENAL_FOUND AND NOT TARGET OpenAL::OpenAL) + if(OPENAL_LIBRARY MATCHES "/([^/]+)\\.framework$") + add_library(OpenAL::OpenAL INTERFACE IMPORTED) set_target_properties(OpenAL::OpenAL PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${OPENAL_INCLUDE_DIR}") + INTERFACE_LINK_LIBRARIES "${OPENAL_LIBRARY}") + else() + add_library(OpenAL::OpenAL UNKNOWN IMPORTED) + set_target_properties(OpenAL::OpenAL PROPERTIES + IMPORTED_LOCATION "${OPENAL_LIBRARY}") endif() + set_target_properties(OpenAL::OpenAL PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OPENAL_INCLUDE_DIR}") endif() diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index 517ac21..60d2296 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -192,28 +192,25 @@ function (_PYTHON_GET_REGISTRIES _PYTHON_PGR_REGISTRY_PATHS) if (implementation STREQUAL "CPython") foreach (version IN LISTS _PGR_VERSION) string (REPLACE "." "" version_no_dots ${version}) - list (APPEND registries - [HKEY_CURRENT_USER/SOFTWARE/Python/PythonCore/${version}-${_${_PYTHON_PREFIX}_ARCH}/InstallPath] - [HKEY_CURRENT_USER/SOFTWARE/Python/PythonCore/${version}-${_${_PYTHON_PREFIX}_ARCH2}/InstallPath]) + list (TRANSFORM _${_PYTHON_PREFIX}_ARCH REPLACE "^(.+)$" "[HKEY_CURRENT_USER/SOFTWARE/Python/PythonCore/${version}-\\1/InstallPath]" OUTPUT_VARIABLE reg_paths) + list (APPEND registries ${reg_paths}) if (version VERSION_GREATER_EQUAL "3.5") # cmake_host_system_information is not usable in bootstrap get_filename_component (arch "[HKEY_CURRENT_USER\\Software\\Python\\PythonCore\\${version};SysArchitecture]" NAME) - if (arch MATCHES "(${_${_PYTHON_PREFIX}_ARCH}|${_${_PYTHON_PREFIX}_ARCH2})bit") - list (APPEND registries - [HKEY_CURRENT_USER/SOFTWARE/Python/PythonCore/${version}/InstallPath]) + string (REPLACE "bit" "" arch "${arch}") + if (arch IN_LIST _${_PYTHON_PREFIX}_ARCH) + list (APPEND registries [HKEY_CURRENT_USER/SOFTWARE/Python/PythonCore/${version}/InstallPath]) endif() else() - list (APPEND registries - [HKEY_CURRENT_USER/SOFTWARE/Python/PythonCore/${version}/InstallPath]) - endif() - list (APPEND registries - [HKEY_CURRENT_USER/SOFTWARE/Python/ContinuumAnalytics/Anaconda${version_no_dots}-${_${_PYTHON_PREFIX}_ARCH}/InstallPath] - [HKEY_CURRENT_USER/SOFTWARE/Python/ContinuumAnalytics/Anaconda${version_no_dots}-${_${_PYTHON_PREFIX}_ARCH2}/InstallPath] - [HKEY_LOCAL_MACHINE/SOFTWARE/Python/PythonCore/${version}-${_${_PYTHON_PREFIX}_ARCH}/InstallPath] - [HKEY_LOCAL_MACHINE/SOFTWARE/Python/PythonCore/${version}-${_${_PYTHON_PREFIX}_ARCH2}/InstallPath] - [HKEY_LOCAL_MACHINE/SOFTWARE/Python/PythonCore/${version}/InstallPath] - [HKEY_LOCAL_MACHINE/SOFTWARE/Python/ContinuumAnalytics/Anaconda${version_no_dots}-${_${_PYTHON_PREFIX}_ARCH}/InstallPath] - [HKEY_LOCAL_MACHINE/SOFTWARE/Python/ContinuumAnalytics/Anaconda${version_no_dots}-${_${_PYTHON_PREFIX}_ARCH2}/InstallPath]) + list (APPEND registries [HKEY_CURRENT_USER/SOFTWARE/Python/PythonCore/${version}/InstallPath]) + endif() + list (TRANSFORM _${_PYTHON_PREFIX}_ARCH REPLACE "^(.+)$" "[HKEY_CURRENT_USER/SOFTWARE/Python/ContinuumAnalytics/Anaconda${version_no_dots}-\\1/InstallPath]" OUTPUT_VARIABLE reg_paths) + list (APPEND registries ${reg_paths}) + list (TRANSFORM _${_PYTHON_PREFIX}_ARCH REPLACE "^(.+)$" "[HKEY_CURRENT_USER/SOFTWARE/Python/PythonCore/${version}-\\1/InstallPath]" OUTPUT_VARIABLE reg_paths) + list (APPEND registries ${reg_paths}) + list (APPEND registries [HKEY_LOCAL_MACHINE/SOFTWARE/Python/PythonCore/${version}/InstallPath]) + list (TRANSFORM _${_PYTHON_PREFIX}_ARCH REPLACE "^(.+)$" "[HKEY_LOCAL_MACHINE/SOFTWARE/Python/ContinuumAnalytics/Anaconda${version_no_dots}-\\1/InstallPath]" OUTPUT_VARIABLE reg_paths) + list (APPEND registries ${reg_paths}) endforeach() elseif (implementation STREQUAL "IronPython") foreach (version IN LISTS _PGR_VERSION) @@ -927,6 +924,33 @@ function (_PYTHON_VALIDATE_INTERPRETER) set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") return() endif() + + if (WIN32) + # In this case, check if the interpreter is compatible with the target processor architecture + if (NOT CMAKE_GENERATOR_PLATFORM AND CMAKE_SYSTEM_PROCESSOR MATCHES "ARM" OR CMAKE_GENERATOR_PLATFORM MATCHES "ARM") + set(target_arm TRUE) + else() + set(target_arm FALSE) + endif() + execute_process (COMMAND ${launcher} "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c + "import sys, sysconfig; sys.stdout.write(sysconfig.get_platform())" + RESULT_VARIABLE result + OUTPUT_VARIABLE platform + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(TOUPPER "${platform}" platform) + if (result OR ((target_arm AND NOT platform MATCHES "ARM") OR + (NOT target_arm AND platform MATCHES "ARM"))) + # interpreter not usable or has wrong architecture + if (result) + set_property (CACHE _${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE PROPERTY VALUE "Cannot use the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"") + else() + set_property (CACHE _${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE PROPERTY VALUE "Wrong architecture for the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"") + endif() + set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") + return() + endif() + endif() endif() endfunction() @@ -1419,19 +1443,37 @@ if (CMAKE_SIZEOF_VOID_P) OR "Development.SABIModule" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS OR "Development.Embed" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) # In this case, search only for 64bit or 32bit - set (_${_PYTHON_PREFIX}_ARCH2 ${_${_PYTHON_PREFIX}_ARCH}) set (_${_PYTHON_PREFIX}_REGISTRY_VIEW REGISTRY_VIEW ${_${_PYTHON_PREFIX}_ARCH}) + if (WIN32 AND (NOT CMAKE_GENERATOR_PLATFORM AND CMAKE_SYSTEM_PROCESSOR MATCHES "ARM" + OR CMAKE_GENERATOR_PLATFORM MATCHES "ARM")) + # search exclusively ARM architecture: 64bit or 32bit + if (_${_PYTHON_PREFIX}_ARCH EQUAL 64) + set (_${_PYTHON_PREFIX}_ARCH ARM64) + else() + set (_${_PYTHON_PREFIX}_ARCH ARM) + endif() + endif() else() if (_${_PYTHON_PREFIX}_ARCH EQUAL "32") - set (_${_PYTHON_PREFIX}_ARCH2 64) + if (CMAKE_SYSTEM_PROCESSOR MATCHES "ARM") + # search first ARM architectures: 32bit and then 64bit + list (PREPEND _${_PYTHON_PREFIX}_ARCH ARM ARM64) + endif() + list (APPEND _${_PYTHON_PREFIX}_ARCH 64) else() - set (_${_PYTHON_PREFIX}_ARCH2 32) + if (CMAKE_SYSTEM_PROCESSOR MATCHES "ARM") + # search first ARM architectures: 64bit and then 32bit + list (PREPEND _${_PYTHON_PREFIX}_ARCH ARM64 ARM) + endif() + list (APPEND _${_PYTHON_PREFIX}_ARCH 32) endif() endif() else() # architecture unknown, search for both 64bit and 32bit - set (_${_PYTHON_PREFIX}_ARCH 64) - set (_${_PYTHON_PREFIX}_ARCH2 32) + set (_${_PYTHON_PREFIX}_ARCH 64 32) + if (CMAKE_SYSTEM_PROCESSOR MATCHES "ARM") + list (PREPEND _${_PYTHON_PREFIX}_ARCH ARM64 ARM) + endif() endif() # IronPython support @@ -1439,7 +1481,7 @@ unset (_${_PYTHON_PREFIX}_IRON_PYTHON_INTERPRETER_NAMES) unset (_${_PYTHON_PREFIX}_IRON_PYTHON_COMPILER_NAMES) unset (_${_PYTHON_PREFIX}_IRON_PYTHON_COMPILER_ARCH_FLAGS) if (CMAKE_SIZEOF_VOID_P) - if (_${_PYTHON_PREFIX}_ARCH EQUAL "32") + if (CMAKE_SIZEOF_VOID_P EQUAL "4") set (_${_PYTHON_PREFIX}_IRON_PYTHON_COMPILER_ARCH_FLAGS "/platform:x86") else() set (_${_PYTHON_PREFIX}_IRON_PYTHON_COMPILER_ARCH_FLAGS "/platform:x64") @@ -2048,7 +2090,6 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) list (GET _${_PYTHON_PREFIX}_INTERPRETER_PROPERTIES 3 ${_PYTHON_PREFIX}_VERSION_PATCH) list (GET _${_PYTHON_PREFIX}_INTERPRETER_PROPERTIES 4 _${_PYTHON_PREFIX}_ARCH) - set (_${_PYTHON_PREFIX}_ARCH2 ${_${_PYTHON_PREFIX}_ARCH}) list (GET _${_PYTHON_PREFIX}_INTERPRETER_PROPERTIES 5 _${_PYTHON_PREFIX}_ABIFLAGS) list (GET _${_PYTHON_PREFIX}_INTERPRETER_PROPERTIES 6 ${_PYTHON_PREFIX}_SOABI) @@ -2098,10 +2139,27 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) if (NOT _${_PYTHON_PREFIX}_RESULT) if (${_PYTHON_PREFIX}_IS64BIT) set (_${_PYTHON_PREFIX}_ARCH 64) - set (_${_PYTHON_PREFIX}_ARCH2 64) else() set (_${_PYTHON_PREFIX}_ARCH 32) - set (_${_PYTHON_PREFIX}_ARCH2 32) + endif() + endif() + + if (WIN32) + # check if architecture is Intel or ARM + execute_process (COMMAND ${_${_PYTHON_PREFIX}_INTERPRETER_LAUNCHER} "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c + "import sys; import sysconfig; sys.stdout.write(sysconfig.get_platform())" + RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT + OUTPUT_VARIABLE _${_PYTHON_PREFIX}_PLATFORM + ERROR_VARIABLE ${_PYTHON_PREFIX}_PLATFORM) + if (NOT _${_PYTHON_PREFIX}_RESULT) + string(TOUPPER "${_${_PYTHON_PREFIX}_PLATFORM}" _${_PYTHON_PREFIX}_PLATFORM) + if (_${_PYTHON_PREFIX}_PLATFORM MATCHES "ARM") + if (${_PYTHON_PREFIX}_IS64BIT) + set (_${_PYTHON_PREFIX}_ARCH ARM64) + else() + set (_${_PYTHON_PREFIX}_ARCH ARM) + endif() + endif() endif() endif() endif() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 531c841..281a8a9 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 26) -set(CMake_VERSION_PATCH 20230323) +set(CMake_VERSION_PATCH 20230330) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/cmBinUtilsWindowsPELinker.cxx b/Source/cmBinUtilsWindowsPELinker.cxx index 79e39e9..918f563 100644 --- a/Source/cmBinUtilsWindowsPELinker.cxx +++ b/Source/cmBinUtilsWindowsPELinker.cxx @@ -3,7 +3,10 @@ #include "cmBinUtilsWindowsPELinker.h" +#include <algorithm> +#include <iterator> #include <sstream> +#include <utility> #include <vector> #include <cm/memory> @@ -16,6 +19,27 @@ #ifdef _WIN32 # include <windows.h> + +# include "cmsys/Encoding.hxx" +#endif + +#ifdef _WIN32 +namespace { + +void ReplaceWithActualNameCasing(std::string& path) +{ + WIN32_FIND_DATAW findData; + HANDLE hFind = ::FindFirstFileW( + cmsys::Encoding::ToWindowsExtendedPath(path).c_str(), &findData); + + if (hFind != INVALID_HANDLE_VALUE) { + auto onDiskName = cmsys::Encoding::ToNarrow(findData.cFileName); + ::FindClose(hFind); + path.replace(path.end() - onDiskName.size(), path.end(), onDiskName); + } +} + +} #endif cmBinUtilsWindowsPELinker::cmBinUtilsWindowsPELinker( @@ -60,29 +84,47 @@ bool cmBinUtilsWindowsPELinker::ScanDependencies( if (!this->Tool->GetFileInfo(file, needed)) { return false; } - for (auto& n : needed) { - n = cmSystemTools::LowerCase(n); - } + + struct WinPEDependency + { + WinPEDependency(std::string o) + : Original(std::move(o)) + , LowerCase(cmSystemTools::LowerCase(Original)) + { + } + std::string const Original; + std::string const LowerCase; + }; + + std::vector<WinPEDependency> depends; + depends.reserve(needed.size()); + std::move(needed.begin(), needed.end(), std::back_inserter(depends)); std::string origin = cmSystemTools::GetFilenamePath(file); - for (auto const& lib : needed) { - if (!this->Archive->IsPreExcluded(lib)) { + for (auto const& lib : depends) { + if (!this->Archive->IsPreExcluded(lib.LowerCase)) { std::string path; bool resolved = false; - if (!this->ResolveDependency(lib, origin, path, resolved)) { + if (!this->ResolveDependency(lib.LowerCase, origin, path, resolved)) { return false; } if (resolved) { if (!this->Archive->IsPostExcluded(path)) { +#ifdef _WIN32 + ReplaceWithActualNameCasing(path); +#else + path.replace(path.end() - lib.Original.size(), path.end(), + lib.Original); +#endif bool unique; - this->Archive->AddResolvedPath(lib, path, unique); + this->Archive->AddResolvedPath(lib.Original, path, unique); if (unique && !this->ScanDependencies(path, cmStateEnums::SHARED_LIBRARY)) { return false; } } } else { - this->Archive->AddUnresolvedPath(lib); + this->Archive->AddUnresolvedPath(lib.Original); } } } diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 5601bf2..f6fdd48 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -165,6 +165,7 @@ std::vector<std::string> cmCommonTargetGenerator::GetLinkedTargetDirectories( { std::vector<std::string> dirs; std::set<cmGeneratorTarget const*> emitted; + cmGlobalCommonGenerator* const gg = this->GlobalCommonGenerator; if (cmComputeLinkInformation* cli = this->GeneratorTarget->GetLinkInformation(config)) { cmComputeLinkInformation::ItemVector const& items = cli->GetItems(); @@ -172,6 +173,8 @@ std::vector<std::string> cmCommonTargetGenerator::GetLinkedTargetDirectories( cmGeneratorTarget const* linkee = item.Target; if (linkee && !linkee->IsImported() + // Skip targets that build after this one in a static lib cycle. + && gg->TargetOrderIndexLess(linkee, this->GeneratorTarget) // We can ignore the INTERFACE_LIBRARY items because // Target->GetLinkInformation already processed their // link interface and they don't have any output themselves. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 7ed68d6..0e9f78e 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1727,8 +1727,7 @@ cmGlobalGenerator::GetLocalGeneratorTargetsInOrder(cmLocalGenerator* lg) const cm::append(gts, lg->GetGeneratorTargets()); std::sort(gts.begin(), gts.end(), [this](cmGeneratorTarget const* l, cmGeneratorTarget const* r) { - return this->TargetOrderIndex.at(l) < - this->TargetOrderIndex.at(r); + return this->TargetOrderIndexLess(l, r); }); return gts; } @@ -3068,6 +3067,12 @@ cmGlobalGenerator::GetTargetDirectDepends(cmGeneratorTarget const* target) return this->TargetDependencies[target]; } +bool cmGlobalGenerator::TargetOrderIndexLess(cmGeneratorTarget const* l, + cmGeneratorTarget const* r) const +{ + return this->TargetOrderIndex.at(l) < this->TargetOrderIndex.at(r); +} + bool cmGlobalGenerator::IsReservedTarget(std::string const& name) { // The following is a list of targets reserved diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 7de8215..4d321b5 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -479,6 +479,11 @@ public: TargetDependSet const& GetTargetDirectDepends( const cmGeneratorTarget* target); + // Return true if target 'l' occurs before 'r' in a global ordering + // of targets that respects inter-target dependencies. + bool TargetOrderIndexLess(cmGeneratorTarget const* l, + cmGeneratorTarget const* r) const; + const std::map<std::string, std::vector<cmLocalGenerator*>>& GetProjectMap() const { diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 75ed693..0c28776 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -949,8 +949,9 @@ void cmGlobalNinjaGenerator::EnableLanguage( mf->GetSafeDefinition(cmStrCat("CMAKE_", l, "_SIMULATE_ID")); std::string const& compilerFrontendVariant = mf->GetSafeDefinition( cmStrCat("CMAKE_", l, "_COMPILER_FRONTEND_VARIANT")); - this->SetUsingGCCOnWindows( - DetectGCCOnWindows(compilerId, simulateId, compilerFrontendVariant)); + if (DetectGCCOnWindows(compilerId, simulateId, compilerFrontendVariant)) { + this->MarkAsGCCOnWindows(); + } #endif } } @@ -2834,8 +2835,9 @@ int cmcmd_cmake_ninja_dyndep(std::vector<std::string>::const_iterator argBeg, cmGlobalNinjaGenerator& gg = cm::static_reference_cast<cmGlobalNinjaGenerator>(ggd); # ifdef _WIN32 - gg.SetUsingGCCOnWindows( - DetectGCCOnWindows(compilerId, simulateId, compilerFrontendVariant)); + if (DetectGCCOnWindows(compilerId, simulateId, compilerFrontendVariant)) { + gg.MarkAsGCCOnWindows(); + } # endif return gg.WriteDyndepFile(dir_top_src, dir_top_bld, dir_cur_src, dir_cur_bld, arg_dd, arg_ddis, module_dir, linked_target_dirs, diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 0af8cde..bd54168 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -169,7 +169,7 @@ public: const std::string& comment = ""); bool IsGCCOnWindows() const { return this->UsingGCCOnWindows; } - void SetUsingGCCOnWindows(bool b) { this->UsingGCCOnWindows = b; } + void MarkAsGCCOnWindows() { this->UsingGCCOnWindows = true; } cmGlobalNinjaGenerator(cmake* cm); diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 6c31da6..9220123 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -529,7 +529,7 @@ void cmInstallTargetGenerator::AddInstallNamePatchRule( std::ostream& os, Indent indent, const std::string& config, std::string const& toDestDirPath) { - if (this->ImportLibrary || + if (this->ImportLibrary || this->NamelinkMode == NamelinkModeOnly || !(this->Target->GetType() == cmStateEnums::SHARED_LIBRARY || this->Target->GetType() == cmStateEnums::MODULE_LIBRARY || this->Target->GetType() == cmStateEnums::EXECUTABLE)) { @@ -626,7 +626,8 @@ void cmInstallTargetGenerator::AddRPathCheckRule( std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. - if (this->ImportLibrary || !this->Target->IsChrpathUsed(config)) { + if (this->ImportLibrary || this->NamelinkMode == NamelinkModeOnly || + !this->Target->IsChrpathUsed(config)) { return; } // Skip if on Apple @@ -677,7 +678,8 @@ void cmInstallTargetGenerator::AddChrpathPatchRule( std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. - if (this->ImportLibrary || !this->Target->IsChrpathUsed(config)) { + if (this->ImportLibrary || this->NamelinkMode == NamelinkModeOnly || + !this->Target->IsChrpathUsed(config)) { return; } @@ -816,7 +818,7 @@ void cmInstallTargetGenerator::AddStripRule(std::ostream& os, Indent indent, // don't strip static and import libraries, because it removes the only // symbol table they have so you can't link to them anymore if (this->Target->GetType() == cmStateEnums::STATIC_LIBRARY || - this->ImportLibrary) { + this->ImportLibrary || this->NamelinkMode == NamelinkModeOnly) { return; } diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index e6f8cdd..3112acd 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1067,18 +1067,51 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( // Maybe insert an include-what-you-use runner. if (!compileCommands.empty() && (lang == "C" || lang == "CXX" || lang == "OBJC" || lang == "OBJCXX")) { - std::string const tidy_prop = lang + "_CLANG_TIDY"; - cmValue tidy = this->GeneratorTarget->GetProperty(tidy_prop); + cmValue tidy = nullptr; cmValue iwyu = nullptr; cmValue cpplint = nullptr; cmValue cppcheck = nullptr; + std::string evaluatedTIDY; + std::string evaluatedIWYU; + std::string evaluatedCPPlint; + std::string evaluatedCPPcheck; + + std::string const tidy_prop = cmStrCat(lang, "_CLANG_TIDY"); + tidy = this->GeneratorTarget->GetProperty(tidy_prop); + evaluatedTIDY = cmGeneratorExpression::Evaluate( + *tidy, this->LocalGenerator, config, this->GeneratorTarget, nullptr, + this->GeneratorTarget, lang); + if (!evaluatedTIDY.empty()) { + tidy = cmValue(&evaluatedTIDY); + } + if (lang == "C" || lang == "CXX") { - std::string const iwyu_prop = lang + "_INCLUDE_WHAT_YOU_USE"; + std::string const iwyu_prop = cmStrCat(lang, "_INCLUDE_WHAT_YOU_USE"); iwyu = this->GeneratorTarget->GetProperty(iwyu_prop); - std::string const cpplint_prop = lang + "_CPPLINT"; + evaluatedIWYU = cmGeneratorExpression::Evaluate( + *iwyu, this->LocalGenerator, config, this->GeneratorTarget, nullptr, + this->GeneratorTarget, lang); + if (!evaluatedIWYU.empty()) { + iwyu = cmValue(&evaluatedIWYU); + } + + std::string const cpplint_prop = cmStrCat(lang, "_CPPLINT"); cpplint = this->GeneratorTarget->GetProperty(cpplint_prop); - std::string const cppcheck_prop = lang + "_CPPCHECK"; + evaluatedCPPlint = cmGeneratorExpression::Evaluate( + *cpplint, this->LocalGenerator, config, this->GeneratorTarget, + nullptr, this->GeneratorTarget, lang); + if (!evaluatedCPPlint.empty()) { + cpplint = cmValue(&evaluatedCPPlint); + } + + std::string const cppcheck_prop = cmStrCat(lang, "_CPPCHECK"); cppcheck = this->GeneratorTarget->GetProperty(cppcheck_prop); + evaluatedCPPcheck = cmGeneratorExpression::Evaluate( + *cppcheck, this->LocalGenerator, config, this->GeneratorTarget, + nullptr, this->GeneratorTarget, lang); + if (!evaluatedCPPcheck.empty()) { + cppcheck = cmValue(&evaluatedCPPcheck); + } } if (cmNonempty(iwyu) || cmNonempty(tidy) || cmNonempty(cpplint) || cmNonempty(cppcheck)) { diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 4c0f935..e163edb 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -908,18 +908,51 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, // Maybe insert an include-what-you-use runner. if (!compileCmds.empty() && (lang == "C" || lang == "CXX" || lang == "OBJC" || lang == "OBJCXX")) { - std::string const tidy_prop = cmStrCat(lang, "_CLANG_TIDY"); - cmValue tidy = this->GeneratorTarget->GetProperty(tidy_prop); + cmValue tidy = nullptr; cmValue iwyu = nullptr; cmValue cpplint = nullptr; cmValue cppcheck = nullptr; + std::string evaluatedTIDY; + std::string evaluatedIWYU; + std::string evaluatedCPPlint; + std::string evaluatedCPPcheck; + + std::string const tidy_prop = cmStrCat(lang, "_CLANG_TIDY"); + tidy = this->GeneratorTarget->GetProperty(tidy_prop); + evaluatedTIDY = cmGeneratorExpression::Evaluate( + *tidy, this->LocalGenerator, config, this->GeneratorTarget, nullptr, + this->GeneratorTarget, lang); + if (!evaluatedTIDY.empty()) { + tidy = cmValue(&evaluatedTIDY); + } + if (lang == "C" || lang == "CXX") { std::string const iwyu_prop = cmStrCat(lang, "_INCLUDE_WHAT_YOU_USE"); iwyu = this->GeneratorTarget->GetProperty(iwyu_prop); + evaluatedIWYU = cmGeneratorExpression::Evaluate( + *iwyu, this->LocalGenerator, config, this->GeneratorTarget, nullptr, + this->GeneratorTarget, lang); + if (!evaluatedIWYU.empty()) { + iwyu = cmValue(&evaluatedIWYU); + } + std::string const cpplint_prop = cmStrCat(lang, "_CPPLINT"); cpplint = this->GeneratorTarget->GetProperty(cpplint_prop); + evaluatedCPPlint = cmGeneratorExpression::Evaluate( + *cpplint, this->LocalGenerator, config, this->GeneratorTarget, nullptr, + this->GeneratorTarget, lang); + if (!evaluatedCPPlint.empty()) { + cpplint = cmValue(&evaluatedCPPlint); + } + std::string const cppcheck_prop = cmStrCat(lang, "_CPPCHECK"); cppcheck = this->GeneratorTarget->GetProperty(cppcheck_prop); + evaluatedCPPcheck = cmGeneratorExpression::Evaluate( + *cppcheck, this->LocalGenerator, config, this->GeneratorTarget, + nullptr, this->GeneratorTarget, lang); + if (!evaluatedCPPcheck.empty()) { + cppcheck = cmValue(&evaluatedCPPcheck); + } } if (cmNonempty(iwyu) || cmNonempty(tidy) || cmNonempty(cpplint) || cmNonempty(cppcheck)) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 3f43183..5e55871 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -438,13 +438,16 @@ TargetProperty const StaticTargetProperties[] = { { "AUTOMOC_MACRO_NAMES"_s, IC::CanCompileSources }, { "AUTOMOC_MOC_OPTIONS"_s, IC::CanCompileSources }, { "AUTOMOC_PATH_PREFIX"_s, IC::CanCompileSources }, + { "AUTOMOC_EXECUTABLE"_s, IC::CanCompileSources }, // ---- uic { "AUTOUIC"_s, IC::CanCompileSources }, { "AUTOUIC_OPTIONS"_s, IC::CanCompileSources }, { "AUTOUIC_SEARCH_PATHS"_s, IC::CanCompileSources }, + { "AUTOUIC_EXECUTABLE"_s, IC::CanCompileSources }, // ---- rcc { "AUTORCC"_s, IC::CanCompileSources }, { "AUTORCC_OPTIONS"_s, IC::CanCompileSources }, + { "AUTORCC_EXECUTABLE"_s, IC::CanCompileSources }, // Linking properties { "ENABLE_EXPORTS"_s, IC::TargetWithSymbolExports }, diff --git a/Tests/CudaOnly/RuntimeControls/verify_runtime.cmake b/Tests/CudaOnly/RuntimeControls/verify_runtime.cmake index b313dac..27fbe45 100644 --- a/Tests/CudaOnly/RuntimeControls/verify_runtime.cmake +++ b/Tests/CudaOnly/RuntimeControls/verify_runtime.cmake @@ -7,7 +7,7 @@ file(GET_RUNTIME_DEPENDENCIES EXECUTABLES ${EXEC_PATH} ) -list(FILTER resolved_libs INCLUDE REGEX ".*cudart.*") +list(FILTER resolved_libs INCLUDE REGEX ".*[Cc][Uu][Dd][Aa][Rr][Tt].*") list(LENGTH resolved_libs has_cudart) if(has_cudart EQUAL 0) diff --git a/Tests/FindOpenAL/Test/CMakeLists.txt b/Tests/FindOpenAL/Test/CMakeLists.txt index fa3e263..6479df6 100644 --- a/Tests/FindOpenAL/Test/CMakeLists.txt +++ b/Tests/FindOpenAL/Test/CMakeLists.txt @@ -12,3 +12,9 @@ add_executable(test_var main.cxx) target_include_directories(test_var PRIVATE ${OPENAL_INCLUDE_DIR}) target_link_libraries(test_var PRIVATE ${OPENAL_LIBRARY}) add_test(NAME test_var COMMAND test_var) + +# OpenAL has been deprecated on macOS since Catalina (10.15) +if(APPLE) + target_compile_options(test_tgt PRIVATE "-Wno-deprecated-declarations") + target_compile_options(test_var PRIVATE "-Wno-deprecated-declarations") +endif() diff --git a/Tests/FindOpenAL/Test/main.cxx b/Tests/FindOpenAL/Test/main.cxx index bb45faf..1396c60 100644 --- a/Tests/FindOpenAL/Test/main.cxx +++ b/Tests/FindOpenAL/Test/main.cxx @@ -1,5 +1,10 @@ -#include <AL/al.h> -#include <AL/alc.h> +#ifdef __APPLE__ +# include "OpenAL/al.h" +# include "OpenAL/alc.h" +#else +# include <AL/al.h> +# include <AL/alc.h> +#endif #include <stdio.h> int main() diff --git a/Tests/FortranModules/Executable/CMakeLists.txt b/Tests/FortranModules/Executable/CMakeLists.txt index f31a3e6..182e23a 100644 --- a/Tests/FortranModules/Executable/CMakeLists.txt +++ b/Tests/FortranModules/Executable/CMakeLists.txt @@ -6,3 +6,4 @@ add_executable(subdir_exe2 main.f90) target_link_libraries(subdir_exe2 subdir_mods subdir_mods2) add_dependencies(subdir_exe2 ExternalTarget) target_link_libraries(subdir_exe2 myext) +target_link_libraries(subdir_exe2 cycleA) diff --git a/Tests/FortranModules/Executable/main.f90 b/Tests/FortranModules/Executable/main.f90 index 640259c..218eee6 100644 --- a/Tests/FortranModules/Executable/main.f90 +++ b/Tests/FortranModules/Executable/main.f90 @@ -3,5 +3,9 @@ PROGRAM MAINF90 USE libraryModuleB USE subdirModuleA USE externalMod + USE libraryCycleA + USE libraryCycleB CALL printExtModGreeting + CALL libraryCycleA2 + CALL libraryCycleB2 END PROGRAM MAINF90 diff --git a/Tests/FortranModules/Library/CMakeLists.txt b/Tests/FortranModules/Library/CMakeLists.txt index 17438ca..e525208 100644 --- a/Tests/FortranModules/Library/CMakeLists.txt +++ b/Tests/FortranModules/Library/CMakeLists.txt @@ -3,9 +3,14 @@ add_library(subdir_mods a.f90 b.f90) add_executable(subdir_exe main.f90) target_link_libraries(subdir_exe subdir_mods) +add_library(cycleA STATIC cycleA1.f90 cycleA2.f90) +add_library(cycleB STATIC cycleB1.f90 cycleB2.f90) +target_link_libraries(cycleA PRIVATE cycleB) +target_link_libraries(cycleB PRIVATE cycleA) + # Test module output directory if available. if(CMAKE_Fortran_MODDIR_FLAG) - set_target_properties(subdir_mods PROPERTIES + set_target_properties(subdir_mods cycleA cycleB PROPERTIES Fortran_MODULE_DIRECTORY modules ) endif() diff --git a/Tests/FortranModules/Library/cycleA1.f90 b/Tests/FortranModules/Library/cycleA1.f90 new file mode 100644 index 0000000..cceebe2 --- /dev/null +++ b/Tests/FortranModules/Library/cycleA1.f90 @@ -0,0 +1,3 @@ +subroutine cycleA1 +use libraryCycleA +end subroutine diff --git a/Tests/FortranModules/Library/cycleA2.f90 b/Tests/FortranModules/Library/cycleA2.f90 new file mode 100644 index 0000000..a2e432e --- /dev/null +++ b/Tests/FortranModules/Library/cycleA2.f90 @@ -0,0 +1,5 @@ +module libraryCycleA +contains + subroutine libraryCycleA2 + end subroutine +end module diff --git a/Tests/FortranModules/Library/cycleB1.f90 b/Tests/FortranModules/Library/cycleB1.f90 new file mode 100644 index 0000000..d6680fa --- /dev/null +++ b/Tests/FortranModules/Library/cycleB1.f90 @@ -0,0 +1,3 @@ +subroutine cycleB1 +use libraryCycleB +end subroutine diff --git a/Tests/FortranModules/Library/cycleB2.f90 b/Tests/FortranModules/Library/cycleB2.f90 new file mode 100644 index 0000000..07c774e --- /dev/null +++ b/Tests/FortranModules/Library/cycleB2.f90 @@ -0,0 +1,5 @@ +module libraryCycleB +contains + subroutine libraryCycleB2 + end subroutine +end module diff --git a/Tests/QtAutogen/GlobalAutogenExecutable/CMakeLists.txt b/Tests/QtAutogen/GlobalAutogenExecutable/CMakeLists.txt new file mode 100644 index 0000000..34da744 --- /dev/null +++ b/Tests/QtAutogen/GlobalAutogenExecutable/CMakeLists.txt @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 3.26) +project(GlobalAutogenExecutable) + +include("../AutogenCoreTest.cmake") + +set(test_automoc_path "global_automoc_exe_path") +set(test_autouic_path "global_autouic_exe_path") +set(test_autorcc_path "global_autorcc_exe_path") + +set(CMAKE_AUTOMOC_EXECUTABLE ${test_automoc_path}) +set(CMAKE_AUTOUIC_EXECUTABLE ${test_autouic_path}) +set(CMAKE_AUTORCC_EXECUTABLE ${test_autorcc_path}) + +add_executable(autogen_test main.cpp) + +get_target_property(target_automoc_path autogen_test AUTOMOC_EXECUTABLE) +get_target_property(target_autouic_path autogen_test AUTOUIC_EXECUTABLE) +get_target_property(target_autorcc_path autogen_test AUTORCC_EXECUTABLE) + +if(NOT ${target_automoc_path} STREQUAL ${test_automoc_path}) + message(FATAL_ERROR "CMAKE_AUTOMOC_EXECUTABLE not set") +endif() + +if (NOT ${target_autouic_path} STREQUAL ${test_autouic_path}) + message(FATAL_ERROR "CMAKE_AUTOUIC_EXECUTABLE not set") +endif() + +if (NOT ${target_autorcc_path} STREQUAL ${test_autorcc_path}) + message(FATAL_ERROR "CMAKE_AUTORCC_EXECUTABLE not set") +endif() diff --git a/Tests/QtAutogen/GlobalAutogenExecutable/main.cpp b/Tests/QtAutogen/GlobalAutogenExecutable/main.cpp new file mode 100644 index 0000000..f8b643a --- /dev/null +++ b/Tests/QtAutogen/GlobalAutogenExecutable/main.cpp @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/QtAutogen/Tests.cmake b/Tests/QtAutogen/Tests.cmake index a3c57a5..b507ab5 100644 --- a/Tests/QtAutogen/Tests.cmake +++ b/Tests/QtAutogen/Tests.cmake @@ -4,6 +4,7 @@ ADD_AUTOGEN_TEST(AutogenOriginDependsOn) ADD_AUTOGEN_TEST(AutogenTargetDepends) ADD_AUTOGEN_TEST(Complex QtAutogen) ADD_AUTOGEN_TEST(GlobalAutogenTarget) +ADD_AUTOGEN_TEST(GlobalAutogenExecutable) ADD_AUTOGEN_TEST(LowMinimumVersion lowMinimumVersion) ADD_AUTOGEN_TEST(ManySources manySources) ADD_AUTOGEN_TEST(MocOnly mocOnly) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 0ebb720..080740c 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -784,6 +784,7 @@ if(DEFINED CMake_COMPILER_FORCES_NEW_DTAGS) endif() add_RunCMake_test(file-GET_RUNTIME_DEPENDENCIES -DCMake_INSTALL_NAME_TOOL_BUG=${CMake_INSTALL_NAME_TOOL_BUG} + -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} ) add_RunCMake_test(CPackCommandLine) diff --git a/Tests/RunCMake/ClangTidy/CXX.cmake b/Tests/RunCMake/ClangTidy/CXX.cmake index 2d22325..3214122 100644 --- a/Tests/RunCMake/ClangTidy/CXX.cmake +++ b/Tests/RunCMake/ClangTidy/CXX.cmake @@ -1,3 +1,3 @@ enable_language(CXX) -set(CMAKE_CXX_CLANG_TIDY "${PSEUDO_TIDY}" -some -args) +set(CMAKE_CXX_CLANG_TIDY "$<1:${PSEUDO_TIDY}>" -some -args) add_executable(main main.cxx) diff --git a/Tests/RunCMake/Cppcheck/CXX.cmake b/Tests/RunCMake/Cppcheck/CXX.cmake index 3b79471..7030c61 100644 --- a/Tests/RunCMake/Cppcheck/CXX.cmake +++ b/Tests/RunCMake/Cppcheck/CXX.cmake @@ -1,3 +1,3 @@ enable_language(CXX) -set(CMAKE_CXX_CPPCHECK "${PSEUDO_CPPCHECK}") +set(CMAKE_CXX_CPPCHECK "$<1:${PSEUDO_CPPCHECK}>") add_executable(main main.cxx) diff --git a/Tests/RunCMake/Cpplint/CXX.cmake b/Tests/RunCMake/Cpplint/CXX.cmake index 35f05ee..b58609c 100644 --- a/Tests/RunCMake/Cpplint/CXX.cmake +++ b/Tests/RunCMake/Cpplint/CXX.cmake @@ -1,3 +1,3 @@ enable_language(CXX) -set(CMAKE_CXX_CPPLINT "${PSEUDO_CPPLINT}" --verbose=0 --linelength=80) +set(CMAKE_CXX_CPPLINT "$<1:${PSEUDO_CPPLINT}>" --verbose=0 --linelength=80) add_executable(main main.cxx) diff --git a/Tests/RunCMake/IncludeWhatYouUse/CXX.cmake b/Tests/RunCMake/IncludeWhatYouUse/CXX.cmake index 896930c..8780bb6 100644 --- a/Tests/RunCMake/IncludeWhatYouUse/CXX.cmake +++ b/Tests/RunCMake/IncludeWhatYouUse/CXX.cmake @@ -1,3 +1,3 @@ enable_language(CXX) -set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "${PSEUDO_IWYU}" -some -args) +set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "$<1:${PSEUDO_IWYU}>" -some -args) add_executable(main main.cxx) diff --git a/Tests/RunCMake/MultiLint/CXX.cmake b/Tests/RunCMake/MultiLint/CXX.cmake index dc30146..3e99e73 100644 --- a/Tests/RunCMake/MultiLint/CXX.cmake +++ b/Tests/RunCMake/MultiLint/CXX.cmake @@ -1,6 +1,6 @@ enable_language(CXX) -set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "${PSEUDO_IWYU}" -some -args) -set(CMAKE_CXX_CLANG_TIDY "${PSEUDO_TIDY}" -some -args) -set(CMAKE_CXX_CPPLINT "${PSEUDO_CPPLINT}" --verbose=0 --linelength=80) -set(CMAKE_CXX_CPPCHECK "${PSEUDO_CPPCHECK}") +set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "$<1:${PSEUDO_IWYU}>" -some -args) +set(CMAKE_CXX_CLANG_TIDY "$<1:${PSEUDO_TIDY}>" -some -args) +set(CMAKE_CXX_CPPLINT "$<1:${PSEUDO_CPPLINT}>" --verbose=0 --linelength=80) +set(CMAKE_CXX_CPPCHECK "$<1:${PSEUDO_CPPCHECK}>") add_executable(main main.cxx) diff --git a/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake b/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake index 7744ee8..b588ce0 100644 --- a/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake +++ b/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake @@ -14,6 +14,7 @@ run_cmake_toolchain(LinkFlagsInit) run_cmake_toolchain(CMP0126-NEW) run_cmake_toolchain(CMP0126-OLD) run_cmake_toolchain(CMP0126-WARN) +run_cmake_toolchain(SetCrossCompiling) function(run_IncludeDirectories) run_cmake_toolchain(IncludeDirectories) diff --git a/Tests/RunCMake/ToolchainFile/SetCrossCompiling-stderr.txt b/Tests/RunCMake/ToolchainFile/SetCrossCompiling-stderr.txt new file mode 100644 index 0000000..6642cf6 --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/SetCrossCompiling-stderr.txt @@ -0,0 +1,8 @@ +^CMake Warning \(dev\) at [^ +]*/Modules/CMakeDetermineSystem.cmake:[0-9]+ \(message\): + CMAKE_CROSSCOMPILING has been set by the project, toolchain file, or user\. + CMake is resetting it to false because CMAKE_SYSTEM_NAME was not set\. To + indicate cross compilation, only CMAKE_SYSTEM_NAME needs to be set\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(project\) +This warning is for project developers\. Use -Wno-dev to suppress it\.$ diff --git a/Tests/RunCMake/ToolchainFile/SetCrossCompiling-toolchain.cmake b/Tests/RunCMake/ToolchainFile/SetCrossCompiling-toolchain.cmake new file mode 100644 index 0000000..170e26c --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/SetCrossCompiling-toolchain.cmake @@ -0,0 +1 @@ +set(CMAKE_CROSSCOMPILING TRUE) diff --git a/Tests/RunCMake/ToolchainFile/SetCrossCompiling.cmake b/Tests/RunCMake/ToolchainFile/SetCrossCompiling.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/SetCrossCompiling.cmake diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/RunCMakeTest.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/RunCMakeTest.cmake index 43b406b..a68607e 100644 --- a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/RunCMakeTest.cmake +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/RunCMakeTest.cmake @@ -9,6 +9,10 @@ function(run_install_test case) run_cmake_command(${case}-build ${CMAKE_COMMAND} --build . --config Debug) # Check "all" components. set(CMAKE_INSTALL_PREFIX ${RunCMake_TEST_BINARY_DIR}/root-all) + set(maybe_stderr "${case}-all-stderr-${CMAKE_C_COMPILER_ID}.txt") + if(EXISTS "${RunCMake_SOURCE_DIR}/${maybe_stderr}") + set(RunCMake-stderr-file "${maybe_stderr}") + endif() run_cmake_command(${case}-all ${CMAKE_COMMAND} --install . --prefix ${CMAKE_INSTALL_PREFIX} --config Debug) endfunction() diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-all-check.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-all-check.cmake index cb0e534..10b7b82 100644 --- a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-all-check.cmake +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-all-check.cmake @@ -1,19 +1,29 @@ +if(CMAKE_C_COMPILER_ID STREQUAL "Borland") + # Borland upper-cases dll names referenced in import libraries. + set(conflict_dll [[CONFLICT\.DLL]]) + set(unresolved_dll [[UNRESOLVED\.DLL]]) +else() + set(conflict_dll [[conflict\.dll]]) + set(unresolved_dll [[unresolved\.dll]]) +endif() + set(_check [=[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-build/root-all/bin/\.conflict/\.\./(lib)?libdir\.dll]=] [=[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-build/root-all/bin/\.search/(lib)?search\.dll]=] + [=[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-build/root-all/bin/(lib)?MixedCase\.dll]=] [=[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-build/root-all/bin/(lib)?testlib\.dll]=] ) check_contents(deps/deps1.txt "^${_check}$") check_contents(deps/deps2.txt "^${_check}$") check_contents(deps/deps3.txt "^${_check}$") set(_check - [=[(lib)?unresolved\.dll]=] + "(lib)?${unresolved_dll}" ) check_contents(deps/udeps1.txt "^${_check}$") check_contents(deps/udeps2.txt "^${_check}$") check_contents(deps/udeps3.txt "^${_check}$") set(_check - "^(lib)?conflict\\.dll:[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-build/root-all/bin/\\.conflict/(lib)?conflict\\.dll;[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-build/root-all/bin/(lib)?conflict\\.dll\n$" + "^(lib)?${conflict_dll}:[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-build/root-all/bin/\\.conflict/(lib)?conflict\\.dll;[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-build/root-all/bin/(lib)?conflict\\.dll\n$" ) check_contents(deps/cdeps1.txt "${_check}") check_contents(deps/cdeps2.txt "${_check}") diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-conflict-all-stderr-Borland.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-conflict-all-stderr-Borland.txt new file mode 100644 index 0000000..607e4b8 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-conflict-all-stderr-Borland.txt @@ -0,0 +1,7 @@ +^CMake Error at cmake_install\.cmake:[0-9]+ \(file\): + file Multiple conflicting paths found for PATH\.DLL: + + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-conflict-build/root-all/lib/test1/path\.dll + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-conflict-build/root-all/lib/test2/path\.dll$ diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-unresolved-all-stderr-Borland.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-unresolved-all-stderr-Borland.txt new file mode 100644 index 0000000..fea1083 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows-unresolved-all-stderr-Borland.txt @@ -0,0 +1,4 @@ +^CMake Error at cmake_install\.cmake:[0-9]+ \(file\): + file Could not resolve runtime dependencies: + + UNRESOLVED\.DLL$ diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows.cmake index 9160ce5..aad9077 100644 --- a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows.cmake +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/windows.cmake @@ -8,6 +8,7 @@ set(testlib_names search unresolved conflict + MixedCase ) file(REMOVE "${CMAKE_BINARY_DIR}/testlib.c") @@ -34,7 +35,7 @@ file(WRITE "${CMAKE_BINARY_DIR}/testlib_noconflict.c" "__declspec(dllimport) ext add_library(testlib_noconflict SHARED "${CMAKE_BINARY_DIR}/testlib_noconflict.c") target_link_libraries(testlib_noconflict PRIVATE libdir) -install(TARGETS testlib libdir_postexcluded libdir conflict testlib_noconflict DESTINATION bin) +install(TARGETS testlib libdir_postexcluded libdir conflict MixedCase testlib_noconflict DESTINATION bin) install(TARGETS libdir search_postexcluded search DESTINATION bin/.search) # Prefixing with "." ensures it is the first item after list(SORT) install(TARGETS testlib_conflict conflict DESTINATION bin/.conflict) @@ -61,6 +62,7 @@ install(CODE [[ "^(lib)?search\\.dll$" "^(lib)?unresolved\\.dll$" "^(lib)?conflict\\.dll$" + "^(lib)?mixedcase\\.dll$" "^kernel32\\.dll$" PRE_EXCLUDE_REGEXES ".*" POST_INCLUDE_REGEXES @@ -68,6 +70,7 @@ install(CODE [[ "^.*/(lib)?libdir\\.dll$" "^.*/(lib)?search\\.dll$" "^.*/(lib)?conflict\\.dll$" + "^.*/(lib)?mixedcase\\.dll$" POST_EXCLUDE_REGEXES ".*" DIRECTORIES "${CMAKE_INSTALL_PREFIX}/bin/.search" diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake index e5a0413..efafdd1 100644 --- a/Tests/RunCMake/install/RunCMakeTest.cmake +++ b/Tests/RunCMake/install/RunCMakeTest.cmake @@ -121,6 +121,10 @@ run_install_test(FILES-OPTIONAL) run_install_test(DIRECTORY-OPTIONAL) run_install_test(TARGETS-Defaults) +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + run_install_test(TARGETS-NAMELINK-No-Tweak) +endif() + set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_BINDIR:PATH=mybin" "-DCMAKE_INSTALL_LIBDIR:PATH=mylib" diff --git a/Tests/RunCMake/install/TARGETS-NAMELINK-No-Tweak.cmake b/Tests/RunCMake/install/TARGETS-NAMELINK-No-Tweak.cmake new file mode 100644 index 0000000..879f4b8 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-NAMELINK-No-Tweak.cmake @@ -0,0 +1,20 @@ +enable_language(C) + +add_library(foo SHARED obj1.c) +set_target_properties(foo PROPERTIES + VERSION 1.0 + SOVERSION 1 + INSTALL_RPATH "$ORIGIN" + ) +install(TARGETS foo DESTINATION lib) + +# Replace the .so "namelink" symlink with a linker script. +# It is no longer a symlink, so any install tweaks would break. +# This verifies that no install tweaks are added for the namelink. +set(linker_script "INPUT($<TARGET_SONAME_FILE_NAME:foo>)") +add_custom_command(TARGET foo POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E remove "$<TARGET_LINKER_FILE:foo>" + COMMAND "${CMAKE_COMMAND}" -E echo "${linker_script}" > "$<TARGET_LINKER_FILE:foo>" + COMMENT "Generating linker script: '${linker_script}' as file $<TARGET_LINKER_FILE:foo>" + VERBATIM + ) |