Merge topic 'test-RunCMake.ExternalProject' 3253bc306e Tests: Optionally run RunCMake.ExternalProject serially Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !9129
diff --git a/Help/command/get_cmake_property.rst b/Help/command/get_cmake_property.rst index b1d18a0..9f78a86 100644 --- a/Help/command/get_cmake_property.rst +++ b/Help/command/get_cmake_property.rst
@@ -5,11 +5,11 @@ .. code-block:: cmake - get_cmake_property(<var> <property>) + get_cmake_property(<variable> <property>) Gets a global property from the CMake instance. The value of -the ``<property>`` is stored in the variable ``<var>``. -If the property is not found, ``<var>`` will be set to ``NOTFOUND``. +the ``<property>`` is stored in the specified ``<variable>``. +If the property is not found, ``<variable>`` will be set to ``NOTFOUND``. See the :manual:`cmake-properties(7)` manual for available properties. In addition to global properties, this command (for historical reasons)
diff --git a/Help/command/get_source_file_property.rst b/Help/command/get_source_file_property.rst index e83e9c2..a7e5191 100644 --- a/Help/command/get_source_file_property.rst +++ b/Help/command/get_source_file_property.rst
@@ -9,14 +9,12 @@ [DIRECTORY <dir> | TARGET_DIRECTORY <target>] <property>) -Gets a property from a source file. The value of the property is -stored in the specified ``<variable>``. If the source property is not found, -the behavior depends on whether it has been defined to be an ``INHERITED`` -property or not (see :command:`define_property`). Non-inherited properties -will set ``variable`` to ``NOTFOUND``, whereas inherited properties will search -the relevant parent scope as described for the :command:`define_property` -command and if still unable to find the property, ``variable`` will be set to -an empty string. +Gets a property from a source file. The value of the property is stored in +the specified ``<variable>``. If the ``<file>`` is not a source file, or the +source property is not found, ``<variable>`` will be set to ``NOTFOUND``. +If the source property was defined to be an ``INHERITED`` property (see +:command:`define_property`), the search will include the relevant parent +scopes, as described for the :command:`define_property` command. By default, the source file's property will be read from the current source directory's scope.
diff --git a/Help/command/get_target_property.rst b/Help/command/get_target_property.rst index 8c6dcb1..1554a85 100644 --- a/Help/command/get_target_property.rst +++ b/Help/command/get_target_property.rst
@@ -5,16 +5,14 @@ .. code-block:: cmake - get_target_property(<VAR> target property) + get_target_property(<variable> <target> <property>) -Get a property from a target. The value of the property is stored in -the variable ``<VAR>``. If the target property is not found, the behavior -depends on whether it has been defined to be an ``INHERITED`` property -or not (see :command:`define_property`). Non-inherited properties will -set ``<VAR>`` to ``<VAR>-NOTFOUND``, whereas inherited properties will search -the relevant parent scope as described for the :command:`define_property` -command and if still unable to find the property, ``<VAR>`` will be set to -an empty string. +Get a property from a target. The value of the property is stored in the +specified ``<variable>``. If the target property is not found, ``<variable>`` +will be set to ``<variable>-NOTFOUND``. If the target property was defined to +be an ``INHERITED`` property (see :command:`define_property`), the search will +include the relevant parent scopes, as described for the +:command:`define_property` command. Use :command:`set_target_properties` to set target property values. Properties are usually used to control how a target is built, but some
diff --git a/Help/command/get_test_property.rst b/Help/command/get_test_property.rst index 1fcf24e..3f1a64c 100644 --- a/Help/command/get_test_property.rst +++ b/Help/command/get_test_property.rst
@@ -5,16 +5,14 @@ .. code-block:: cmake - get_test_property(test property [DIRECTORY <dir>] VAR) + get_test_property(<test> <property> [DIRECTORY <dir>] <variable>) Get a property from the test. The value of the property is stored in -the variable ``VAR``. If the test property is not found, the behavior -depends on whether it has been defined to be an ``INHERITED`` property -or not (see :command:`define_property`). Non-inherited properties will -set ``VAR`` to "NOTFOUND", whereas inherited properties will search the -relevant parent scope as described for the :command:`define_property` -command and if still unable to find the property, ``VAR`` will be set to -an empty string. +the specified ``<variable>``. If the ``<test>`` is not defined, or the +test property is not found, ``<variable>`` will be set to ``NOTFOUND``. +If the test property was defined to be an ``INHERITED`` property (see +:command:`define_property`), the search will include the relevant parent +scopes, as described for the :command:`define_property` command. For a list of standard properties you can type :option:`cmake --help-property-list`.
diff --git a/Help/command/set_directory_properties.rst b/Help/command/set_directory_properties.rst index 93ad39b..6d94808 100644 --- a/Help/command/set_directory_properties.rst +++ b/Help/command/set_directory_properties.rst
@@ -5,9 +5,10 @@ .. code-block:: cmake - set_directory_properties(PROPERTIES prop1 value1 [prop2 value2] ...) + set_directory_properties(PROPERTIES <prop1> <value1> [<prop2> <value2>] ...) -Sets properties of the current directory and its subdirectories in key-value pairs. +Sets properties of the current directory and its subdirectories in key-value +pairs. See also the :command:`set_property(DIRECTORY)` command.
diff --git a/Help/command/set_target_properties.rst b/Help/command/set_target_properties.rst index 874788b..5357575 100644 --- a/Help/command/set_target_properties.rst +++ b/Help/command/set_target_properties.rst
@@ -5,9 +5,9 @@ .. code-block:: cmake - set_target_properties(target1 target2 ... - PROPERTIES prop1 value1 - prop2 value2 ...) + set_target_properties(<targets> ... + PROPERTIES <prop1> <value1> + [<prop2> <value2>] ...) Sets properties on targets. The syntax for the command is to list all the targets you want to change, and then provide the values you want to
diff --git a/Help/command/set_tests_properties.rst b/Help/command/set_tests_properties.rst index da750e3..a21f746 100644 --- a/Help/command/set_tests_properties.rst +++ b/Help/command/set_tests_properties.rst
@@ -5,7 +5,10 @@ .. code-block:: cmake - set_tests_properties(test1 [test2...] PROPERTIES prop1 value1 prop2 value2) + set_tests_properties(<tests>... + [DIRECTORY <dir>] + PROPERTIES <prop1> <value1> + [<prop2> <value2>]...) Sets a property for the tests. If the test is not found, CMake will report an error.
diff --git a/Modules/CheckLanguage.cmake b/Modules/CheckLanguage.cmake index 94948b9..bad3590 100644 --- a/Modules/CheckLanguage.cmake +++ b/Modules/CheckLanguage.cmake
@@ -41,6 +41,12 @@ not be set without also setting :variable:`CMAKE_<LANG>_COMPILER` to a NVCC compiler. + :variable:`CMAKE_<LANG>_PLATFORM <CMAKE_HIP_PLATFORM>` + This variable is set to the detected GPU platform when ``<lang>`` is ``HIP``. + + If the variable is already set its value is always preserved. Only compatible values + will be considered for :variable:`CMAKE_<LANG>_COMPILER`. + For example: .. code-block:: cmake @@ -66,15 +72,23 @@ set(extra_compiler_variables) if("${lang}" MATCHES "^(CUDA|HIP)$" AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") - set(extra_compiler_variables "set(CMAKE_CUDA_HOST_COMPILER \\\"\${CMAKE_CUDA_HOST_COMPILER}\\\")") + set(extra_compiler_variables "set(CMAKE_${lang}_HOST_COMPILER \\\"\${CMAKE_${lang}_HOST_COMPILER}\\\")") endif() + if("${lang}" STREQUAL "HIP") + list(APPEND extra_compiler_variables "set(CMAKE_${lang}_PLATFORM \\\"\${CMAKE_${lang}_PLATFORM}\\\")") + endif() + + list(TRANSFORM extra_compiler_variables PREPEND "\"") + list(TRANSFORM extra_compiler_variables APPEND "\\n\"") + list(JOIN extra_compiler_variables "\n " extra_compiler_variables) + set(_cl_content "cmake_minimum_required(VERSION ${CMAKE_VERSION}) project(Check${lang} ${lang}) file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\" \"set(CMAKE_${lang}_COMPILER \\\"\${CMAKE_${lang}_COMPILER}\\\")\\n\" - \"${extra_compiler_variables}\\n\" + ${extra_compiler_variables} )" ) @@ -95,6 +109,11 @@ else() set(_D_CMAKE_TOOLCHAIN_FILE "") endif() + if(CMAKE_${lang}_PLATFORM) + set(_D_CMAKE_LANG_PLATFORM "-DCMAKE_${lang}_PLATFORM:STRING=${CMAKE_${lang}_PLATFORM}") + else() + set(_D_CMAKE_LANG_PLATFORM "") + endif() execute_process( WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang} COMMAND ${CMAKE_COMMAND} . -G ${CMAKE_GENERATOR} @@ -103,6 +122,7 @@ ${_D_CMAKE_GENERATOR_INSTANCE} ${_D_CMAKE_MAKE_PROGRAM} ${_D_CMAKE_TOOLCHAIN_FILE} + ${_D_CMAKE_LANG_PLATFORM} OUTPUT_VARIABLE _cl_output ERROR_VARIABLE _cl_output RESULT_VARIABLE _cl_result @@ -130,6 +150,10 @@ mark_as_advanced(CMAKE_${lang}_HOST_COMPILER) endif() + if(CMAKE_${lang}_PLATFORM) + set(CMAKE_${lang}_PLATFORM "${CMAKE_${lang}_PLATFORM}" CACHE STRING "${lang} platform") + mark_as_advanced(CMAKE_${lang}_PLATFORM) + endif() endif() endmacro()
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index eda95c1..fd10a16 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 20240104) +set(CMake_VERSION_PATCH 20240105) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Tests/CMakeOnly/CMakeLists.txt b/Tests/CMakeOnly/CMakeLists.txt index a41b44e..30cabf1 100644 --- a/Tests/CMakeOnly/CMakeLists.txt +++ b/Tests/CMakeOnly/CMakeLists.txt
@@ -25,6 +25,13 @@ add_CMakeOnly_test(CheckCXXCompilerFlag) add_CMakeOnly_test(CheckLanguage) +if (CMake_TEST_HIP) + set_property(TEST CMakeOnly.CheckLanguage APPEND PROPERTY LABELS "HIP") + add_CMakeOnly_test(CheckLanguageHIPPlatform) + set_property(TEST CMakeOnly.CheckLanguageHIPPlatform APPEND PROPERTY LABELS "HIP") + add_CMakeOnly_test(CheckLanguageHIPPlatform2) + set_property(TEST CMakeOnly.CheckLanguageHIPPlatform2 APPEND PROPERTY LABELS "HIP") +endif() add_CMakeOnly_test(CheckStructHasMember)
diff --git a/Tests/CMakeOnly/CheckLanguageHIPPlatform/CMakeLists.txt b/Tests/CMakeOnly/CheckLanguageHIPPlatform/CMakeLists.txt new file mode 100644 index 0000000..03b8aa0 --- /dev/null +++ b/Tests/CMakeOnly/CheckLanguageHIPPlatform/CMakeLists.txt
@@ -0,0 +1,17 @@ +cmake_minimum_required (VERSION 3.28) +project(CheckLanguageHIPPlatform NONE) +include(CheckLanguage) + +check_language(HIP) + +if(NOT DEFINED CMAKE_HIP_COMPILER) + message(FATAL_ERROR "check_language did not set result") +endif() + +if (NOT CMAKE_HIP_COMPILER) + message(FATAL_ERROR "check_language should not fail!") +endif() + +if (NOT DEFINED CMAKE_HIP_PLATFORM) + message(FATAL_ERROR "check_language did not set CMAKE_HIP_PLATFORM!") +endif()
diff --git a/Tests/CMakeOnly/CheckLanguageHIPPlatform2/CMakeLists.txt b/Tests/CMakeOnly/CheckLanguageHIPPlatform2/CMakeLists.txt new file mode 100644 index 0000000..f251c49 --- /dev/null +++ b/Tests/CMakeOnly/CheckLanguageHIPPlatform2/CMakeLists.txt
@@ -0,0 +1,14 @@ +cmake_minimum_required (VERSION 3.28) +project(CheckLanguageHIPPlatform2 NONE) +include(CheckLanguage) + +set(CMAKE_HIP_PLATFORM "not-a-hip-platform" CACHE STRING "") +check_language(HIP) + +if(NOT DEFINED CMAKE_HIP_COMPILER) + message(FATAL_ERROR "check_language did not set result") +endif() + +if (CMAKE_HIP_COMPILER) + message(FATAL_ERROR "check_language should have failed") +endif()