summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/target_link_options
diff options
context:
space:
mode:
authorRaul Tambre <raul@tambre.ee>2021-11-06 10:54:07 (GMT)
committerRaul Tambre <raul@tambre.ee>2021-11-08 19:26:00 (GMT)
commit4707ecbe6fed1e135785f9fe9734a4c66807dd77 (patch)
tree1519f6d6bec23dcd2518284d030876e2c073f582 /Tests/RunCMake/target_link_options
parent15fde4c420e0fa469077fad020b9fdc071796f70 (diff)
downloadCMake-4707ecbe6fed1e135785f9fe9734a4c66807dd77.zip
CMake-4707ecbe6fed1e135785f9fe9734a4c66807dd77.tar.gz
CMake-4707ecbe6fed1e135785f9fe9734a4c66807dd77.tar.bz2
CUDA: Support CMP0105 on Clang
Add link flags during the "device compile" step. Enabled the relevant tests. The disable reasons regarding separable compilation were outdated and the actual failure case was device link flags support.
Diffstat (limited to 'Tests/RunCMake/target_link_options')
-rw-r--r--Tests/RunCMake/target_link_options/RunCMakeTest.cmake17
-rw-r--r--Tests/RunCMake/target_link_options/genex_DEVICE_LINK-host_link_options-check.cmake9
-rw-r--r--Tests/RunCMake/target_link_options/genex_DEVICE_LINK.cmake39
3 files changed, 34 insertions, 31 deletions
diff --git a/Tests/RunCMake/target_link_options/RunCMakeTest.cmake b/Tests/RunCMake/target_link_options/RunCMakeTest.cmake
index a707383..1a29ecf 100644
--- a/Tests/RunCMake/target_link_options/RunCMakeTest.cmake
+++ b/Tests/RunCMake/target_link_options/RunCMakeTest.cmake
@@ -53,16 +53,13 @@ if (NOT CMAKE_C_COMPILER_ID STREQUAL "Intel")
run_cmake_target(genex_DEVICE_LINK interface LinkOptions_shared_interface --config Release)
run_cmake_target(genex_DEVICE_LINK private LinkOptions_private --config Release)
if (CMake_TEST_CUDA)
- # Separable compilation is only supported on NVCC.
- if(NOT CMake_TEST_CUDA STREQUAL "Clang")
- run_cmake_target(genex_DEVICE_LINK CMP0105_UNSET LinkOptions_CMP0105_UNSET --config Release)
- run_cmake_target(genex_DEVICE_LINK CMP0105_OLD LinkOptions_CMP0105_OLD --config Release)
- run_cmake_target(genex_DEVICE_LINK CMP0105_NEW LinkOptions_CMP0105_NEW --config Release)
- run_cmake_target(genex_DEVICE_LINK device LinkOptions_device --config Release)
-
- if (RunCMake_GENERATOR MATCHES "(Ninja|Unix Makefiles)")
- run_cmake_target(genex_DEVICE_LINK host_link_options LinkOptions_host_link_options --config Release ${VERBOSE})
- endif()
+ run_cmake_target(genex_DEVICE_LINK CMP0105_UNSET LinkOptions_CMP0105_UNSET --config Release)
+ run_cmake_target(genex_DEVICE_LINK CMP0105_OLD LinkOptions_CMP0105_OLD --config Release)
+ run_cmake_target(genex_DEVICE_LINK CMP0105_NEW LinkOptions_CMP0105_NEW --config Release)
+ run_cmake_target(genex_DEVICE_LINK device LinkOptions_device --config Release)
+
+ if (RunCMake_GENERATOR MATCHES "(Ninja|Unix Makefiles)")
+ run_cmake_target(genex_DEVICE_LINK host_link_options LinkOptions_host_link_options --config Release ${VERBOSE})
endif()
run_cmake_target(genex_DEVICE_LINK no_device LinkOptions_no_device --config Release)
diff --git a/Tests/RunCMake/target_link_options/genex_DEVICE_LINK-host_link_options-check.cmake b/Tests/RunCMake/target_link_options/genex_DEVICE_LINK-host_link_options-check.cmake
index 31ffe7f..cc3088a 100644
--- a/Tests/RunCMake/target_link_options/genex_DEVICE_LINK-host_link_options-check.cmake
+++ b/Tests/RunCMake/target_link_options/genex_DEVICE_LINK-host_link_options-check.cmake
@@ -1,4 +1,9 @@
+if(CMake_TEST_CUDA STREQUAL "NVIDIA")
+ set(expected "-Xlinker=OPT1 -Xlinker=OPT2 -Xlinker=OPT3 -Xlinker=OPT4 -Xlinker=OPT5")
+elseif(CMake_TEST_CUDA STREQUAL "Clang")
+ set(expected "-Wl,OPT1 -Xlinker OPT2 -Xlinker OPT3 -Xlinker OPT4")
+endif()
-if (NOT actual_stdout MATCHES "-Xlinker=OPT1 -Xlinker=OPT2 -Xlinker=OPT3 -Xlinker=OPT4 -Xlinker=OPT5")
- set (RunCMake_TEST_FAILED "Not found expected '-Xlinker=OPT1 -Xlinker=OPT2 -Xlinker=OPT3 -Xlinker=OPT4 -Xlinker=OPT5'.")
+if(NOT actual_stdout MATCHES "${expected}")
+ set(RunCMake_TEST_FAILED "Not found expected '${expected}'")
endif()
diff --git a/Tests/RunCMake/target_link_options/genex_DEVICE_LINK.cmake b/Tests/RunCMake/target_link_options/genex_DEVICE_LINK.cmake
index a53ab20..b6c9ee6 100644
--- a/Tests/RunCMake/target_link_options/genex_DEVICE_LINK.cmake
+++ b/Tests/RunCMake/target_link_options/genex_DEVICE_LINK.cmake
@@ -25,32 +25,33 @@ target_link_options (LinkOptions_private PRIVATE $<DEVICE_LINK:${pre}BADFLAG_DEV
if (CMake_TEST_CUDA)
enable_language(CUDA)
- # Separable compilation is only supported on NVCC.
- if(NOT CMake_TEST_CUDA STREQUAL "Clang")
- add_executable(LinkOptions_CMP0105_UNSET LinkOptionsDevice.cu)
- set_property(TARGET LinkOptions_CMP0105_UNSET PROPERTY CUDA_SEPARABLE_COMPILATION ON)
- target_link_options(LinkOptions_CMP0105_UNSET PRIVATE $<DEVICE_LINK:${pre}BADFLAG_DEVICE_LINK${obj}>)
+ add_executable(LinkOptions_CMP0105_UNSET LinkOptionsDevice.cu)
+ set_property(TARGET LinkOptions_CMP0105_UNSET PROPERTY CUDA_SEPARABLE_COMPILATION ON)
+ target_link_options(LinkOptions_CMP0105_UNSET PRIVATE $<DEVICE_LINK:${pre}BADFLAG_DEVICE_LINK${obj}>)
- cmake_policy(SET CMP0105 OLD)
+ cmake_policy(SET CMP0105 OLD)
- add_executable(LinkOptions_CMP0105_OLD LinkOptionsDevice.cu)
- set_property(TARGET LinkOptions_CMP0105_OLD PROPERTY CUDA_SEPARABLE_COMPILATION ON)
- target_link_options(LinkOptions_CMP0105_OLD PRIVATE $<DEVICE_LINK:${pre}BADFLAG_DEVICE_LINK${obj}>)
+ add_executable(LinkOptions_CMP0105_OLD LinkOptionsDevice.cu)
+ set_property(TARGET LinkOptions_CMP0105_OLD PROPERTY CUDA_SEPARABLE_COMPILATION ON)
+ target_link_options(LinkOptions_CMP0105_OLD PRIVATE $<DEVICE_LINK:${pre}BADFLAG_DEVICE_LINK${obj}>)
- cmake_policy(SET CMP0105 NEW)
+ cmake_policy(SET CMP0105 NEW)
- add_executable(LinkOptions_CMP0105_NEW LinkOptionsDevice.cu)
- set_property(TARGET LinkOptions_CMP0105_NEW PROPERTY CUDA_SEPARABLE_COMPILATION ON)
- target_link_options(LinkOptions_CMP0105_NEW PRIVATE $<DEVICE_LINK:${pre}BADFLAG_DEVICE_LINK${obj}>)
+ add_executable(LinkOptions_CMP0105_NEW LinkOptionsDevice.cu)
+ set_property(TARGET LinkOptions_CMP0105_NEW PROPERTY CUDA_SEPARABLE_COMPILATION ON)
+ target_link_options(LinkOptions_CMP0105_NEW PRIVATE $<DEVICE_LINK:${pre}BADFLAG_DEVICE_LINK${obj}>)
- add_executable(LinkOptions_device LinkOptionsDevice.cu)
- set_property(TARGET LinkOptions_device PROPERTY CUDA_SEPARABLE_COMPILATION ON)
- target_link_options(LinkOptions_device PRIVATE $<DEVICE_LINK:${pre}BADFLAG_DEVICE_LINK${obj}>
- $<HOST_LINK:${pre}BADFLAG_NORMAL_LINK${obj}>)
+ add_executable(LinkOptions_device LinkOptionsDevice.cu)
+ set_property(TARGET LinkOptions_device PROPERTY CUDA_SEPARABLE_COMPILATION ON)
+ target_link_options(LinkOptions_device PRIVATE $<DEVICE_LINK:${pre}BADFLAG_DEVICE_LINK${obj}>
+ $<HOST_LINK:${pre}BADFLAG_NORMAL_LINK${obj}>)
- add_executable(LinkOptions_host_link_options LinkOptionsDevice.cu)
- set_property(TARGET LinkOptions_host_link_options PROPERTY CUDA_SEPARABLE_COMPILATION ON)
+ add_executable(LinkOptions_host_link_options LinkOptionsDevice.cu)
+ set_property(TARGET LinkOptions_host_link_options PROPERTY CUDA_SEPARABLE_COMPILATION ON)
+ if(CMake_TEST_CUDA STREQUAL "NVIDIA")
target_link_options(LinkOptions_host_link_options PRIVATE -Wl,OPT1 -Xlinker=OPT2 "SHELL:-Xlinker OPT3" "SHELL:LINKER:OPT4 LINKER:OPT5")
+ elseif(CMake_TEST_CUDA STREQUAL "Clang")
+ target_link_options(LinkOptions_host_link_options PRIVATE -Wl,OPT1 "SHELL:-Xlinker OPT2" "SHELL:LINKER:OPT3 LINKER:OPT4")
endif()
add_executable(LinkOptions_no_device LinkOptionsDevice.cu)