mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-23 14:48:19 -05:00
FindCUDA: Take NVCC include directories from target properties
Fixes issue where include directories specified on the target are not passed on to NVCC. This includes both target_include_directories() as well as include directories added by dependency chaining. Closes: #14201
This commit is contained in:
committed by
Brad King
parent
e240a7c017
commit
7ded655f7b
@@ -73,10 +73,25 @@ set(CUDA_NVCC_EXECUTABLE "@CUDA_NVCC_EXECUTABLE@") # path
|
||||
set(CUDA_NVCC_FLAGS @CUDA_NVCC_FLAGS@ ;; @CUDA_WRAP_OPTION_NVCC_FLAGS@) # list
|
||||
@CUDA_NVCC_FLAGS_CONFIG@
|
||||
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(CUDA_NVCC_INCLUDE_DIRS "@CUDA_NVCC_INCLUDE_DIRS@") # list (needs to be in quotes to handle spaces properly).
|
||||
set(CUDA_NVCC_COMPILE_DEFINITIONS "@CUDA_NVCC_COMPILE_DEFINITIONS@") # list (needs to be in quotes to handle spaces properly).
|
||||
set(format_flag "@format_flag@") # string
|
||||
set(cuda_language_flag @cuda_language_flag@) # list
|
||||
|
||||
# Clean up list of include directories and add -I flags
|
||||
list(REMOVE_DUPLICATES CUDA_NVCC_INCLUDE_DIRS)
|
||||
set(CUDA_NVCC_INCLUDE_ARGS)
|
||||
foreach(dir ${CUDA_NVCC_INCLUDE_DIRS})
|
||||
# Extra quotes are added around each flag to help nvcc parse out flags with spaces.
|
||||
list(APPEND CUDA_NVCC_INCLUDE_ARGS "-I${dir}")
|
||||
endforeach()
|
||||
|
||||
# Clean up list of compile definitions, add -D flags, and append to nvcc_flags
|
||||
list(REMOVE_DUPLICATES CUDA_NVCC_COMPILE_DEFINITIONS)
|
||||
foreach(def ${CUDA_NVCC_COMPILE_DEFINITIONS})
|
||||
list(APPEND nvcc_flags "-D${def}")
|
||||
endforeach()
|
||||
|
||||
if(build_cubin AND NOT generated_cubin_file)
|
||||
message(FATAL_ERROR "You must specify generated_cubin_file on the command line")
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user