summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2020-04-06 09:22:37 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2020-04-19 13:53:11 (GMT)
commit4248bb452a5886ec4b632e2d602fcaafd2b13aaf (patch)
treeb7e126570036c7a7ec0ac61ca7ef99f67edd6d18 /Tests
parentec48e023f6261371aa5d0e46ebf9c163e40c9b40 (diff)
downloadCMake-4248bb452a5886ec4b632e2d602fcaafd2b13aaf.zip
CMake-4248bb452a5886ec4b632e2d602fcaafd2b13aaf.tar.gz
CMake-4248bb452a5886ec4b632e2d602fcaafd2b13aaf.tar.bz2
CUDA: Device linking use now link options
properties LINK_OPTIONS and INTERFACE_LINK_OPTIONS are propagated to the device link step. To control which options are selected for normal link and device link steps, the $<DEVICE_LINK> and $<HOST_LINK> generator expressions can be used. Fixes: #18265
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt1
-rw-r--r--Tests/RunCMake/export/Repeat-CMP0103-WARN-stderr.txt4
-rw-r--r--Tests/RunCMake/target_link_options/LinkOptionsDevice.cu14
-rw-r--r--Tests/RunCMake/target_link_options/RunCMakeTest.cmake10
-rw-r--r--Tests/RunCMake/target_link_options/genex_DEVICE_LINK-CMP0105_NEW-check.cmake4
-rw-r--r--Tests/RunCMake/target_link_options/genex_DEVICE_LINK-CMP0105_NEW-result.txt1
-rw-r--r--Tests/RunCMake/target_link_options/genex_DEVICE_LINK-device-check.cmake3
-rw-r--r--Tests/RunCMake/target_link_options/genex_DEVICE_LINK-device-result.txt1
-rw-r--r--Tests/RunCMake/target_link_options/genex_DEVICE_LINK-no_device-check.cmake3
-rw-r--r--Tests/RunCMake/target_link_options/genex_DEVICE_LINK-no_device-result.txt1
-rw-r--r--Tests/RunCMake/target_link_options/genex_DEVICE_LINK.cmake29
12 files changed, 70 insertions, 4 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 34e1fbc..f5472d9 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -471,7 +471,8 @@ add_RunCMake_test(ExportWithoutLanguage)
add_RunCMake_test(target_link_directories)
add_RunCMake_test(target_link_libraries)
add_RunCMake_test(add_link_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID})
-add_RunCMake_test(target_link_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID})
+add_RunCMake_test(target_link_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}
+ -DCMake_TEST_CUDA=${CMake_TEST_CUDA})
add_RunCMake_test(target_compile_definitions)
add_RunCMake_test(target_compile_features)
diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
index 7ffd522..2d270c5 100644
--- a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
+++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
@@ -30,6 +30,7 @@
\* CMP0095
\* CMP0099
\* CMP0104
+ \* CMP0105
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/export/Repeat-CMP0103-WARN-stderr.txt b/Tests/RunCMake/export/Repeat-CMP0103-WARN-stderr.txt
index 3104df4..28e849d 100644
--- a/Tests/RunCMake/export/Repeat-CMP0103-WARN-stderr.txt
+++ b/Tests/RunCMake/export/Repeat-CMP0103-WARN-stderr.txt
@@ -1,5 +1,5 @@
CMake Warning \(dev\) at Repeat.cmake:[0-9]+ \(export\):
- Policy CMP0103 is not set: multiple export\(\) with same FILE without APPEND
+ Policy CMP0103 is not set: Multiple export\(\) with same FILE without APPEND
is not allowed. Run "cmake --help-policy CMP0103" for policy details. Use
the cmake_policy command to set the policy and suppress this warning.
@@ -14,7 +14,7 @@ Call Stack \(most recent call first\):
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning \(dev\) at Repeat/CMakeLists.txt:[0-9]+ \(export\):
- Policy CMP0103 is not set: multiple export\(\) with same FILE without APPEND
+ Policy CMP0103 is not set: Multiple export\(\) with same FILE without APPEND
is not allowed. Run "cmake --help-policy CMP0103" for policy details. Use
the cmake_policy command to set the policy and suppress this warning.
diff --git a/Tests/RunCMake/target_link_options/LinkOptionsDevice.cu b/Tests/RunCMake/target_link_options/LinkOptionsDevice.cu
new file mode 100644
index 0000000..96504e1
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/LinkOptionsDevice.cu
@@ -0,0 +1,14 @@
+#include <cuda.h>
+
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ int simplelib()
+{
+ return 0;
+}
+
+int main(void)
+{
+ return simplelib();
+}
diff --git a/Tests/RunCMake/target_link_options/RunCMakeTest.cmake b/Tests/RunCMake/target_link_options/RunCMakeTest.cmake
index af3e4c0..b919f48 100644
--- a/Tests/RunCMake/target_link_options/RunCMakeTest.cmake
+++ b/Tests/RunCMake/target_link_options/RunCMakeTest.cmake
@@ -13,8 +13,9 @@ endmacro()
if (NOT CMAKE_C_COMPILER_ID STREQUAL "Intel")
# Intel compiler does not reject bad flags or objects!
set(RunCMake_TEST_OUTPUT_MERGE TRUE)
+ set(RunCMake_TEST_OPTIONS -DCMake_TEST_CUDA=${CMake_TEST_CUDA})
if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
- set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release)
+ list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release)
endif()
run_cmake(LINK_OPTIONS)
@@ -48,6 +49,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)
+ 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)
+ run_cmake_target(genex_DEVICE_LINK no_device LinkOptions_no_device --config Release)
+ endif()
unset(RunCMake_TEST_OPTIONS)
unset(RunCMake_TEST_OUTPUT_MERGE)
diff --git a/Tests/RunCMake/target_link_options/genex_DEVICE_LINK-CMP0105_NEW-check.cmake b/Tests/RunCMake/target_link_options/genex_DEVICE_LINK-CMP0105_NEW-check.cmake
new file mode 100644
index 0000000..20c4fab
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/genex_DEVICE_LINK-CMP0105_NEW-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "BADFLAG_DEVICE_LINK")
+ set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG_DEVICE_LINK'.")
+endif()
diff --git a/Tests/RunCMake/target_link_options/genex_DEVICE_LINK-CMP0105_NEW-result.txt b/Tests/RunCMake/target_link_options/genex_DEVICE_LINK-CMP0105_NEW-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/genex_DEVICE_LINK-CMP0105_NEW-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_options/genex_DEVICE_LINK-device-check.cmake b/Tests/RunCMake/target_link_options/genex_DEVICE_LINK-device-check.cmake
new file mode 100644
index 0000000..23c3b46
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/genex_DEVICE_LINK-device-check.cmake
@@ -0,0 +1,3 @@
+set (DEVICE_LINK TRUE)
+
+include ("${CMAKE_CURRENT_LIST_DIR}/genex_DEVICE_LINK-validation.cmake")
diff --git a/Tests/RunCMake/target_link_options/genex_DEVICE_LINK-device-result.txt b/Tests/RunCMake/target_link_options/genex_DEVICE_LINK-device-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/genex_DEVICE_LINK-device-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_options/genex_DEVICE_LINK-no_device-check.cmake b/Tests/RunCMake/target_link_options/genex_DEVICE_LINK-no_device-check.cmake
new file mode 100644
index 0000000..8431e22
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/genex_DEVICE_LINK-no_device-check.cmake
@@ -0,0 +1,3 @@
+set (DEVICE_LINK FALSE)
+
+include ("${CMAKE_CURRENT_LIST_DIR}/genex_DEVICE_LINK-validation.cmake")
diff --git a/Tests/RunCMake/target_link_options/genex_DEVICE_LINK-no_device-result.txt b/Tests/RunCMake/target_link_options/genex_DEVICE_LINK-no_device-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/genex_DEVICE_LINK-no_device-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_options/genex_DEVICE_LINK.cmake b/Tests/RunCMake/target_link_options/genex_DEVICE_LINK.cmake
index b3648e9..4d0c02f 100644
--- a/Tests/RunCMake/target_link_options/genex_DEVICE_LINK.cmake
+++ b/Tests/RunCMake/target_link_options/genex_DEVICE_LINK.cmake
@@ -17,3 +17,32 @@ target_link_libraries (LinkOptions_shared_interface PRIVATE LinkOptions_interfac
add_library(LinkOptions_private SHARED LinkOptionsLib.c)
target_link_options (LinkOptions_private PRIVATE $<DEVICE_LINK:${pre}BADFLAG_DEVICE_LINK${obj}>
$<HOST_LINK:${pre}BADFLAG_NORMAL_LINK${obj}>)
+
+if (CMake_TEST_CUDA)
+ enable_language(CUDA)
+
+ 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)
+
+ 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)
+
+ 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_no_device LinkOptionsDevice.cu)
+ target_link_options(LinkOptions_no_device PRIVATE $<DEVICE_LINK:${pre}BADFLAG_DEVICE_LINK${obj}>
+ $<HOST_LINK:${pre}BADFLAG_NORMAL_LINK${obj}>)
+endif()