From 5c66ac31e638dae7529e04064047722fca80ec01 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Mon, 14 Sep 2020 10:28:17 -0400 Subject: CUDA: CheckLinkerFlag now supports CUDA --- Help/release/dev/cuda-check-support.rst | 3 +++ Modules/CheckLinkerFlag.cmake | 2 ++ Tests/RunCMake/CMakeLists.txt | 4 +++- Tests/RunCMake/CheckLinkerFlag/CheckCUDALinkerFlag.cmake | 3 +++ Tests/RunCMake/CheckLinkerFlag/RunCMakeTest.cmake | 4 ++++ 5 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/CheckLinkerFlag/CheckCUDALinkerFlag.cmake diff --git a/Help/release/dev/cuda-check-support.rst b/Help/release/dev/cuda-check-support.rst index 50a42d6..d88ef94 100644 --- a/Help/release/dev/cuda-check-support.rst +++ b/Help/release/dev/cuda-check-support.rst @@ -9,3 +9,6 @@ cuda-check-support * The :module:`CheckSourceRuns` module was extended to support 'CUDA'. + +* The :module:`CheckLinkerFlag` module has been extended to + support the validity of CUDA link flags. diff --git a/Modules/CheckLinkerFlag.cmake b/Modules/CheckLinkerFlag.cmake index 051e0bc..f56d365 100644 --- a/Modules/CheckLinkerFlag.cmake +++ b/Modules/CheckLinkerFlag.cmake @@ -66,6 +66,8 @@ function(CHECK_LINKER_FLAG _lang _flag _var) set (_source "int main() { return 0; }") elseif (_lang STREQUAL "Fortran") set (_source " program test\n stop\n end program") + elseif (_lang MATCHES "CUDA") + set (_source "__host__ int main() { return 0; }") elseif (_lang MATCHES "^(OBJC|OBJCXX)$") set (_source "#ifndef __OBJC__\n# error \"Not an Objective-C++ compiler\"\n#endif\nint main(void) { return 0; }") else() diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 68bd0d9..63738d7 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -555,7 +555,9 @@ add_RunCMake_test(CheckIPOSupported) if (CMAKE_SYSTEM_NAME MATCHES "(Linux|Darwin)" AND (CMAKE_C_COMPILER_ID MATCHES "Clang|GNU" OR CMAKE_Fortran_COMPILER_ID MATCHES "GNU")) add_RunCMake_test(CheckLinkerFlag -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} - -DCMAKE_Fortran_COMPILER_ID=${CMAKE_Fortran_COMPILER_ID}) + -DCMAKE_Fortran_COMPILER_ID=${CMAKE_Fortran_COMPILER_ID} + -DCMake_TEST_CUDA=${CMake_TEST_CUDA}) + set_property(TEST RunCMake.CheckLinkerFlag APPEND PROPERTY LABELS "CUDA") endif() diff --git a/Tests/RunCMake/CheckLinkerFlag/CheckCUDALinkerFlag.cmake b/Tests/RunCMake/CheckLinkerFlag/CheckCUDALinkerFlag.cmake new file mode 100644 index 0000000..84d6dd9 --- /dev/null +++ b/Tests/RunCMake/CheckLinkerFlag/CheckCUDALinkerFlag.cmake @@ -0,0 +1,3 @@ + +set (CHECK_LANGUAGE CUDA) +include ("${CMAKE_CURRENT_SOURCE_DIR}/CheckLinkerFlag.cmake") diff --git a/Tests/RunCMake/CheckLinkerFlag/RunCMakeTest.cmake b/Tests/RunCMake/CheckLinkerFlag/RunCMakeTest.cmake index 224a2a3..6ec9148 100644 --- a/Tests/RunCMake/CheckLinkerFlag/RunCMakeTest.cmake +++ b/Tests/RunCMake/CheckLinkerFlag/RunCMakeTest.cmake @@ -12,3 +12,7 @@ endif() if (CMAKE_Fortran_COMPILER_ID MATCHES "GNU") run_cmake(CheckFortranLinkerFlag) endif() + +if (CMake_TEST_CUDA) + run_cmake(CheckCUDALinkerFlag) +endif() -- cgit v0.12