diff --git a/Help/prop_tgt/LANG_LINKER_LAUNCHER.rst b/Help/prop_tgt/LANG_LINKER_LAUNCHER.rst index 875cf740bc..86f5f871fd 100644 --- a/Help/prop_tgt/LANG_LINKER_LAUNCHER.rst +++ b/Help/prop_tgt/LANG_LINKER_LAUNCHER.rst @@ -11,7 +11,7 @@ This property is implemented only when ```` is one of: * ``CUDA`` - .. versionadded:: 4.1 + .. versionadded:: 4.5 * ``OBJC`` @@ -23,7 +23,7 @@ This property is implemented only when ```` is one of: * ``HIP`` - .. versionadded:: 4.1 + .. versionadded:: 4.5 Specify a :ref:`semicolon-separated list ` containing a command line for a linker launching tool. The :ref:`Makefile Generators` and the diff --git a/Help/release/4.1.rst b/Help/release/4.1.rst index 7b69e0a9e5..811ae21e3d 100644 --- a/Help/release/4.1.rst +++ b/Help/release/4.1.rst @@ -21,7 +21,7 @@ Generators ---------- * :ref:`Makefile Generators` and :ref:`Ninja Generators` gained support - for adding a linker launcher with ``Fortran``, ``CUDA``, and ``HIP``. + for adding a linker launcher with ``Fortran``. See the :variable:`CMAKE__LINKER_LAUNCHER` variable and :prop_tgt:`_LINKER_LAUNCHER` target property for details. diff --git a/Help/release/dev/cuda-hip-linker-launcher.rst b/Help/release/dev/cuda-hip-linker-launcher.rst new file mode 100644 index 0000000000..f6b7012de7 --- /dev/null +++ b/Help/release/dev/cuda-hip-linker-launcher.rst @@ -0,0 +1,7 @@ +cuda-hip-linker-launcher +------------------------ + +* :ref:`Makefile Generators` and :ref:`Ninja Generators` gained support + for adding a linker launcher with ``CUDA`` and ``HIP``. + See the :variable:`CMAKE__LINKER_LAUNCHER` variable + and :prop_tgt:`_LINKER_LAUNCHER` target property for details. diff --git a/Help/variable/CMAKE_LANG_LINKER_LAUNCHER.rst b/Help/variable/CMAKE_LANG_LINKER_LAUNCHER.rst index d51951ac4e..f2db00b69a 100644 --- a/Help/variable/CMAKE_LANG_LINKER_LAUNCHER.rst +++ b/Help/variable/CMAKE_LANG_LINKER_LAUNCHER.rst @@ -13,7 +13,7 @@ This is done only when ```` is one of: * ``CUDA`` - .. versionadded:: 4.1 + .. versionadded:: 4.5 * ``OBJC`` @@ -25,7 +25,7 @@ This is done only when ```` is one of: * ``HIP`` - .. versionadded:: 4.1 + .. versionadded:: 4.5 This variable is initialized to the :envvar:`CMAKE__LINKER_LAUNCHER` environment variable if it is set. diff --git a/Source/cmRulePlaceholderExpander.cxx b/Source/cmRulePlaceholderExpander.cxx index 1c7000144b..0386a4d1bf 100644 --- a/Source/cmRulePlaceholderExpander.cxx +++ b/Source/cmRulePlaceholderExpander.cxx @@ -54,6 +54,19 @@ std::string cmRulePlaceholderExpander::ExpandVariable( return result; } } + if (this->ReplaceValues->Language && this->ReplaceValues->Launcher && + variable == + cmStrCat("CMAKE_", this->ReplaceValues->Language, + "_HOST_LINK_LAUNCHER")) { + auto mapIt = this->VariableMappings.find(variable); + std::string result = mapIt != this->VariableMappings.end() + ? this->ConvertToOutputForExisting(mapIt->second) + : variable; + // Add launcher as part of expansion so that it always appears + // immediately before the command itself, regardless of whether the + // overall rule template contains other content at the front. + return cmStrCat(this->ReplaceValues->Launcher, ' ', result); + } if (this->ReplaceValues->Manifests) { if (variable == "MANIFESTS") { return this->ReplaceValues->Manifests; diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index c407722a7b..400304cfe3 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -1337,29 +1337,33 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja|FASTBuild") -DPSEUDO_CPPCHECK=$ ) + add_RunCMake_test(ctest_labels_for_subprojects) + add_RunCMake_test(CompilerArgs) + + # Enable supported languages for {Compiler,Linker}Launcher. if(DEFINED CMake_TEST_CUDA) - list(APPEND CompilerLauncher_ARGS -DCMake_TEST_CUDA=${CMake_TEST_CUDA}) + list(APPEND LauncherCommon_ARGS -DCMake_TEST_CUDA=${CMake_TEST_CUDA}) endif() if(DEFINED CMake_TEST_HIP) - list(APPEND CompilerLauncher_ARGS -DCMake_TEST_HIP=${CMake_TEST_HIP}) - endif() - if(DEFINED CMake_TEST_ISPC) - list(APPEND CompilerLauncher_ARGS -DCMake_TEST_ISPC=${CMake_TEST_ISPC}) + list(APPEND LauncherCommon_ARGS -DCMake_TEST_HIP=${CMake_TEST_HIP}) endif() if(DEFINED CMake_TEST_OBJC) - list(APPEND CompilerLauncher_ARGS -DCMake_TEST_OBJC=${CMake_TEST_OBJC}) - list(APPEND LinkerLauncher_ARGS -DCMake_TEST_OBJC=${CMake_TEST_OBJC}) + list(APPEND LauncherCommon_ARGS -DCMake_TEST_OBJC=${CMake_TEST_OBJC}) endif() if(CMAKE_Fortran_COMPILER) - list(APPEND CompilerLauncher_ARGS -DCMake_TEST_Fortran=1) + list(APPEND LauncherCommon_ARGS -DCMake_TEST_Fortran=1) + endif() + set(CompilerLauncher_ARGS ${LauncherCommon_ARGS}) + set(LinkerLauncher_ARGS ${LauncherCommon_ARGS}) + if(DEFINED CMake_TEST_ISPC) + list(APPEND CompilerLauncher_ARGS -DCMake_TEST_ISPC=${CMake_TEST_ISPC}) endif() add_RunCMake_test(CompilerLauncher) set_property(TEST RunCMake.CompilerLauncher APPEND PROPERTY LABELS "CUDA" "HIP" "ISPC" "Fortran") - - add_RunCMake_test(ctest_labels_for_subprojects) - add_RunCMake_test(CompilerArgs) add_RunCMake_test(LinkerLauncher) + set_property(TEST RunCMake.LinkerLauncher APPEND + PROPERTY LABEL "CUDA" "HIP" "Fortran") endif() set(cpack_tests