diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2019-11-29 16:16:21 (GMT) |
---|---|---|
committer | Robert Maynard <robert.maynard@kitware.com> | 2019-11-29 19:21:35 (GMT) |
commit | 7f15c998519d83d49b16887c4e035336378d854b (patch) | |
tree | 8ca6f986c42c892e7485dbd7ad9e5b770eedfc4a /Modules/Compiler | |
parent | ca2a3929c2c7d479b12bab96d1910eff87380861 (diff) | |
download | CMake-7f15c998519d83d49b16887c4e035336378d854b.zip CMake-7f15c998519d83d49b16887c4e035336378d854b.tar.gz CMake-7f15c998519d83d49b16887c4e035336378d854b.tar.bz2 |
CUDA: forward unknown flags to host compiler when possible.
Starting with CUDA 10.2 the nvcc compiler has gained support
to automatically forward unknown flags to the host compiler.
This behavior is highly desired as projcts that mix CUDA, C, C++
run into situation where flags such as `-pthread` which aren't
supported by nvcc, are being applied to all source files and
therefore break CUDA compilation.
Diffstat (limited to 'Modules/Compiler')
-rw-r--r-- | Modules/Compiler/NVIDIA-CUDA.cmake | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Modules/Compiler/NVIDIA-CUDA.cmake b/Modules/Compiler/NVIDIA-CUDA.cmake index b59deda..2400a9d 100644 --- a/Modules/Compiler/NVIDIA-CUDA.cmake +++ b/Modules/Compiler/NVIDIA-CUDA.cmake @@ -2,6 +2,22 @@ set(CMAKE_CUDA_COMPILER_HAS_DEVICE_LINK_PHASE True) set(CMAKE_CUDA_VERBOSE_FLAG "-v") set(CMAKE_CUDA_VERBOSE_COMPILE_FLAG "-Xcompiler=-v") +if (NOT CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 10.2) + # The -forward-unknown-to-host-compiler flag was only + # added to nvcc in 10.2 so before that we had no good + # way to invoke the CUDA compiler and propagate unknown + # flags such as -pthread to the host compiler + set(_CMAKE_CUDA_EXTRA_FLAGS "-forward-unknown-to-host-compiler") +else() + set(_CMAKE_CUDA_EXTRA_FLAGS "") +endif() + +if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0") + set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "-Wno-deprecated-gpu-targets") +else() + set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "") +endif() + if(NOT "x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC") set(CMAKE_CUDA_COMPILE_OPTIONS_PIE -Xcompiler=-fPIE) set(CMAKE_CUDA_COMPILE_OPTIONS_PIC -Xcompiler=-fPIC) |