CUDA: Add support for [CMAKE_]CUDA_LINKER_LAUNCHER

`CMAKE_<LANG>_LINKER_LAUNCHER` and `<LANG>_LINKER_LAUNCHER` are
already support for C, CXX, OBJC, OBJCXX, and Fortran.  Add CUDA.

Issue: #26967
This commit is contained in:
Maximilian Sander
2025-05-30 14:38:24 +02:00
committed by Brad King
parent ab5866c2d2
commit 77312cc636
16 changed files with 47 additions and 1 deletions

View File

@@ -6,9 +6,17 @@
This property is implemented only when ``<LANG>`` is one of:
* ``C``
* ``CXX``
* ``CUDA``
.. versionadded:: 4.1
* ``OBJC``
* ``OBJCXX``
* ``Fortran``
.. versionadded:: 4.1

View File

@@ -2,6 +2,6 @@ linker-launcher
---------------
* :ref:`Makefile Generators` and :ref:`Ninja Generators` gained support
for adding a linker launcher with ``Fortran``.
for adding a linker launcher with ``Fortran`` and ``CUDA``.
See the :variable:`CMAKE_<LANG>_LINKER_LAUNCHER` variable
and :prop_tgt:`<LANG>_LINKER_LAUNCHER` target property for details.

View File

@@ -8,9 +8,17 @@ variable is used to initialize the property on each target as it is created.
This is done only when ``<LANG>`` is one of:
* ``C``
* ``CXX``
* ``CUDA``
.. versionadded:: 4.1
* ``OBJC``
* ``OBJCXX``
* ``Fortran``
.. versionadded:: 4.1

View File

@@ -75,6 +75,11 @@ if(NOT CMAKE_CUDA_COMPILER_LAUNCHER AND DEFINED ENV{CMAKE_CUDA_COMPILER_LAUNCHER
CACHE STRING "Compiler launcher for CUDA.")
endif()
if(NOT CMAKE_CUDA_LINKER_LAUNCHER AND DEFINED ENV{CMAKE_CUDA_LINKER_LAUNCHER})
set(CMAKE_CUDA_LINKER_LAUNCHER "$ENV{CMAKE_CUDA_LINKER_LAUNCHER}"
CACHE STRING "Linker launcher for CUDA.")
endif()
include(CMakeCommonLanguageInclude)
_cmake_common_language_platform_flags(CUDA)

View File

@@ -449,6 +449,7 @@ TargetProperty const StaticTargetProperties[] = {
// ---- C++
{ "CXX_LINKER_LAUNCHER"_s, IC::CanCompileSources },
// ---- CUDA
{ "CUDA_LINKER_LAUNCHER"_s, IC::CanCompileSources },
{ "CUDA_RESOLVE_DEVICE_SYMBOLS"_s, IC::CanCompileSources },
{ "CUDA_RUNTIME_LIBRARY"_s, IC::CanCompileSources },
// ---- HIP

View File

@@ -0,0 +1 @@
.*-E env USED_LAUNCHER=1.*

View File

@@ -0,0 +1,4 @@
cmake_policy(SET CMP0104 NEW)
enable_language(CUDA)
set(CMAKE_VERBOSE_MAKEFILE TRUE)
add_executable(main main.cu)

View File

@@ -0,0 +1 @@
.*-E env USED_LAUNCHER=1 TARGET_NAME=main LANGUAGE=CUDA.*

View File

@@ -0,0 +1 @@
include(CUDA-common.cmake)

View File

@@ -0,0 +1 @@
.*-E env USED_LAUNCHER=1.*

View File

@@ -0,0 +1 @@
.*-E env USED_LAUNCHER=1 TARGET_NAME=main LANGUAGE=CUDA.*

View File

@@ -0,0 +1,3 @@
set(CTEST_USE_LAUNCHERS 1)
include(CTestUseLaunchers)
include(CUDA-env.cmake)

View File

@@ -0,0 +1,3 @@
set(CTEST_USE_LAUNCHERS 1)
include(CTestUseLaunchers)
include(CUDA.cmake)

View File

@@ -0,0 +1,2 @@
set(CMAKE_CUDA_LINKER_LAUNCHER "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1")
include(CUDA-common.cmake)

View File

@@ -24,6 +24,9 @@ function(run_linker_launcher_env lang)
endfunction()
set(langs C CXX)
if(CMake_TEST_CUDA)
list(APPEND langs CUDA)
endif()
if(CMake_TEST_Fortran)
list(APPEND langs Fortran)
endif()

View File

@@ -0,0 +1,4 @@
int main()
{
return 0;
}