diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2020-05-18 19:29:18 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-05-21 15:15:03 (GMT) |
commit | e55b21e24ee81f5433b8ec778aa341c485d6e149 (patch) | |
tree | d10f18e2def364aa034b8b59238b535c635673fc /Tests/CudaOnly/SharedRuntimeViaCUDAFlags | |
parent | 1086e930dc8ad94847f17f627673db8f7a3fb3ab (diff) | |
download | CMake-e55b21e24ee81f5433b8ec778aa341c485d6e149.zip CMake-e55b21e24ee81f5433b8ec778aa341c485d6e149.tar.gz CMake-e55b21e24ee81f5433b8ec778aa341c485d6e149.tar.bz2 |
CUDA: Compute CMAKE_CUDA_RUNTIME_LIBRARY default from toolchain
Since commit 0d0145138f (CUDA: Add abstraction for cuda runtime
selection, 2019-11-29, v3.17.0-rc1~83^2) we add CUDA runtime library
selection flags by default.
To maintain backwards compatibility the default CUDA runtime
library needs to be computed based on what libraries are found
on the initial compiler invocation. For example a toolchain
could establish initial flags that have all CUDA compilations
using the runtime version, and if we don't detect this we will
try to link to both the static and shared runtime.
Co-Author: Brad King <brad.king@kitware.com>
Fixes: #20708
Diffstat (limited to 'Tests/CudaOnly/SharedRuntimeViaCUDAFlags')
-rw-r--r-- | Tests/CudaOnly/SharedRuntimeViaCUDAFlags/CMakeLists.txt | 15 | ||||
-rw-r--r-- | Tests/CudaOnly/SharedRuntimeViaCUDAFlags/main.cu | 5 |
2 files changed, 20 insertions, 0 deletions
diff --git a/Tests/CudaOnly/SharedRuntimeViaCUDAFlags/CMakeLists.txt b/Tests/CudaOnly/SharedRuntimeViaCUDAFlags/CMakeLists.txt new file mode 100644 index 0000000..24ff478 --- /dev/null +++ b/Tests/CudaOnly/SharedRuntimeViaCUDAFlags/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.17) +project(SharedRuntimeViaCUDAFlags NONE) + +set(CMAKE_CUDA_FLAGS "") +string(APPEND CMAKE_CUDA_FLAGS "-cudart shared") + +enable_language(CUDA) + +add_executable(CudaOnlySharedRuntimeViaCUDAFlags main.cu) + +if(UNIX) + # Help the shared cuda runtime find libcudart as it is not located + # in a default system searched location + set_property(TARGET CudaOnlySharedRuntimeViaCUDAFlags PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) +endif() diff --git a/Tests/CudaOnly/SharedRuntimeViaCUDAFlags/main.cu b/Tests/CudaOnly/SharedRuntimeViaCUDAFlags/main.cu new file mode 100644 index 0000000..766b775 --- /dev/null +++ b/Tests/CudaOnly/SharedRuntimeViaCUDAFlags/main.cu @@ -0,0 +1,5 @@ + +int main() +{ + return 0; +} |