Prevent multiple "-ccbin g++" in nvcc command.

If ENV{CUDAHOSTCXX} is set then this will cause CMake to add
"-ccnin ${ENV{CUDAHOSTCXX}}" to variable CMAKE_CUDA_FLAGS
even if there already is one.
This commit is contained in:
Markus Blatt 2020-04-27 21:52:41 +02:00
parent ddb0940336
commit 4e0cd2a77e

View File

@ -99,10 +99,14 @@ if(NOT CMAKE_DISABLE_FIND_PACKAGE_CUDA AND
"prevent incompatibilities. Note that this might report that there "
"is not CUDA compiler if your system's CUDA compiler does not support "
"${CMAKE_CXX_COMPILER}.")
set(CMAKE_CUDA_FLAGS "-ccbin ${CMAKE_CXX_COMPILER} ${CMAKE_CUDA_FLAGS}")
# check_language does not seem to care about ${CMAKE_CUDA_FLAGS}, we
# need to set the environment variable CUDAHOSTCXX such that cuda
# picks up the correct compiler.
# set(CMAKE_CUDA_FLAGS "-ccbin ${CMAKE_CXX_COMPILER} ${CMAKE_CUDA_FLAGS}")
# check_language does not seem to care about ${CMAKE_CUDA_FLAGS}.
# Hence set(CMAKE_CUDA_FLAGS "-ccbin ${CMAKE_CXX_COMPILER} ${CMAKE_CUDA_FLAGS}")
# would have no effect. We need to set the environment variable ENV{CUDAHOSTCXX} such
# that cuda picks up the correct compiler during check_language.
# In check_language(CUDA) we will get and error if we set and put
# "-ccbin ${CMAKE_CXX_COMPILER}" into the CMAKE_CUDA_FLAGS as this results
# in "${NVCC} -ccbin=${CMAKE_CXX_COMPILER} -ccbin ${CMAKE_CXX_COMPILER}"
set(ENV{CUDAHOSTCXX} ${CMAKE_CXX_COMPILER})
endif()
include(CheckLanguage)