diff options
author | Adam Strzelecki <ono@java.pl> | 2014-06-12 17:46:50 (GMT) |
---|---|---|
committer | Robert Maynard <robert.maynard@kitware.com> | 2014-06-30 15:23:36 (GMT) |
commit | 32bcec5fab8a92590bfc2efafe29f2403bbab4dd (patch) | |
tree | 5fe48a79838c8f00fbd64816ed2d0539b1011b39 /Modules/FindCUDA.cmake | |
parent | bf5fc1d5829e7995c0941996b4a515cbd46d4e4e (diff) | |
download | CMake-32bcec5fab8a92590bfc2efafe29f2403bbab4dd.zip CMake-32bcec5fab8a92590bfc2efafe29f2403bbab4dd.tar.gz CMake-32bcec5fab8a92590bfc2efafe29f2403bbab4dd.tar.bz2 |
FindCUDA: Fix OSX Clang & no C language enabled
When setting default CUDA_HOST_COMPILER we must dereference CMAKE_C_COMPILER,
i.e. /usr/bin/clang should be used instead /usr/bin/cc which is symlink.
Otherwise CUDA thinks it is GCC and issues -dumpspecs which is unknown option
to Clang.
Also in case neither CMAKE_C_COMPILER is defined (project does not use C
language) nor CUDA_HOST_COMPILER is specified manually we should skip -ccbin
and let nvcc use its own default C compiler.
Diffstat (limited to 'Modules/FindCUDA.cmake')
-rw-r--r-- | Modules/FindCUDA.cmake | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index d9809ad..9348aa5 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -452,7 +452,17 @@ set(CUDA_NVCC_FLAGS "" CACHE STRING "Semi-colon delimit multiple arguments.") if(CMAKE_GENERATOR MATCHES "Visual Studio") set(CUDA_HOST_COMPILER "$(VCInstallDir)bin" CACHE FILEPATH "Host side compiler used by NVCC") else() - set(CUDA_HOST_COMPILER "${CMAKE_C_COMPILER}" CACHE FILEPATH "Host side compiler used by NVCC") + # Using cc which is symlink to clang may let NVCC think it is GCC and issue + # unhandled -dumpspecs option to clang. Also in case neither + # CMAKE_C_COMPILER is defined (project does not use C language) nor + # CUDA_HOST_COMPILER is specified manually we should skip -ccbin and let + # nvcc use its own default C compiler. + if(DEFINED CMAKE_C_COMPILER AND NOT DEFINED CUDA_HOST_COMPILER) + get_filename_component(c_compiler_realpath "${CMAKE_C_COMPILER}" REALPATH) + else() + set(c_compiler_realpath "") + endif() + set(CUDA_HOST_COMPILER "${c_compiler_realpath}" CACHE FILEPATH "Host side compiler used by NVCC") endif() # Propagate the host flags to the host compiler via -Xcompiler @@ -1422,7 +1432,7 @@ function(CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS output_file cuda_target options # If -ccbin, --compiler-bindir has been specified, don't do anything. Otherwise add it here. list( FIND nvcc_flags "-ccbin" ccbin_found0 ) list( FIND nvcc_flags "--compiler-bindir" ccbin_found1 ) - if( ccbin_found0 LESS 0 AND ccbin_found1 LESS 0 ) + if( ccbin_found0 LESS 0 AND ccbin_found1 LESS 0 AND CUDA_HOST_COMPILER ) list(APPEND nvcc_flags -ccbin "\"${CUDA_HOST_COMPILER}\"") endif() # Create a list of flags specified by CUDA_NVCC_FLAGS_${CONFIG} |