Browse Source

FindCUDA: Add specific cuda_language_flag instead of using nvcc.

I was previously appending to nvcc_flags inside the file loop.  This
caused the flag to be appended multiple times which freaks out nvcc.
Now the flag is specifically handled per file.
James Bigler 10 years ago
parent
commit
1b0c77a33d
2 changed files with 5 additions and 1 deletions
  1. 3 1
      Modules/FindCUDA.cmake
  2. 2 0
      Modules/FindCUDA/run_nvcc.cmake

+ 3 - 1
Modules/FindCUDA.cmake

@@ -1310,7 +1310,9 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files)
       endif()
       # If file isn't a .cu file, we need to tell nvcc to treat it as such.
       if(NOT ${file} MATCHES "\\.cu$")
-        list(APPEND nvcc_flags "-x=cu")
+        set(cuda_language_flag -x=cu)
+      else()
+        set(cuda_language_flag)
       endif()
 
       if( ${_cuda_source_format} MATCHES "OBJ")

+ 2 - 0
Modules/FindCUDA/run_nvcc.cmake

@@ -75,6 +75,7 @@ set(CUDA_NVCC_FLAGS @CUDA_NVCC_FLAGS@ ;; @CUDA_WRAP_OPTION_NVCC_FLAGS@) # list
 set(nvcc_flags @nvcc_flags@) # list
 set(CUDA_NVCC_INCLUDE_ARGS "@CUDA_NVCC_INCLUDE_ARGS@") # list (needs to be in quotes to handle spaces properly).
 set(format_flag "@format_flag@") # string
+set(cuda_language_flag @cuda_language_flag@) # list
 
 if(build_cubin AND NOT generated_cubin_file)
   message(FATAL_ERROR "You must specify generated_cubin_file on the command line")
@@ -238,6 +239,7 @@ cuda_execute_process(
   "Generating ${generated_file}"
   COMMAND "${CUDA_NVCC_EXECUTABLE}"
   "${source_file}"
+  ${cuda_language_flag}
   ${format_flag} -o "${generated_file}"
   ${CCBIN}
   ${nvcc_flags}