diff options
74 files changed, 639 insertions, 155 deletions
diff --git a/Auxiliary/vim/syntax/cmake.vim b/Auxiliary/vim/syntax/cmake.vim index c95503b..d2cbdc9 100644 --- a/Auxiliary/vim/syntax/cmake.vim +++ b/Auxiliary/vim/syntax/cmake.vim @@ -2764,7 +2764,6 @@ syn keyword cmakeKWcmake_language contained \ DIRECTORY \ EVAL \ FALSE - \ FETCHCONTENT_MAKEAVAILABE_SERIAL \ FETCHCONTENT_MAKEAVAILABLE_SERIAL \ FETCHCONTENT_SOURCE_DIR_ \ FETCHCONTENT_TRY_FIND_PACKAGE_MODE diff --git a/Copyright.txt b/Copyright.txt index 515e403..2074109 100644 --- a/Copyright.txt +++ b/Copyright.txt @@ -1,5 +1,5 @@ CMake - Cross Platform Makefile Generator -Copyright 2000-2023 Kitware, Inc. and Contributors +Copyright 2000-2024 Kitware, Inc. and Contributors All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/Help/command/add_test.rst b/Help/command/add_test.rst index 37b9563..557c858 100644 --- a/Help/command/add_test.rst +++ b/Help/command/add_test.rst @@ -42,6 +42,12 @@ directory the test is created in. <emulator> <command> + .. versionchanged:: 3.29 + + The emulator is used only when + :variable:`cross-compiling <CMAKE_CROSSCOMPILING>`. + See policy :policy:`CMP0158`. + * .. versionadded:: 3.29 The target's :prop_tgt:`TEST_LAUNCHER`, if set, will be diff --git a/Help/command/cmake_language.rst b/Help/command/cmake_language.rst index 3af6b9c..4b64eb6 100644 --- a/Help/command/cmake_language.rst +++ b/Help/command/cmake_language.rst @@ -317,7 +317,7 @@ be one of the ``<methods>`` that was specified when setting the provider. implementation as part of its processing, it can do so by including the ``BYPASS_PROVIDER`` keyword as one of the arguments. -``FETCHCONTENT_MAKEAVAILABE_SERIAL`` +``FETCHCONTENT_MAKEAVAILABLE_SERIAL`` The ``<method-specific-args>`` will be everything passed to the :command:`FetchContent_Declare` call that corresponds to the requested dependency, with the following exceptions: diff --git a/Help/command/string.rst b/Help/command/string.rst index 0e69b27..2f01653 100644 --- a/Help/command/string.rst +++ b/Help/command/string.rst @@ -22,7 +22,7 @@ Synopsis string(`JOIN`_ <glue> <out-var> [<input>...]) string(`TOLOWER`_ <string> <out-var>) string(`TOUPPER`_ <string> <out-var>) - string(`LENGTH`_ <string> <out-var>) + string(`LENGTH <LENGTH_>`_ <string> <out-var>) string(`SUBSTRING`_ <string> <begin> <length> <out-var>) string(`STRIP`_ <string> <out-var>) string(`GENEX_STRIP`_ <string> <out-var>) diff --git a/Help/guide/tutorial/Step3/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step3/MathFunctions/CMakeLists.txt index ffb2f35..74c553f 100644 --- a/Help/guide/tutorial/Step3/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step3/MathFunctions/CMakeLists.txt @@ -14,9 +14,9 @@ if (USE_MYMATH) mysqrt.cxx ) - # TODO 7: Link SqrtLibrary to tutorial_compiler_flags + # TODO 6: Link SqrtLibrary to tutorial_compiler_flags target_link_libraries(MathFunctions PRIVATE SqrtLibrary) endif() -# TODO 6: Link MathFunctions to tutorial_compiler_flags +# TODO 7: Link MathFunctions to tutorial_compiler_flags diff --git a/Help/manual/cmake-file-api.7.rst b/Help/manual/cmake-file-api.7.rst index fd28dbe..c249ee2 100644 --- a/Help/manual/cmake-file-api.7.rst +++ b/Help/manual/cmake-file-api.7.rst @@ -998,35 +998,35 @@ with members: destination is available. The value is an unsigned integer 0-based index into the ``backtraceGraph`` member's ``nodes`` array. - ``launchers`` - Optional member that is present on executable targets that have - at least one launcher specified by the project. The value is a - JSON array of entries corresponding to the specified launchers. - Each entry is a JSON object with members: +``launchers`` + Optional member that is present on executable targets that have + at least one launcher specified by the project. The value is a + JSON array of entries corresponding to the specified launchers. + Each entry is a JSON object with members: - ``command`` - A string specifying the path to the launcher on disk, represented - with forward slashes. If the file is inside the top-level source - directory then the path is specified relative to that directory. + ``command`` + A string specifying the path to the launcher on disk, represented + with forward slashes. If the file is inside the top-level source + directory then the path is specified relative to that directory. - ``arguments`` - Optional member that is present when the launcher command has - arguments preceding the executable to be launched. The value - is a JSON array of strings representing the arguments. + ``arguments`` + Optional member that is present when the launcher command has + arguments preceding the executable to be launched. The value + is a JSON array of strings representing the arguments. - ``type`` - A string specifying the type of launcher. The value is one of - the following: + ``type`` + A string specifying the type of launcher. The value is one of + the following: - ``emulator`` - An emulator for the target platform when cross-compiling. - See the :prop_tgt:`CROSSCOMPILING_EMULATOR` target property. + ``emulator`` + An emulator for the target platform when cross-compiling. + See the :prop_tgt:`CROSSCOMPILING_EMULATOR` target property. - ``test`` - A start program for the execution of tests. - See the :prop_tgt:`TEST_LAUNCHER` target property. + ``test`` + A start program for the execution of tests. + See the :prop_tgt:`TEST_LAUNCHER` target property. - This field was added in codemodel version 2.7. + This field was added in codemodel version 2.7. ``link`` Optional member that is present for executables and shared library diff --git a/Help/manual/cmake-language.7.rst b/Help/manual/cmake-language.7.rst index d0774cb..dba953d 100644 --- a/Help/manual/cmake-language.7.rst +++ b/Help/manual/cmake-language.7.rst @@ -224,7 +224,7 @@ For example:: They interpret the opening bracket as the start of an `Unquoted Argument`_. -.. _`Lua`: http://www.lua.org/ +.. _`Lua`: https://www.lua.org/ .. _`Quoted Argument`: diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index ddde877..35b4497 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -57,6 +57,7 @@ Policies Introduced by CMake 3.29 .. toctree:: :maxdepth: 1 + CMP0158: add_test() honors CMAKE_CROSSCOMPILING_EMULATOR only when cross-compiling. </policy/CMP0158> CMP0157: Swift compilation mode is selected by an abstraction. </policy/CMP0157> CMP0156: De-duplicate libraries on link lines based on linker capabilities. </policy/CMP0156> diff --git a/Help/manual/cmake-toolchains.7.rst b/Help/manual/cmake-toolchains.7.rst index e32bd29..1ebdf85 100644 --- a/Help/manual/cmake-toolchains.7.rst +++ b/Help/manual/cmake-toolchains.7.rst @@ -583,7 +583,7 @@ generator is recommended. The :generator:`Unix Makefiles` or :generator:`Ninja` generators can also be used, but they require the project to handle more areas like target CPU selection and code signing. -Any of the three systems can be targeted by setting the +Any of the Apple device platforms can be targeted by setting the :variable:`CMAKE_SYSTEM_NAME` variable to a value from the table below. By default, the latest Device SDK is chosen. As for all Apple platforms, a different SDK (e.g. a simulator) can be selected by setting the @@ -611,9 +611,11 @@ Variable :variable:`CMAKE_OSX_ARCHITECTURES` can be used to set architectures for both device and simulator. Variable :variable:`CMAKE_OSX_DEPLOYMENT_TARGET` can be used to set an iOS/tvOS/visionOS/watchOS deployment target. -Next configuration will install fat 5 architectures iOS library -and add the ``-miphoneos-version-min=9.3``/``-mios-simulator-version-min=9.3`` -flags to the compiler: +The next example installs five architectures in a universal binary for an iOS +library. It adds the relevant ``-miphoneos-version-min=9.3`` or +``-mios-simulator-version-min=9.3`` compiler flag where appropriate. +Note that the :variable:`CMAKE_IOS_INSTALL_COMBINED` variable used in the +example is now deprecated, so this approach is no longer recommended. .. code-block:: console diff --git a/Help/manual/ctest.1.rst b/Help/manual/ctest.1.rst index b519ccf..0917191 100644 --- a/Help/manual/ctest.1.rst +++ b/Help/manual/ctest.1.rst @@ -1594,17 +1594,20 @@ that running several of these tests at once does not exhaust the GPU's memory pool. Please note that CTest has no concept of what a GPU is or how much memory it -has, nor does it have any way of communicating with a GPU to retrieve this -information or perform any memory management. CTest simply keeps track of a -list of abstract resource types, each of which has a certain number of slots -available for tests to use. Each test specifies the number of slots that it -requires from a certain resource, and CTest then schedules them in a way that -prevents the total number of slots in use from exceeding the listed capacity. -When a test is executed, and slots from a resource are allocated to that test, -tests may assume that they have exclusive use of those slots for the duration -of the test's process. - -The CTest resource allocation feature consists of two inputs: +has. It does not have any way of communicating with a GPU to retrieve this +information or perform any memory management, although the project can define +a test that provides details about the test machine (see +:ref:`ctest-resource-dynamically-generated-spec-file`). + +CTest keeps track of a list of abstract resource types, each of which has a +certain number of slots available for tests to use. Each test specifies the +number of slots that it requires from a certain resource, and CTest then +schedules them in a way that prevents the total number of slots in use from +exceeding the listed capacity. When a test is executed, and slots from a +resource are allocated to that test, tests may assume that they have exclusive +use of those slots for the duration of the test's process. + +The CTest resource allocation feature consists of at least two inputs: * The :ref:`resource specification file <ctest-resource-specification-file>`, described below, which describes the resources available on the system. @@ -1645,15 +1648,20 @@ properties to indicate a skipped test. Resource Specification File --------------------------- -The resource specification file is a JSON file which is passed to CTest, either -on the command line as :option:`ctest --resource-spec-file`, or as the -``RESOURCE_SPEC_FILE`` argument of :command:`ctest_test`. If a dashboard script -is used and ``RESOURCE_SPEC_FILE`` is not specified, the value of -:variable:`CTEST_RESOURCE_SPEC_FILE` in the dashboard script is used instead. -If :option:`--resource-spec-file <ctest --resource-spec-file>`, ``RESOURCE_SPEC_FILE``, -and :variable:`CTEST_RESOURCE_SPEC_FILE` in the dashboard script are not specified, -the value of :variable:`CTEST_RESOURCE_SPEC_FILE` in the CMake build is used -instead. If none of these are specified, no resource spec file is used. +The resource specification file is a JSON file which is passed to CTest in one +of a number of ways. It can be specified on the command line with the +:option:`ctest --resource-spec-file` option, it can be given using the +``RESOURCE_SPEC_FILE`` argument of :command:`ctest_test`, or it can be +generated dynamically as part of test execution (see +:ref:`ctest-resource-dynamically-generated-spec-file`). + +If a dashboard script is used and ``RESOURCE_SPEC_FILE`` is not specified, the +value of :variable:`CTEST_RESOURCE_SPEC_FILE` in the dashboard script is used +instead. If :option:`--resource-spec-file <ctest --resource-spec-file>`, +``RESOURCE_SPEC_FILE``, and :variable:`CTEST_RESOURCE_SPEC_FILE` in the +dashboard script are not specified, the value of +:variable:`CTEST_RESOURCE_SPEC_FILE` in the CMake build is used instead. +If none of these are specified, no resource spec file is used. The resource specification file must be a JSON object. All examples in this document assume the following resource specification file: diff --git a/Help/policy/CMP0158.rst b/Help/policy/CMP0158.rst new file mode 100644 index 0000000..4289c6d --- /dev/null +++ b/Help/policy/CMP0158.rst @@ -0,0 +1,27 @@ +CMP0158 +------- + +.. versionadded:: 3.29 + +:command:`add_test` honors :variable:`CMAKE_CROSSCOMPILING_EMULATOR` only +when :variable:`cross-compiling <CMAKE_CROSSCOMPILING>`. + +In CMake 3.28 and below, :command:`add_test` unconditionally used the +:prop_tgt:`CROSSCOMPILING_EMULATOR` target property (initialized by the +:variable:`CMAKE_CROSSCOMPILING_EMULATOR` variable) to run test commands +naming executable targets. CMake 3.29 and above prefer to use the emulator +only when the :variable:`CMAKE_CROSSCOMPILING` variable is enabled. The +:variable:`CMAKE_TEST_LAUNCHER` variable may be used instead when not +cross-compiling. This policy provides compatibility for projects that +have not been updated. + +The ``OLD`` behavior for this policy is for :command:`add_test` to use +the :prop_tgt:`CROSSCOMPILING_EMULATOR` target property unconditionally. +The ``NEW`` behavior for this policy is for :command:`add_test` to use +the :prop_tgt:`CROSSCOMPILING_EMULATOR` target property only when +:variable:`cross-compiling <CMAKE_CROSSCOMPILING>`. + +This policy was introduced in CMake version 3.29. Use the +:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly. +Unlike many policies, CMake version |release| does *not* warn +when this policy is not set and simply uses ``OLD`` behavior. diff --git a/Help/release/3.28.rst b/Help/release/3.28.rst index f002cd2..d28024f 100644 --- a/Help/release/3.28.rst +++ b/Help/release/3.28.rst @@ -116,12 +116,6 @@ Modules Additionally, the :command:`ExternalProject_Add_Step` command has been updated to support the new ``JOB_SERVER_AWARE`` option. -* The :module:`ExternalProject` module now declares ``BYPRODUCTS`` for the - downloaded file for generated ``download`` steps. Previously, if multiple - external projects downloaded to the same file, hash verification could fail. - Now, when using the :ref:`Ninja Generators`, this scenario is detected and - Ninja will raise an error stating that multiple rules generate the same file. - * The :module:`FetchContent` module's :command:`FetchContent_Declare` command gained an ``EXCLUDE_FROM_ALL`` option, which propagates through to the :command:`add_subdirectory` call made by diff --git a/Help/release/dev/cmake-test-launcher.rst b/Help/release/dev/cmake-test-launcher.rst index e97498d..a82a8ad 100644 --- a/Help/release/dev/cmake-test-launcher.rst +++ b/Help/release/dev/cmake-test-launcher.rst @@ -5,3 +5,7 @@ cmake-test-launcher :prop_tgt:`TEST_LAUNCHER` target property were added to specify a launcher to be used by executable targets when invoked by tests added by the :command:`add_test` command. + +* The :command:`add_test` command now honors + :variable:`CMAKE_CROSSCOMPILING_EMULATOR` only when cross-compiling. + See policy :policy:`CMP0158`. diff --git a/Help/release/dev/package-dispatch-apple.rst b/Help/release/dev/package-dispatch-apple.rst new file mode 100644 index 0000000..d49cce1 --- /dev/null +++ b/Help/release/dev/package-dispatch-apple.rst @@ -0,0 +1,7 @@ +package-dispatch-apple +---------------------- + +* The :module:`CMakePackageConfigHelpers` module gained a new + :command:`generate_apple_architecture_selection_file` function, which can be + used to generate a file that includes an architecture-specific implementation + of a package for an Apple platform. diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake index ab38820..eeab67b 100644 --- a/Modules/CMakePackageConfigHelpers.cmake +++ b/Modules/CMakePackageConfigHelpers.cmake @@ -8,9 +8,6 @@ CMakePackageConfigHelpers Helpers functions for creating config files that can be included by other projects to find and use a package. -Adds the :command:`configure_package_config_file()` and -:command:`write_basic_package_version_file()` commands. - Generating a Package Configuration File ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -193,64 +190,128 @@ point to create more sophisticated custom ``ConfigVersion.cmake`` files. Generating an Apple Platform Selection File ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. versionadded:: 3.29 - .. command:: generate_apple_platform_selection_file - Create an Apple platform selection file: + .. versionadded:: 3.29 - generate_apple_platform_selection_file(<filename> - INSTALL_DESTINATION <path> - [MACOS_CONFIG_FILE <file>] - [IOS_CONFIG_FILE <file>] - [IOS_SIMULATOR_CONFIG_FILE <file>] - [TVOS_CONFIG_FILE <file>] - [TVOS_SIMULATOR_CONFIG_FILE <file>] - [WATCHOS_CONFIG_FILE <file>] - [WATCHOS_SIMULATOR_CONFIG_FILE <file>] - [VISIONOS_CONFIG_FILE <file>] - [VISIONOS_SIMULATOR_CONFIG_FILE <file>] - ) + Create an Apple platform selection file: + + .. code-block:: cmake + + generate_apple_platform_selection_file(<filename> + INSTALL_DESTINATION <path> + [INSTALL_PREFIX <path>] + [MACOS_CONFIG_FILE <file>] + [IOS_CONFIG_FILE <file>] + [IOS_SIMULATOR_CONFIG_FILE <file>] + [TVOS_CONFIG_FILE <file>] + [TVOS_SIMULATOR_CONFIG_FILE <file>] + [WATCHOS_CONFIG_FILE <file>] + [WATCHOS_SIMULATOR_CONFIG_FILE <file>] + [VISIONOS_CONFIG_FILE <file>] + [VISIONOS_SIMULATOR_CONFIG_FILE <file>] + ) + + Writes a file for use as ``<PackageName>Config.cmake`` which can include an + Apple-platform-specific ``<PackageName>Config.cmake`` from a different + directory. This can be used in conjunction with the ``XCFRAMEWORK_LOCATION`` + argument of :command:`export(SETUP)` to export packages in a way that a project + built for any Apple platform can use them. + + ``INSTALL_DESTINATION <path>`` + Path to which the file will be installed by the caller, e.g., via + :command:`install(FILES)`. The path may be either relative to the + ``INSTALL_PREFIX`` or absolute. + + ``INSTALL_PREFIX <path>`` + Path prefix to which the package will be installed by the caller. + The ``<path>`` argument must be an absolute path. If this argument + is not passed, the :variable:`CMAKE_INSTALL_PREFIX` variable will be + used instead. + + ``MACOS_CONFIG_FILE <file>`` + File to include if the platform is macOS. + + ``IOS_CONFIG_FILE <file>`` + File to include if the platform is iOS. + + ``IOS_SIMULATOR_CONFIG_FILE <file>`` + File to include if the platform is iOS Simulator. -Writes a file for use as ``<PackageName>Config.cmake`` which can include an -Apple-platform-specific ``<PackageName>Config.cmake`` from a different -directory. This can be used in conjunction with the ``XCFRAMEWORK_LOCATION`` -argument of :command:`export(SETUP)` to export packages in a way that a project -built for any Apple platform can use them. + ``TVOS_CONFIG_FILE <file>`` + File to include if the platform is tvOS. -``INSTALL_DESTINATION <path>`` - Path that the file will be installed to. + ``TVOS_SIMULATOR_CONFIG_FILE <file>`` + File to include if the platform is tvOS Simulator. -``MACOS_CONFIG_FILE <file>`` - File to include if the platform is macOS. + ``WATCHOS_CONFIG_FILE <file>`` + File to include if the platform is watchOS. -``IOS_CONFIG_FILE <file>`` - File to include if the platform is iOS. + ``WATCHOS_SIMULATOR_CONFIG_FILE <file>`` + File to include if the platform is watchOS Simulator. -``IOS_SIMULATOR_CONFIG_FILE <file>`` - File to include if the platform is iOS Simulator. + ``VISIONOS_CONFIG_FILE <file>`` + File to include if the platform is visionOS. -``TVOS_CONFIG_FILE <file>`` - File to include if the platform is tvOS. + ``VISIONOS_SIMULATOR_CONFIG_FILE <file>`` + File to include if the platform is visionOS Simulator. -``TVOS_SIMULATOR_CONFIG_FILE <file>`` - File to include if the platform is tvOS Simulator. + If any of the optional config files are not specified, and the consuming + project is built for their corresponding platform, an error will be thrown + when including the generated file. -``WATCHOS_CONFIG_FILE <file>`` - File to include if the platform is watchOS. +.. command:: generate_apple_architecture_selection_file -``WATCHOS_SIMULATOR_CONFIG_FILE <file>`` - File to include if the platform is watchOS Simulator. + .. versionadded:: 3.29 -``VISIONOS_CONFIG_FILE <file>`` - File to include if the platform is visionOS. + Create an Apple architecture selection file: -``VISIONOS_SIMULATOR_CONFIG_FILE <file>`` - File to include if the platform is visionOS Simulator. + .. code-block:: cmake -If any of the optional config files are not specified, and the consuming -project is built for their corresponding platform, an error will be thrown -when including the generated file. + generate_apple_architecture_selection_file(<filename> + INSTALL_DESTINATION <path> + [INSTALL_PREFIX <path>] + [SINGLE_ARCHITECTURES <archs> + SINGLE_ARCHITECTURE_CONFIG_FILES <files>] + [UNIVERSAL_ARCHITECTURES <archs> + UNIVERSAL_CONFIG_FILE <file>] + ) + + Writes a file for use as ``<PackageName>Config.cmake`` on Apple platforms + which can include an architecture-specific ``<PackageName>Config.cmake`` + from a different directory based on :variable:`CMAKE_OSX_ARCHITECTURES`. + + ``INSTALL_DESTINATION <path>`` + Path to which the file will be installed by the caller, e.g., via + :command:`install(FILES)`. The path may be either relative to the + ``INSTALL_PREFIX`` or absolute. + + ``INSTALL_PREFIX <path>`` + Path prefix to which the package will be installed by the caller. + The ``<path>`` argument must be an absolute path. If this argument + is not passed, the :variable:`CMAKE_INSTALL_PREFIX` variable will be + used instead. + + ``SINGLE_ARCHITECTURES <archs>`` + A :ref:`semicolon-separated list <CMake Language Lists>` of + architectures provided by entries of + ``SINGLE_ARCHITECTURE_CONFIG_FILES``. + + ``SINGLE_ARCHITECTURE_CONFIG_FILES <files>`` + A :ref:`semicolon-separated list <CMake Language Lists>` of + architecture-specific files. One of them will be loaded + when :variable:`CMAKE_OSX_ARCHITECTURES` contains a single + architecture matching the corresponding entry of + ``SINGLE_ARCHITECTURES``. + + ``UNIVERSAL_ARCHITECTURES <archs>`` + A :ref:`semicolon-separated list <CMake Language Lists>` of + architectures provided by the ``UNIVERSAL_CONFIG_FILE``. + + ``UNIVERSAL_CONFIG_FILE <file>`` + A file to load when :variable:`CMAKE_OSX_ARCHITECTURES` contains + a (non-strict) subset of the ``UNIVERSAL_ARCHITECTURES`` and + does not match any one of the ``SINGLE_ARCHITECTURES``. Example Generating Package Files ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -423,11 +484,21 @@ function(generate_apple_platform_selection_file _output_file) set(_options) set(_single INSTALL_DESTINATION + INSTALL_PREFIX ${_config_file_options} ) set(_multi) cmake_parse_arguments(PARSE_ARGV 0 _gpsf "${_options}" "${_single}" "${_multi}") + if(NOT _gpsf_INSTALL_DESTINATION) + message(FATAL_ERROR "No INSTALL_DESTINATION given to generate_apple_platform_selection_file()") + endif() + if(_gpsf_INSTALL_PREFIX) + set(maybe_INSTALL_PREFIX INSTALL_PREFIX ${_gpsf_INSTALL_PREFIX}) + else() + set(maybe_INSTALL_PREFIX "") + endif() + set(_have_relative 0) foreach(_opt IN LISTS _config_file_options) if(_gpsf_${_opt}) @@ -442,8 +513,83 @@ function(generate_apple_platform_selection_file _output_file) endif() endforeach() - configure_package_config_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/Internal/PlatformSelectionFile.cmake.in" "${_output_file}" + configure_package_config_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/Internal/ApplePlatformSelection.cmake.in" "${_output_file}" INSTALL_DESTINATION "${_gpsf_INSTALL_DESTINATION}" + ${maybe_INSTALL_PREFIX} + NO_SET_AND_CHECK_MACRO + NO_CHECK_REQUIRED_COMPONENTS_MACRO + ) +endfunction() + +function(generate_apple_architecture_selection_file _output_file) + set(_options) + set(_single + INSTALL_DESTINATION + INSTALL_PREFIX + SINGLE_ARCHITECTURES + SINGLE_ARCHITECTURE_CONFIG_FILES + UNIVERSAL_ARCHITECTURES + UNIVERSAL_CONFIG_FILE + ) + set(_multi) + cmake_parse_arguments(PARSE_ARGV 0 _gasf "${_options}" "${_single}" "${_multi}") + + if(NOT _gasf_INSTALL_DESTINATION) + message(FATAL_ERROR "No INSTALL_DESTINATION given to generate_apple_platform_selection_file()") + endif() + if(_gasf_INSTALL_PREFIX) + set(maybe_INSTALL_PREFIX INSTALL_PREFIX ${_gasf_INSTALL_PREFIX}) + else() + set(maybe_INSTALL_PREFIX "") + endif() + + list(LENGTH _gasf_SINGLE_ARCHITECTURES _gasf_SINGLE_ARCHITECTURES_len) + list(LENGTH _gasf_SINGLE_ARCHITECTURE_CONFIG_FILES _gasf_SINGLE_ARCHITECTURE_CONFIG_FILES_len) + if(NOT _gasf_SINGLE_ARCHITECTURES_len EQUAL _gasf_SINGLE_ARCHITECTURE_CONFIG_FILES_len) + message(FATAL_ERROR "SINGLE_ARCHITECTURES and SINGLE_ARCHITECTURE_CONFIG_FILES do not have the same number of entries.") + endif() + + set(_branch_code "") + + foreach(pair IN ZIP_LISTS _gasf_SINGLE_ARCHITECTURES _gasf_SINGLE_ARCHITECTURE_CONFIG_FILES) + set(arch "${pair_0}") + set(config_file "${pair_1}") + if(NOT IS_ABSOLUTE "${config_file}") + string(PREPEND config_file [[${PACKAGE_PREFIX_DIR}/]]) + endif() + string(APPEND _branch_code + "\n" + "if(CMAKE_OSX_ARCHITECTURES STREQUAL \"${arch}\")\n" + " include(\"${config_file}\")\n" + " return()\n" + "endif()\n" + ) + endforeach() + + if(_gasf_UNIVERSAL_ARCHITECTURES AND _gasf_UNIVERSAL_CONFIG_FILE) + string(JOIN " " universal_archs "${_gasf_UNIVERSAL_ARCHITECTURES}") + set(config_file "${_gasf_UNIVERSAL_CONFIG_FILE}") + if(NOT IS_ABSOLUTE "${config_file}") + string(PREPEND config_file [[${PACKAGE_PREFIX_DIR}/]]) + endif() + string(APPEND _branch_code + "\n" + "set(_cmake_apple_archs \"\${CMAKE_OSX_ARCHITECTURES}\")\n" + "list(REMOVE_ITEM _cmake_apple_archs ${universal_archs})\n" + "if(NOT _cmake_apple_archs)\n" + " include(\"${config_file}\")\n" + " return()\n" + "endif()\n" + ) + elseif(_gasf_UNIVERSAL_ARCHITECTURES) + message(FATAL_ERROR "UNIVERSAL_CONFIG_FILE requires UNIVERSAL_ARCHITECTURES") + elseif(_gasf_UNIVERSAL_CONFIG_FILE) + message(FATAL_ERROR "UNIVERSAL_ARCHITECTURES requires UNIVERSAL_CONFIG_FILE") + endif() + + configure_package_config_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/Internal/AppleArchitectureSelection.cmake.in" "${_output_file}" + INSTALL_DESTINATION "${_gasf_INSTALL_DESTINATION}" + ${maybe_INSTALL_PREFIX} NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO ) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index b2816a5..757b04e 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -2836,7 +2836,6 @@ function(_ep_add_download_command name) set(comment) set(work_dir) set(extra_repo_info) - set(byproduct_file) if(cmd_set) set(work_dir ${download_dir}) @@ -3117,16 +3116,14 @@ hash=${hash} get_filename_component(fname "${fname}" NAME) else() # Fall back to a default file name. The actual file name does not - # matter as long as it doesn't conflict with other projects because - # it is used only internally and our extraction tool inspects the - # file content directly. If it turns out the wrong URL was given - # that will be revealed during the build which is an easier place for - # users to diagnose than an error here anyway. - set(fname "${name}-archive.tar") + # matter because it is used only internally and our extraction tool + # inspects the file content directly. If it turns out the wrong URL + # was given that will be revealed during the build which is an easier + # place for users to diagnose than an error here anyway. + set(fname "archive.tar") endif() string(REPLACE ";" "-" fname "${fname}") set(file ${download_dir}/${fname}) - set(byproduct_file "${download_dir}/${fname}") get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT) get_property(inactivity_timeout TARGET ${name} @@ -3303,7 +3300,6 @@ hash=${hash} COMMAND ${__cmdQuoted} WORKING_DIRECTORY \${work_dir} DEPENDS \${depends} - BYPRODUCTS \${byproduct_file} DEPENDEES mkdir ${log} ${uses_terminal} diff --git a/Modules/FeatureSummary.cmake b/Modules/FeatureSummary.cmake index 77c66d1..009ca38 100644 --- a/Modules/FeatureSummary.cmake +++ b/Modules/FeatureSummary.cmake @@ -17,7 +17,7 @@ packages and/or feature for a build tree such as:: PNG, A PNG image library., <http://www.libpng.org/pub/png/> * Enables saving screenshots -- The following OPTIONAL packages have not been found: - Lua51, The Lua scripting language., <http://www.lua.org> + Lua51, The Lua scripting language., <https://www.lua.org> * Enables macros in MyWordProcessor Foo, Foo provides cool stuff. diff --git a/Modules/FindCURL.cmake b/Modules/FindCURL.cmake index 2f33dac..5e5f1f8 100644 --- a/Modules/FindCURL.cmake +++ b/Modules/FindCURL.cmake @@ -94,8 +94,10 @@ find_package(PkgConfig QUIET) if(PKG_CONFIG_FOUND) pkg_check_modules(PC_CURL QUIET libcurl) if(PC_CURL_FOUND) - pkg_get_variable(CURL_SUPPORTED_PROTOCOLS libcurl supported_protocols) - pkg_get_variable(CURL_SUPPORTED_FEATURES libcurl supported_features) + pkg_get_variable(CURL_SUPPORTED_PROTOCOLS_STRING libcurl supported_protocols) + string(REPLACE " " ";" CURL_SUPPORTED_PROTOCOLS "${CURL_SUPPORTED_PROTOCOLS_STRING}") + pkg_get_variable(CURL_SUPPORTED_FEATURES_STRING libcurl supported_features) + string(REPLACE " " ";" CURL_SUPPORTED_FEATURES "${CURL_SUPPORTED_FEATURES_STRING}") endif() endif() diff --git a/Modules/GoogleTestAddTests.cmake b/Modules/GoogleTestAddTests.cmake index de0f7d6..eea267d 100644 --- a/Modules/GoogleTestAddTests.cmake +++ b/Modules/GoogleTestAddTests.cmake @@ -112,6 +112,7 @@ function(gtest_discover_tests_impl) message(FATAL_ERROR "Error running test executable.\n" " Path: '${path}'\n" + " Working directory: '${_TEST_WORKING_DIR}'\n" " Result: ${result}\n" " Output:\n" " ${output}\n" diff --git a/Modules/Internal/AppleArchitectureSelection.cmake.in b/Modules/Internal/AppleArchitectureSelection.cmake.in new file mode 100644 index 0000000..fec0d41 --- /dev/null +++ b/Modules/Internal/AppleArchitectureSelection.cmake.in @@ -0,0 +1,8 @@ +@PACKAGE_INIT@ + +if(NOT CMAKE_OSX_ARCHITECTURES) + message(FATAL_ERROR "CMAKE_OSX_ARCHITECTURES must be explicitly set for this package") +endif() +@_branch_code@ + +message(FATAL_ERROR "Architecture not supported") diff --git a/Modules/Internal/PlatformSelectionFile.cmake.in b/Modules/Internal/ApplePlatformSelection.cmake.in index 493d650..493d650 100644 --- a/Modules/Internal/PlatformSelectionFile.cmake.in +++ b/Modules/Internal/ApplePlatformSelection.cmake.in diff --git a/Modules/UsePkgConfig.cmake b/Modules/UsePkgConfig.cmake index b020259..fdf632a 100644 --- a/Modules/UsePkgConfig.cmake +++ b/Modules/UsePkgConfig.cmake @@ -41,20 +41,19 @@ macro(PKGCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags) if(NOT _return_VALUE) execute_process(COMMAND ${PKGCONFIG_EXECUTABLE} ${_package} --variable=includedir - OUTPUT_VARIABLE ${_include_DIR} ) + OUTPUT_VARIABLE ${_include_DIR} OUTPUT_STRIP_TRAILING_WHITESPACE ) string(REGEX REPLACE "[\r\n]" " " ${_include_DIR} "${${_include_DIR}}") - execute_process(COMMAND ${PKGCONFIG_EXECUTABLE} ${_package} --variable=libdir - OUTPUT_VARIABLE ${_link_DIR} ) + OUTPUT_VARIABLE ${_link_DIR} OUTPUT_STRIP_TRAILING_WHITESPACE ) string(REGEX REPLACE "[\r\n]" " " ${_link_DIR} "${${_link_DIR}}") execute_process(COMMAND ${PKGCONFIG_EXECUTABLE} ${_package} --libs - OUTPUT_VARIABLE ${_link_FLAGS} ) + OUTPUT_VARIABLE ${_link_FLAGS} OUTPUT_STRIP_TRAILING_WHITESPACE ) string(REGEX REPLACE "[\r\n]" " " ${_link_FLAGS} "${${_link_FLAGS}}") execute_process(COMMAND ${PKGCONFIG_EXECUTABLE} ${_package} --cflags - OUTPUT_VARIABLE ${_cflags} ) + OUTPUT_VARIABLE ${_cflags} OUTPUT_STRIP_TRAILING_WHITESPACE ) string(REGEX REPLACE "[\r\n]" " " ${_cflags} "${${_cflags}}") else() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index d60d36f..eda95c1 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 28) -set(CMake_VERSION_PATCH 20231218) +set(CMake_VERSION_PATCH 20240104) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/cmDyndepCollation.cxx b/Source/cmDyndepCollation.cxx index e9f7be3..ea46f03 100644 --- a/Source/cmDyndepCollation.cxx +++ b/Source/cmDyndepCollation.cxx @@ -495,7 +495,8 @@ bool cmDyndepCollation::WriteDyndepMetadata( if (!has_provides) { cmSystemTools::Error( cmStrCat("Output ", object.PrimaryOutput, - " is of type `CXX_MODULES` but does not provide a module")); + " is of type `CXX_MODULES` but does not provide a module " + "interface unit or partition")); result = false; continue; } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index feeae95..289bb24 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -8860,11 +8860,23 @@ bool cmGeneratorTarget::IsFrameworkOnApple() const bool cmGeneratorTarget::IsImportedFrameworkFolderOnApple( const std::string& config) const { - return this->IsApple() && this->IsImported() && - (this->GetType() == cmStateEnums::STATIC_LIBRARY || - this->GetType() == cmStateEnums::SHARED_LIBRARY || - this->GetType() == cmStateEnums::UNKNOWN_LIBRARY) && - cmSystemTools::IsPathToFramework(this->GetLocation(config)); + if (this->IsApple() && this->IsImported() && + (this->GetType() == cmStateEnums::STATIC_LIBRARY || + this->GetType() == cmStateEnums::SHARED_LIBRARY || + this->GetType() == cmStateEnums::UNKNOWN_LIBRARY)) { + std::string cfg = config; + if (cfg.empty() && this->GetGlobalGenerator()->IsXcode()) { + // FIXME(#25515): Remove the need for this workaround. + // The Xcode generator queries include directories without any + // specific configuration. Pick one in case this target does + // not set either IMPORTED_LOCATION or IMPORTED_CONFIGURATIONS. + cfg = + this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig)[0]; + } + return cmSystemTools::IsPathToFramework(this->GetLocation(cfg)); + } + + return false; } bool cmGeneratorTarget::IsAppBundleOnApple() const diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index af2fa82..55eb9b5 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -579,6 +579,7 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator(cmake* cm) this->Comspec = "cmd.exe"; } #endif + cm->GetState()->SetNinja(true); this->FindMakeProgramFile = "CMakeNinjaFindMake.cmake"; } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 732593f..7ea479e 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1142,7 +1142,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements( std::vector<cmSourceFile const*> swiftSources; for (cmSourceFile const* sf : objectSources) { - if (sf->GetLanguage() == "Swift") { + if (this->GetLocalGenerator()->IsSplitSwiftBuild() && + sf->GetLanguage() == "Swift") { swiftSources.push_back(sf); } else { this->WriteObjectBuildStatement(sf, config, fileConfig, @@ -1389,8 +1390,10 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( bool const needDyndep = !isPch && this->GeneratorTarget->NeedDyndepForSource(language, config, source); - cmNinjaBuild objBuild(this->LanguageCompilerRule( - language, config, needDyndep ? WithScanning::Yes : WithScanning::No)); + WithScanning withScanning = + needDyndep ? WithScanning::Yes : WithScanning::No; + cmNinjaBuild objBuild( + this->LanguageCompilerRule(language, config, withScanning)); cmNinjaVars& vars = objBuild.Variables; vars["FLAGS"] = this->ComputeFlagsForObject(source, language, config, objectFileName); @@ -1453,7 +1456,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( this->ExportObjectCompileCommand( language, sourceFilePath, objectDir, objectFileName, objectFileDir, vars["FLAGS"], vars["DEFINES"], vars["INCLUDES"], - vars["TARGET_COMPILE_PDB"], vars["TARGET_PDB"], config); + vars["TARGET_COMPILE_PDB"], vars["TARGET_PDB"], config, withScanning); } objBuild.Outputs.push_back(objectFileName); @@ -1800,7 +1803,7 @@ void cmNinjaTargetGenerator::WriteCxxModuleBmiBuildStatement( this->ExportObjectCompileCommand( language, sourceFilePath, bmiDir, bmiFileName, bmiFileDir, vars["FLAGS"], vars["DEFINES"], vars["INCLUDES"], vars["TARGET_COMPILE_PDB"], - vars["TARGET_PDB"], config); + vars["TARGET_PDB"], config, WithScanning::Yes); } bmiBuild.Outputs.push_back(bmiFileName); @@ -2030,7 +2033,7 @@ void cmNinjaTargetGenerator::WriteSwiftObjectBuildStatement( language, sourceFilePath, objectDir, targetObjectFilename, cmSystemTools::GetFilenamePath(targetObjectFilename), vars["FLAGS"], vars["DEFINES"], vars["INCLUDES"], - /*compile pdb*/ "", /*target pdb*/ "", config); + /*compile pdb*/ "", /*target pdb*/ "", config, WithScanning::No); } } else { // Object outputs @@ -2050,7 +2053,7 @@ void cmNinjaTargetGenerator::WriteSwiftObjectBuildStatement( cmSystemTools::GetFilenamePath(objectFilepath), vars["FLAGS"], vars["DEFINES"], vars["INCLUDES"], /*compile pdb*/ "", - /*target pdb*/ "", config); + /*target pdb*/ "", config, WithScanning::No); } } } @@ -2219,7 +2222,7 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand( std::string const& objectFileDir, std::string const& flags, std::string const& defines, std::string const& includes, std::string const& targetCompilePdb, std::string const& targetPdb, - std::string const& outputConfig) + std::string const& outputConfig, WithScanning withScanning) { if (!this->GeneratorTarget->GetPropertyAsBool("EXPORT_COMPILE_COMMANDS")) { return; @@ -2242,14 +2245,12 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand( escapedSourceFileName, cmOutputConverter::SHELL); std::string fullFlags = flags; - { - bool const needDyndep = - this->GetGeneratorTarget()->NeedDyndep(language, outputConfig); + if (withScanning == WithScanning::Yes) { std::string const modmapFormatVar = cmStrCat("CMAKE_", language, "_MODULE_MAP_FORMAT"); std::string const modmapFormat = this->Makefile->GetSafeDefinition(modmapFormatVar); - if (needDyndep && !modmapFormat.empty()) { + if (!modmapFormat.empty()) { std::string modmapFlags = this->GetMakefile()->GetRequiredDefinition( cmStrCat("CMAKE_", language, "_MODULE_MAP_FLAG")); // XXX(modmap): If changing this path construction, change diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 7a68599..b55c460 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -193,7 +193,7 @@ protected: std::string const& objectFileDir, std::string const& flags, std::string const& defines, std::string const& includes, std::string const& targetCompilePdb, std::string const& targetPdb, - std::string const& outputConfig); + std::string const& outputConfig, WithScanning withScanning); void AdditionalCleanFiles(const std::string& config); diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx index 9c30d74..f4a8d0c 100644 --- a/Source/cmOutputConverter.cxx +++ b/Source/cmOutputConverter.cxx @@ -275,6 +275,9 @@ std::string cmOutputConverter::EscapeForShell(cm::string_view str, if (this->GetState()->UseNMake()) { flags |= Shell_Flag_NMake; } + if (this->GetState()->UseNinja()) { + flags |= Shell_Flag_Ninja; + } if (!this->GetState()->UseWindowsShell()) { flags |= Shell_Flag_IsUnix; } @@ -677,6 +680,12 @@ std::string cmOutputConverter::Shell_GetArgument(cm::string_view in, int flags) /* Otherwise a semicolon is written just ;. */ out += ';'; } + } else if (*cit == '\n') { + if (flags & Shell_Flag_Ninja) { + out += "$\n"; + } else { + out += '\n'; + } } else { /* Store this character. */ out += *cit; diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h index 0ee7afb..424f004 100644 --- a/Source/cmOutputConverter.h +++ b/Source/cmOutputConverter.h @@ -100,7 +100,10 @@ public: Shell_Flag_UnescapeNinjaConfiguration = (1 << 9), - Shell_Flag_IsResponse = (1 << 10) + Shell_Flag_IsResponse = (1 << 10), + + /** The target shell is in a Ninja build file. */ + Shell_Flag_Ninja = (1 << 11) }; std::string EscapeForShell(cm::string_view str, bool makeVars = false, diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 7964f32..f038c6b 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -480,7 +480,11 @@ class cmMakefile; 29, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0157, \ "Swift compilation mode selected by an abstraction.", 3, 29, 0, \ - cmPolicies::WARN) + cmPolicies::WARN) \ + SELECT(POLICY, CMP0158, \ + "add_test() honors CMAKE_CROSSCOMPILING_EMULATOR only when " \ + "cross-compiling.", \ + 3, 28, 0, cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) #define CM_FOR_EACH_POLICY_ID(POLICY) \ diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 8ae2166..d104268 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -752,6 +752,16 @@ bool cmState::UseMSYSShell() const return this->MSYSShell; } +void cmState::SetNinja(bool ninja) +{ + this->Ninja = ninja; +} + +bool cmState::UseNinja() const +{ + return this->Ninja; +} + void cmState::SetNinjaMulti(bool ninjaMulti) { this->NinjaMulti = ninjaMulti; diff --git a/Source/cmState.h b/Source/cmState.h index 702b06f..ae0d52b 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -220,6 +220,8 @@ public: bool UseNMake() const; void SetMSYSShell(bool mSYSShell); bool UseMSYSShell() const; + void SetNinja(bool ninja); + bool UseNinja() const; void SetNinjaMulti(bool ninjaMulti); bool UseNinjaMulti() const; @@ -297,6 +299,7 @@ private: bool MinGWMake = false; bool NMake = false; bool MSYSShell = false; + bool Ninja = false; bool NinjaMulti = false; Mode StateMode = Unknown; ProjectKind StateProjectKind = ProjectKind::Normal; diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx index b0d9c2d..7c9969c 100644 --- a/Source/cmTest.cxx +++ b/Source/cmTest.cxx @@ -9,6 +9,7 @@ cmTest::cmTest(cmMakefile* mf) : Backtrace(mf->GetBacktrace()) + , PolicyStatusCMP0158(mf->GetPolicyStatus(cmPolicies::CMP0158)) { this->Makefile = mf; this->OldStyle = true; diff --git a/Source/cmTest.h b/Source/cmTest.h index 8b50b87..480966a 100644 --- a/Source/cmTest.h +++ b/Source/cmTest.h @@ -9,6 +9,7 @@ #include <vector> #include "cmListFileCache.h" +#include "cmPolicies.h" #include "cmPropertyMap.h" #include "cmValue.h" @@ -60,6 +61,12 @@ public: bool GetOldStyle() const { return this->OldStyle; } void SetOldStyle(bool b) { this->OldStyle = b; } + /** Get/Set if CMP0158 policy is NEW */ + bool GetCMP0158IsNew() const + { + return this->PolicyStatusCMP0158 == cmPolicies::NEW; + } + /** Set/Get whether lists in command lines should be expanded. */ bool GetCommandExpandLists() const; void SetCommandExpandLists(bool b); @@ -74,4 +81,5 @@ private: cmMakefile* Makefile; cmListFileBacktrace Backtrace; + cmPolicies::PolicyStatus PolicyStatusCMP0158; }; diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 2831d0d..3194d8f 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -167,6 +167,8 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, if (target && target->GetType() == cmStateEnums::EXECUTABLE) { // Use the target file on disk. exe = target->GetFullPath(config); + auto useEmulator = !this->GetTest()->GetCMP0158IsNew() || + this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING"); // Prepend with the test launcher if specified. cmValue launcher = target->GetProperty("TEST_LAUNCHER"); @@ -182,7 +184,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, // Prepend with the emulator when cross compiling if required. cmValue emulator = target->GetProperty("CROSSCOMPILING_EMULATOR"); - if (cmNonempty(emulator)) { + if (cmNonempty(emulator) && useEmulator) { cmList emulatorWithArgs{ *emulator }; std::string emulatorExe(emulatorWithArgs[0]); cmSystemTools::ConvertToUnixSlashes(emulatorExe); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index fd22957..32064b4 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1576,14 +1576,15 @@ void cmake::SetArgs(const std::vector<std::string>& args) if (!expandedPreset->ArchitectureStrategy || expandedPreset->ArchitectureStrategy == cmCMakePresetsGraph::ArchToolsetStrategy::Set) { - if (!this->GeneratorPlatformSet) { + if (!this->GeneratorPlatformSet && + !expandedPreset->Architecture.empty()) { this->SetGeneratorPlatform(expandedPreset->Architecture); } } if (!expandedPreset->ToolsetStrategy || expandedPreset->ToolsetStrategy == cmCMakePresetsGraph::ArchToolsetStrategy::Set) { - if (!this->GeneratorToolsetSet) { + if (!this->GeneratorToolsetSet && !expandedPreset->Toolset.empty()) { this->SetGeneratorToolset(expandedPreset->Toolset); } } diff --git a/Tests/RunCMake/CMakePackage/ApplePlatformMissingDest-result.txt b/Tests/RunCMake/CMakePackage/ApplePlatformMissingDest-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePackage/ApplePlatformMissingDest-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePackage/ApplePlatformMissingDest-stderr.txt b/Tests/RunCMake/CMakePackage/ApplePlatformMissingDest-stderr.txt new file mode 100644 index 0000000..03be015 --- /dev/null +++ b/Tests/RunCMake/CMakePackage/ApplePlatformMissingDest-stderr.txt @@ -0,0 +1,6 @@ +^CMake Error at [^ +]*/Modules/CMakePackageConfigHelpers\.cmake:[0-9]+ \(message\): + No INSTALL_DESTINATION given to generate_apple_platform_selection_file\(\) +Call Stack \(most recent call first\): + ApplePlatformMissingDest\.cmake:[0-9]+ \(generate_apple_platform_selection_file\) + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CMakePackage/ApplePlatformMissingDest.cmake b/Tests/RunCMake/CMakePackage/ApplePlatformMissingDest.cmake new file mode 100644 index 0000000..e47b595 --- /dev/null +++ b/Tests/RunCMake/CMakePackage/ApplePlatformMissingDest.cmake @@ -0,0 +1,4 @@ +include(CMakePackageConfigHelpers) +generate_apple_platform_selection_file(mylib-config-install.cmake + #missing: INSTALL_DESTINATION lib/cmake/mylib + ) diff --git a/Tests/RunCMake/CMakePackage/RunCMakeTest.cmake b/Tests/RunCMake/CMakePackage/RunCMakeTest.cmake index 9fef792..4145ccc 100644 --- a/Tests/RunCMake/CMakePackage/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePackage/RunCMakeTest.cmake @@ -7,16 +7,23 @@ endif() function(apple_export platform system_name archs sysroot) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/apple-export-${platform}-build) string(REPLACE ";" "\\;" archs "${archs}") + if(select_archs) + string(REPLACE ";" "\\\\;" maybe_IOS_SIMULATOR_SELECT_ARCHS "-DIOS_SIMULATOR_SELECT_ARCHS=${select_archs}") + endif() run_cmake_with_options(apple-export-${platform} "-DCMAKE_SYSTEM_NAME=${system_name}" "-DCMAKE_OSX_ARCHITECTURES=${archs}" "-DCMAKE_OSX_SYSROOT=${sysroot}" "-DCMAKE_INSTALL_PREFIX=${apple_install}" ${maybe_CMAKE_BUILD_TYPE} + ${maybe_IOS_SIMULATOR_SELECT_ARCHS} ) set(RunCMake_TEST_NO_CLEAN 1) run_cmake_command(apple-export-${platform}-build ${CMAKE_COMMAND} --build . --config Release) run_cmake_command(apple-export-${platform}-install ${CMAKE_COMMAND} --install . --config Release) + file(APPEND "${apple_install}/lib/${platform}/cmake/mylib/mylib-targets.cmake" "\n" + "message(STATUS \"loaded: '\${CMAKE_CURRENT_LIST_FILE}'\")\n" + ) endfunction() function(apple_import platform system_name archs sysroot) @@ -33,6 +40,10 @@ function(apple_import platform system_name archs sysroot) run_cmake_command(apple-import-${platform}-build ${CMAKE_COMMAND} --build . --config Release) endfunction() +if(APPLE) + run_cmake(ApplePlatformMissingDest) +endif() + if(APPLE AND CMAKE_C_COMPILER_ID STREQUAL "AppleClang") set(apple_install ${RunCMake_BINARY_DIR}/apple-install) file(REMOVE_RECURSE "${apple_install}") @@ -40,9 +51,11 @@ if(APPLE AND CMAKE_C_COMPILER_ID STREQUAL "AppleClang") if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 12) set(macos_archs "x86_64;arm64") set(watch_sim_archs "x86_64") + set(select_archs "arm64;x86_64") else() set(macos_archs "x86_64") set(watch_sim_archs "i386") + set(select_archs "") endif() if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 9) @@ -64,6 +77,12 @@ if(APPLE AND CMAKE_C_COMPILER_ID STREQUAL "AppleClang") endif() apple_export(watchos watchOS "${watch_archs}" watchos) apple_export(ios-simulator iOS "${macos_archs}" iphonesimulator) + if(select_archs) + foreach(arch IN LISTS macos_archs) + apple_export(ios-simulator-${arch} iOS "${arch}" iphonesimulator) + endforeach() + endif() + apple_export(tvos-simulator tvOS "${macos_archs}" appletvsimulator) if(enable_visionos) apple_export(visionos-simulator visionOS "${macos_archs}" xrsimulator) @@ -78,6 +97,11 @@ if(APPLE AND CMAKE_C_COMPILER_ID STREQUAL "AppleClang") endif() apple_import(watchos watchOS "${watch_archs}" watchos) apple_import(ios-simulator iOS "${macos_archs}" iphonesimulator) + if(select_archs) + foreach(arch IN LISTS macos_archs) + apple_import(ios-simulator-${arch} iOS "${arch}" iphonesimulator) + endforeach() + endif() apple_import(tvos-simulator tvOS "${macos_archs}" appletvsimulator) if(enable_visionos) apple_import(visionos-simulator visionOS "${macos_archs}" xrsimulator) diff --git a/Tests/RunCMake/CMakePackage/apple-export-common.cmake b/Tests/RunCMake/CMakePackage/apple-export-common.cmake index 1381f59..d334f75 100644 --- a/Tests/RunCMake/CMakePackage/apple-export-common.cmake +++ b/Tests/RunCMake/CMakePackage/apple-export-common.cmake @@ -6,12 +6,19 @@ install(TARGETS mylib EXPORT mylib-targets FILE_SET HEADERS ARCHIVE DESTINATION install(EXPORT mylib-targets DESTINATION lib/${platform_name}/cmake/mylib) +if(IOS_SIMULATOR_SELECT_ARCHS) + set(IOS_SIMULATOR_CONFIG_FILE lib/ios-simulator/cmake/mylib/mylib-select-arch.cmake) +else() + set(IOS_SIMULATOR_CONFIG_FILE lib/ios-simulator/cmake/mylib/mylib-targets.cmake) +endif() + include(CMakePackageConfigHelpers) generate_apple_platform_selection_file(mylib-config-install.cmake INSTALL_DESTINATION lib/cmake/mylib + INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} MACOS_CONFIG_FILE lib/macos/cmake/mylib/mylib-targets.cmake IOS_CONFIG_FILE lib/ios/cmake/mylib/mylib-targets.cmake - IOS_SIMULATOR_CONFIG_FILE lib/ios-simulator/cmake/mylib/mylib-targets.cmake + IOS_SIMULATOR_CONFIG_FILE ${IOS_SIMULATOR_CONFIG_FILE} TVOS_CONFIG_FILE lib/tvos/cmake/mylib/mylib-targets.cmake TVOS_SIMULATOR_CONFIG_FILE lib/tvos-simulator/cmake/mylib/mylib-targets.cmake VISIONOS_CONFIG_FILE lib/watchos/cmake/mylib/mylib-targets.cmake diff --git a/Tests/RunCMake/CMakePackage/apple-export-ios-simulator-arm64.cmake b/Tests/RunCMake/CMakePackage/apple-export-ios-simulator-arm64.cmake new file mode 100644 index 0000000..6984df2 --- /dev/null +++ b/Tests/RunCMake/CMakePackage/apple-export-ios-simulator-arm64.cmake @@ -0,0 +1,2 @@ +set(platform_name ios-simulator-arm64) +include(apple-export-ios-simulator-common.cmake) diff --git a/Tests/RunCMake/CMakePackage/apple-export-ios-simulator-common.cmake b/Tests/RunCMake/CMakePackage/apple-export-ios-simulator-common.cmake new file mode 100644 index 0000000..ac09d65 --- /dev/null +++ b/Tests/RunCMake/CMakePackage/apple-export-ios-simulator-common.cmake @@ -0,0 +1,13 @@ +include(apple-export-common.cmake) + +if(IOS_SIMULATOR_SELECT_ARCHS) + generate_apple_architecture_selection_file(mylib-select-arch-install.cmake + INSTALL_DESTINATION lib/ios-simulator/cmake/mylib + INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} + SINGLE_ARCHITECTURES "${IOS_SIMULATOR_SELECT_ARCHS}" + SINGLE_ARCHITECTURE_CONFIG_FILES "lib/ios-simulator-arm64/cmake/mylib/mylib-targets.cmake;lib/ios-simulator-x86_64/cmake/mylib/mylib-targets.cmake" + UNIVERSAL_ARCHITECTURES "${IOS_SIMULATOR_SELECT_ARCHS}" + UNIVERSAL_CONFIG_FILE "lib/ios-simulator/cmake/mylib/mylib-targets.cmake" + ) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mylib-select-arch-install.cmake DESTINATION lib/ios-simulator/cmake/mylib RENAME mylib-select-arch.cmake) +endif() diff --git a/Tests/RunCMake/CMakePackage/apple-export-ios-simulator-x86_64.cmake b/Tests/RunCMake/CMakePackage/apple-export-ios-simulator-x86_64.cmake new file mode 100644 index 0000000..290cfa7 --- /dev/null +++ b/Tests/RunCMake/CMakePackage/apple-export-ios-simulator-x86_64.cmake @@ -0,0 +1,2 @@ +set(platform_name ios-simulator-x86_64) +include(apple-export-ios-simulator-common.cmake) diff --git a/Tests/RunCMake/CMakePackage/apple-export-ios-simulator.cmake b/Tests/RunCMake/CMakePackage/apple-export-ios-simulator.cmake index dd545bb..bc3deb3 100644 --- a/Tests/RunCMake/CMakePackage/apple-export-ios-simulator.cmake +++ b/Tests/RunCMake/CMakePackage/apple-export-ios-simulator.cmake @@ -1,2 +1,2 @@ set(platform_name ios-simulator) -include(apple-export-common.cmake) +include(apple-export-ios-simulator-common.cmake) diff --git a/Tests/RunCMake/CMakePackage/apple-import-ios-simulator-arm64-stdout.txt b/Tests/RunCMake/CMakePackage/apple-import-ios-simulator-arm64-stdout.txt new file mode 100644 index 0000000..7999474 --- /dev/null +++ b/Tests/RunCMake/CMakePackage/apple-import-ios-simulator-arm64-stdout.txt @@ -0,0 +1 @@ +loaded: '[^']*/Tests/RunCMake/CMakePackage/apple-install/lib/ios-simulator-arm64/cmake/mylib/mylib-targets.cmake' diff --git a/Tests/RunCMake/CMakePackage/apple-import-ios-simulator-arm64.cmake b/Tests/RunCMake/CMakePackage/apple-import-ios-simulator-arm64.cmake new file mode 100644 index 0000000..fa7ba53 --- /dev/null +++ b/Tests/RunCMake/CMakePackage/apple-import-ios-simulator-arm64.cmake @@ -0,0 +1 @@ +include(apple-import-common.cmake) diff --git a/Tests/RunCMake/CMakePackage/apple-import-ios-simulator-stdout.txt b/Tests/RunCMake/CMakePackage/apple-import-ios-simulator-stdout.txt new file mode 100644 index 0000000..4ca925d --- /dev/null +++ b/Tests/RunCMake/CMakePackage/apple-import-ios-simulator-stdout.txt @@ -0,0 +1 @@ +loaded: '[^']*/Tests/RunCMake/CMakePackage/apple-install/lib/ios-simulator/cmake/mylib/mylib-targets.cmake' diff --git a/Tests/RunCMake/CMakePackage/apple-import-ios-simulator-x86_64-stdout.txt b/Tests/RunCMake/CMakePackage/apple-import-ios-simulator-x86_64-stdout.txt new file mode 100644 index 0000000..ec52735 --- /dev/null +++ b/Tests/RunCMake/CMakePackage/apple-import-ios-simulator-x86_64-stdout.txt @@ -0,0 +1 @@ +loaded: '[^']*/Tests/RunCMake/CMakePackage/apple-install/lib/ios-simulator-x86_64/cmake/mylib/mylib-targets.cmake' diff --git a/Tests/RunCMake/CMakePackage/apple-import-ios-simulator-x86_64.cmake b/Tests/RunCMake/CMakePackage/apple-import-ios-simulator-x86_64.cmake new file mode 100644 index 0000000..fa7ba53 --- /dev/null +++ b/Tests/RunCMake/CMakePackage/apple-import-ios-simulator-x86_64.cmake @@ -0,0 +1 @@ +include(apple-import-common.cmake) diff --git a/Tests/RunCMake/CMakePackage/apple-import-ios-stdout.txt b/Tests/RunCMake/CMakePackage/apple-import-ios-stdout.txt new file mode 100644 index 0000000..eabb96a --- /dev/null +++ b/Tests/RunCMake/CMakePackage/apple-import-ios-stdout.txt @@ -0,0 +1 @@ +loaded: '[^']*/Tests/RunCMake/CMakePackage/apple-install/lib/ios/cmake/mylib/mylib-targets.cmake' diff --git a/Tests/RunCMake/CMakePackage/apple-import-macos-stdout.txt b/Tests/RunCMake/CMakePackage/apple-import-macos-stdout.txt new file mode 100644 index 0000000..2c3d87d --- /dev/null +++ b/Tests/RunCMake/CMakePackage/apple-import-macos-stdout.txt @@ -0,0 +1 @@ +loaded: '[^']*/Tests/RunCMake/CMakePackage/apple-install/lib/macos/cmake/mylib/mylib-targets.cmake' diff --git a/Tests/RunCMake/CMakePackage/apple-import-tvos-simulator-stdout.txt b/Tests/RunCMake/CMakePackage/apple-import-tvos-simulator-stdout.txt new file mode 100644 index 0000000..544f90f --- /dev/null +++ b/Tests/RunCMake/CMakePackage/apple-import-tvos-simulator-stdout.txt @@ -0,0 +1 @@ +loaded: '[^']*/Tests/RunCMake/CMakePackage/apple-install/lib/tvos-simulator/cmake/mylib/mylib-targets.cmake' diff --git a/Tests/RunCMake/CMakePackage/apple-import-tvos-stdout.txt b/Tests/RunCMake/CMakePackage/apple-import-tvos-stdout.txt new file mode 100644 index 0000000..eccad6a --- /dev/null +++ b/Tests/RunCMake/CMakePackage/apple-import-tvos-stdout.txt @@ -0,0 +1 @@ +loaded: '[^']*/Tests/RunCMake/CMakePackage/apple-install/lib/tvos/cmake/mylib/mylib-targets.cmake' diff --git a/Tests/RunCMake/CMakePackage/apple-import-visionos-simulator-stdout.txt b/Tests/RunCMake/CMakePackage/apple-import-visionos-simulator-stdout.txt new file mode 100644 index 0000000..c4cc068 --- /dev/null +++ b/Tests/RunCMake/CMakePackage/apple-import-visionos-simulator-stdout.txt @@ -0,0 +1 @@ +loaded: '[^']*/Tests/RunCMake/CMakePackage/apple-install/lib/visionos-simulator/cmake/mylib/mylib-targets.cmake' diff --git a/Tests/RunCMake/CMakePackage/apple-import-visionos-stdout.txt b/Tests/RunCMake/CMakePackage/apple-import-visionos-stdout.txt new file mode 100644 index 0000000..410eda2 --- /dev/null +++ b/Tests/RunCMake/CMakePackage/apple-import-visionos-stdout.txt @@ -0,0 +1 @@ +loaded: '[^']*/Tests/RunCMake/CMakePackage/apple-install/lib/visionos/cmake/mylib/mylib-targets.cmake' diff --git a/Tests/RunCMake/CMakePackage/apple-import-watchos-simulator-stdout.txt b/Tests/RunCMake/CMakePackage/apple-import-watchos-simulator-stdout.txt new file mode 100644 index 0000000..752e2be --- /dev/null +++ b/Tests/RunCMake/CMakePackage/apple-import-watchos-simulator-stdout.txt @@ -0,0 +1 @@ +loaded: '[^']*/Tests/RunCMake/CMakePackage/apple-install/lib/watchos-simulator/cmake/mylib/mylib-targets.cmake' diff --git a/Tests/RunCMake/CMakePackage/apple-import-watchos-stdout.txt b/Tests/RunCMake/CMakePackage/apple-import-watchos-stdout.txt new file mode 100644 index 0000000..5654fe8 --- /dev/null +++ b/Tests/RunCMake/CMakePackage/apple-import-watchos-stdout.txt @@ -0,0 +1 @@ +loaded: '[^']*/Tests/RunCMake/CMakePackage/apple-install/lib/watchos/cmake/mylib/mylib-targets.cmake' diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddTest-CMP0158-NEW-check.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddTest-CMP0158-NEW-check.cmake new file mode 100644 index 0000000..8a6a702 --- /dev/null +++ b/Tests/RunCMake/CrosscompilingEmulator/AddTest-CMP0158-NEW-check.cmake @@ -0,0 +1,28 @@ +set(testfile "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake") +if(EXISTS "${testfile}") + file(READ "${testfile}" testfile_contents) +else() + message(FATAL_ERROR "Could not find expected CTestTestfile.cmake.") +endif() + +set(error_details "There is a problem with generated test file: ${testfile}") + +if(testfile_contents MATCHES "add_test[(]DoesNotUseEmulator [^\n]+pseudo_emulator[^\n]+\n") + message(SEND_ERROR "Used emulator when it should not be used. ${error_details}") +endif() + +if(testfile_contents MATCHES "add_test[(]ShouldNotUseEmulator [^\n]+pseudo_emulator[^\n]+\n") + message(SEND_ERROR "Used emulator when it should be used. ${error_details}") +endif() + +if(testfile_contents MATCHES "add_test[(]DoesNotUseEmulatorWithGenex [^\n]+pseudo_emulator[^\n]+\n") + message(SEND_ERROR "Used emulator when it should not be used. ${error_details}") +endif() + +if(testfile_contents MATCHES "add_test[(]ShouldNotUseEmulatorWithExecTargetFromSubdirAddedWithoutGenex [^\n]+pseudo_emulator[^\n]+\n") + message(SEND_ERROR "Used emulator when it should be used. ${error_details}") +endif() + +if(testfile_contents MATCHES "add_test[(]DoesNotUseEmulatorWithExecTargetFromSubdirAddedWithGenex [^\n]+pseudo_emulator[^\n]+\n") + message(SEND_ERROR "Used emulator when it should not be used. ${error_details}") +endif() diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddTest-CMP0158-NEW.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddTest-CMP0158-NEW.cmake new file mode 100644 index 0000000..9f9547c --- /dev/null +++ b/Tests/RunCMake/CrosscompilingEmulator/AddTest-CMP0158-NEW.cmake @@ -0,0 +1,25 @@ +if(CMAKE_CROSSCOMPILING) + message(FATAL_ERROR "cross compiling") +endif() + +cmake_policy(SET CMP0158 NEW) + +enable_testing() +add_test(NAME DoesNotUseEmulator + COMMAND ${CMAKE_COMMAND} -E echo "Hi") + +add_executable(generated_exe simple_src_exiterror.cxx) + +add_test(NAME ShouldNotUseEmulator + COMMAND generated_exe) + +add_test(NAME DoesNotUseEmulatorWithGenex + COMMAND $<TARGET_FILE:generated_exe>) + +add_subdirectory(AddTest) + +add_test(NAME ShouldNotUseEmulatorWithExecTargetFromSubdirAddedWithoutGenex + COMMAND generated_exe_in_subdir_added_to_test_without_genex) + +add_test(NAME DoesNotUseEmulatorWithExecTargetFromSubdirAddedWithGenex + COMMAND $<TARGET_FILE:generated_exe_in_subdir_added_to_test_with_genex>) diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddTest-CMP0158-OLD-check.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddTest-CMP0158-OLD-check.cmake new file mode 100644 index 0000000..588b77b --- /dev/null +++ b/Tests/RunCMake/CrosscompilingEmulator/AddTest-CMP0158-OLD-check.cmake @@ -0,0 +1,28 @@ +set(testfile "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake") +if(EXISTS "${testfile}") + file(READ "${testfile}" testfile_contents) +else() + message(FATAL_ERROR "Could not find expected CTestTestfile.cmake.") +endif() + +set(error_details "There is a problem with generated test file: ${testfile}") + +if(testfile_contents MATCHES "add_test[(]DoesNotUseEmulator [^\n]+pseudo_emulator[^\n]+\n") + message(SEND_ERROR "Used emulator when it should not be used. ${error_details}") +endif() + +if(NOT testfile_contents MATCHES "add_test[(]UsesEmulator [^\n]+pseudo_emulator[^\n]+\n") + message(SEND_ERROR "Did not use emulator when it should be used. ${error_details}") +endif() + +if(testfile_contents MATCHES "add_test[(]DoesNotUseEmulatorWithGenex [^\n]+pseudo_emulator[^\n]+\n") + message(SEND_ERROR "Used emulator when it should not be used. ${error_details}") +endif() + +if(NOT testfile_contents MATCHES "add_test[(]UsesEmulatorWithExecTargetFromSubdirAddedWithoutGenex [^\n]+pseudo_emulator[^\n]+\n") + message(SEND_ERROR "Did not use emulator when it should be used. ${error_details}") +endif() + +if(testfile_contents MATCHES "add_test[(]DoesNotUseEmulatorWithExecTargetFromSubdirAddedWithGenex [^\n]+pseudo_emulator[^\n]+\n") + message(SEND_ERROR "Used emulator when it should not be used. ${error_details}") +endif() diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddTest-CMP0158-OLD.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddTest-CMP0158-OLD.cmake new file mode 100644 index 0000000..910f1b4 --- /dev/null +++ b/Tests/RunCMake/CrosscompilingEmulator/AddTest-CMP0158-OLD.cmake @@ -0,0 +1,25 @@ +if(CMAKE_CROSSCOMPILING) + message(FATAL_ERROR "cross compiling") +endif() + +cmake_policy(SET CMP0158 OLD) + +enable_testing() +add_test(NAME DoesNotUseEmulator + COMMAND ${CMAKE_COMMAND} -E echo "Hi") + +add_executable(generated_exe simple_src_exiterror.cxx) + +add_test(NAME UsesEmulator + COMMAND generated_exe) + +add_test(NAME DoesNotUseEmulatorWithGenex + COMMAND $<TARGET_FILE:generated_exe>) + +add_subdirectory(AddTest) + +add_test(NAME UsesEmulatorWithExecTargetFromSubdirAddedWithoutGenex + COMMAND generated_exe_in_subdir_added_to_test_without_genex) + +add_test(NAME DoesNotUseEmulatorWithExecTargetFromSubdirAddedWithGenex + COMMAND $<TARGET_FILE:generated_exe_in_subdir_added_to_test_with_genex>) diff --git a/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake index 1ffd91c..c595f1a 100644 --- a/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake +++ b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake @@ -6,6 +6,8 @@ set(RunCMake_TEST_OPTIONS run_cmake(CrosscompilingEmulatorProperty) run_cmake(TryRun) run_cmake(AddTest) +run_cmake(AddTest-CMP0158-OLD) +run_cmake(AddTest-CMP0158-NEW) function(CustomCommandGenerator_run_and_build case) # Use a single build tree for a few tests without cleaning. diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-POST_BUILD-timeout-build-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-POST_BUILD-timeout-build-stdout.txt index 3a6572c..84bbe9f 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-POST_BUILD-timeout-build-stdout.txt +++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-POST_BUILD-timeout-build-stdout.txt @@ -2,6 +2,7 @@ ( *|[0-9]+>) Error running test executable. ?( *|[0-9]+>) ( *|[0-9]+>) Path: '.*discovery_timeout_test(\.exe)?' +( *|[0-9]+>) Working directory: '[^']*/Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout' ( *|[0-9]+>) Result: Process terminated due to timeout ( *|[0-9]+>) Output: ( *|[0-9]+>) + diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-PRE_TEST-timeout-test-stderr.txt b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-PRE_TEST-timeout-test-stderr.txt index 75afe4a..03d73ee 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-PRE_TEST-timeout-test-stderr.txt +++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-PRE_TEST-timeout-test-stderr.txt @@ -2,6 +2,7 @@ CMake Error at .*GoogleTestAddTests.cmake:[0-9]+ \(message\): [ \t]*Error running test executable. + [ \t]*Path: '.*discovery_timeout_test(\.exe)?' +[ \t]*Working directory: '[^']*/Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout' [ \t]*Result: Process terminated due to timeout [ \t]*Output: [ \t]*timeout. diff --git a/Tests/RunCMake/Ninja/LINK_OPTIONSWithNewlines.cmake b/Tests/RunCMake/Ninja/LINK_OPTIONSWithNewlines.cmake new file mode 100644 index 0000000..285966e --- /dev/null +++ b/Tests/RunCMake/Ninja/LINK_OPTIONSWithNewlines.cmake @@ -0,0 +1,7 @@ +enable_language(C) + +add_library(hello STATIC hello.c) + +target_link_options(hello PRIVATE "-FLAGS=[ + FLAG1, + FLAG2]") diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index 8d9aa6f..f020f0d 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -407,3 +407,5 @@ endfunction() if(CMake_TEST_Qt_version) run_QtAutoMocSkipPch() endif() + +run_cmake(LINK_OPTIONSWithNewlines) diff --git a/Tests/RunCMake/Swift/CMP0157-OLD-build-stdout.txt b/Tests/RunCMake/Swift/CMP0157-OLD-build-stdout.txt new file mode 100644 index 0000000..0955c61 --- /dev/null +++ b/Tests/RunCMake/Swift/CMP0157-OLD-build-stdout.txt @@ -0,0 +1 @@ +swiftc .* -output-file-map CMakeFiles/greetings_default.dir//output-file-map.json .* diff --git a/Tests/RunCMake/Swift/RunCMakeTest.cmake b/Tests/RunCMake/Swift/RunCMakeTest.cmake index 68d10ea..184b461 100644 --- a/Tests/RunCMake/Swift/RunCMakeTest.cmake +++ b/Tests/RunCMake/Swift/RunCMakeTest.cmake @@ -49,9 +49,17 @@ elseif(RunCMake_GENERATOR STREQUAL Ninja) run_cmake_command(IncrementalSwift-second ${CMAKE_COMMAND} --build ${IncrementalSwift_TEST_BINARY_DIR} -- -d explain) endblock() - run_cmake(CMP0157-NEW) - run_cmake(CMP0157-OLD) - run_cmake(CMP0157-WARN) + block() + set(CMP0157-OLD_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0157-OLD-build) + set(CMP0157-OLD_TEST_NO_CLEAN 1) + set(CMP0157-OLD_TEST_OUTPUT_MERGE 1) + + run_cmake(CMP0157-NEW) + run_cmake(CMP0157-OLD) + # -n: dry-run to avoid actually compiling, -v: verbose to capture executed command + run_cmake_command(CMP0157-OLD-build ${CMAKE_COMMAND} --build ${CMP0157-OLD_TEST_BINARY_DIR} -- -n -v) + run_cmake(CMP0157-WARN) + endblock() endif() elseif(RunCMake_GENERATOR STREQUAL "Ninja Multi-Config") diff --git a/Tests/RunCMake/VS10Project/UnityBuildPre2017-check.cmake b/Tests/RunCMake/VS10Project/UnityBuildPre2017-check.cmake index 17e7b46..c904cd0 100644 --- a/Tests/RunCMake/VS10Project/UnityBuildPre2017-check.cmake +++ b/Tests/RunCMake/VS10Project/UnityBuildPre2017-check.cmake @@ -27,7 +27,7 @@ foreach(line IN LISTS tgt_projects_strings) endif() endforeach() -string(REPLACE "\\" "/" unity_source_line ${unity_source_line}) +string(REPLACE "\\" "/" unity_source_line "${unity_source_line}") string(FIND "${unity_source_line}" "CMakeFiles/tgt.dir/Unity/unity_0_c.c" unity_source_file_position) if (unity_source_file_position EQUAL "-1") set(RunCMake_TEST_FAILED "Generated project should include the generated unity source file.") diff --git a/Tests/RunCMake/target_link_libraries/ImportedTargetPerConfig.cmake b/Tests/RunCMake/target_link_libraries/ImportedTargetPerConfig.cmake new file mode 100644 index 0000000..a143617 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/ImportedTargetPerConfig.cmake @@ -0,0 +1,27 @@ +enable_language(C) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(NOT _isMultiConfig AND NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Debug") +endif() + +add_library(StaticImported STATIC IMPORTED) + +# Test with no IMPORTED_CONFIGURATIONS, which works if the +# imported target provides all exact-name configurations +# built by this project. See issue #25515. +set_target_properties(StaticImported PROPERTIES + IMPORTED_LOCATION_DEBUG "a" + IMPORTED_LOCATION_RELEASE "b" + IMPORTED_LOCATION_MINSIZEREL "c" + IMPORTED_LOCATION_RELWITHDEBINFO "d" + ) + +add_library(StaticLib STATIC empty.c) + +# The Xcode generator queries imported targets for system +# include directories, but without any specific config. +set_source_files_properties(empty.c PROPERTIES + INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}" + ) + +target_link_libraries(StaticLib PRIVATE StaticImported) diff --git a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake index 0e3877a..1bcebb8 100644 --- a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake @@ -25,6 +25,7 @@ run_cmake(CMP0108-NEW-self-link) run_cmake(ImportedTarget) run_cmake(ImportedTargetStub) run_cmake(ImportedTargetFailure) +run_cmake(ImportedTargetPerConfig) run_cmake(MixedSignature) run_cmake(Separate-PRIVATE-LINK_PRIVATE-uses) run_cmake(SharedDepNotTarget) |