mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 21:59:54 -06:00
CUDA: Add include paths from nvcc SYSTEM_INCLUDES entry
Upcoming versions of nvcc are adding support for `SYSTEM_INCLUDES` which contain includes that are implicitly used with `-isystem` instead of `-I`. Support of this is needed in CMake as some CUDA Toolkit releases will start to have a different include directory layout and using only the output from `INCLUDES` will be insufficient to find all headers.
This commit is contained in:
committed by
Brad King
parent
160b518252
commit
d2be863b5e
@@ -694,9 +694,21 @@ else()
|
||||
get_filename_component(line "${line}" ABSOLUTE)
|
||||
list(APPEND _cmake_CUDAToolkit_include_directories "${line}")
|
||||
endforeach()
|
||||
endif()
|
||||
if(_CUDA_NVCC_OUT MATCHES "\\#\\$ SYSTEM_INCLUDES=([^\r\n]*)")
|
||||
unset(_nvcc_output)
|
||||
separate_arguments(_nvcc_output NATIVE_COMMAND "${CMAKE_MATCH_1}")
|
||||
foreach(line IN LISTS _nvcc_output)
|
||||
string(REGEX REPLACE "^-isystem" "" line "${line}")
|
||||
if(line)
|
||||
get_filename_component(line "${line}" ABSOLUTE)
|
||||
list(APPEND _cmake_CUDAToolkit_include_directories "${line}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
if(DEFINED _cmake_CUDAToolkit_include_directories)
|
||||
message(CONFIGURE_LOG
|
||||
"Parsed CUDAToolkit nvcc implicit include information:\n${_cmake_CUDAToolkit_include_directories}\n\n")
|
||||
|
||||
set(_cmake_CUDAToolkit_include_directories "${_cmake_CUDAToolkit_include_directories}" CACHE INTERNAL "CUDAToolkit internal list of include directories")
|
||||
endif()
|
||||
if(_CUDA_NVCC_OUT MATCHES "\\#\\$ LIBRARIES=([^\r\n]*)")
|
||||
|
||||
@@ -29,6 +29,14 @@ macro(cmake_nvcc_parse_implicit_info lang lang_var_)
|
||||
string(REPLACE "\n" "\n " _nvcc_output_log "\n${_nvcc_output_orig}")
|
||||
string(APPEND _nvcc_log " no 'INCLUDES=' string found in nvcc output:${_nvcc_output_log}\n")
|
||||
endif()
|
||||
if(_nvcc_output_orig MATCHES "#\\\$ +SYSTEM_INCLUDES= *([^\n]*)\n")
|
||||
set(_nvcc_system_includes "${CMAKE_MATCH_1}")
|
||||
string(APPEND _nvcc_log " found 'SYSTEM_INCLUDES=' string: [${_nvcc_system_includes}]\n")
|
||||
else()
|
||||
set(_nvcc_system_includes "")
|
||||
string(REPLACE "\n" "\n " _nvcc_output_log "\n${_nvcc_output_orig}")
|
||||
string(APPEND _nvcc_log " no 'SYSTEM_INCLUDES=' string found in nvcc output:${_nvcc_output_log}\n")
|
||||
endif()
|
||||
string(REGEX MATCHALL "-arch compute_([0-9]+)" _nvcc_target_cpus "${_nvcc_output_orig}")
|
||||
foreach(_nvcc_target_cpu ${_nvcc_target_cpus})
|
||||
if(_nvcc_target_cpu MATCHES "-arch compute_([0-9]+)")
|
||||
@@ -134,7 +142,7 @@ macro(cmake_nvcc_parse_implicit_info lang lang_var_)
|
||||
endif()
|
||||
|
||||
set(${lang_var_}TOOLKIT_INCLUDE_DIRECTORIES)
|
||||
if(_nvcc_includes)
|
||||
if(_nvcc_includes OR _nvcc_system_includes)
|
||||
# across all operating system each include directory is prefixed with -I
|
||||
separate_arguments(_nvcc_output NATIVE_COMMAND "${_nvcc_includes}")
|
||||
foreach(line IN LISTS _nvcc_output)
|
||||
@@ -143,6 +151,17 @@ macro(cmake_nvcc_parse_implicit_info lang lang_var_)
|
||||
list(APPEND ${lang_var_}TOOLKIT_INCLUDE_DIRECTORIES "${line}")
|
||||
endforeach()
|
||||
|
||||
# across all operating system each system include directory is prefixed with -isystem
|
||||
unset(_nvcc_output)
|
||||
separate_arguments(_nvcc_output NATIVE_COMMAND "${_nvcc_system_includes}")
|
||||
foreach(line IN LISTS _nvcc_output)
|
||||
string(REGEX REPLACE "^-isystem" "" line "${line}")
|
||||
if(line)
|
||||
get_filename_component(line "${line}" ABSOLUTE)
|
||||
list(APPEND ${lang_var_}TOOLKIT_INCLUDE_DIRECTORIES "${line}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
message(CONFIGURE_LOG
|
||||
"Parsed CUDA nvcc include information:\n${_nvcc_log}\n${log}\n\n")
|
||||
else()
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
// Only thing we care about is that these headers are found
|
||||
#include <cuda.h>
|
||||
#include <cuda_runtime_api.h>
|
||||
#if CUDA_VERSION >= 11040
|
||||
# include <nv/target>
|
||||
#endif
|
||||
#include <thrust/version.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
// Only thing we care about is that these headers are found
|
||||
#include <cuda.h>
|
||||
#include <cuda_runtime_api.h>
|
||||
#if CUDA_VERSION >= 11040
|
||||
# include <nv/target>
|
||||
#endif
|
||||
#include <thrust/version.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
// Only thing we care about is that these headers are found
|
||||
#include <cuda.h>
|
||||
#include <cuda_runtime_api.h>
|
||||
#if CUDA_VERSION >= 11040
|
||||
# include <nv/target>
|
||||
#endif
|
||||
#include <thrust/version.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
// Only thing we care about is that these headers are found
|
||||
#include <cuda.h>
|
||||
#include <cuda_runtime_api.h>
|
||||
#if CUDA_VERSION >= 11040
|
||||
# include <nv/target>
|
||||
#endif
|
||||
#include <thrust/version.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
// Only thing we care about is that these headers are found
|
||||
#include <cuda.h>
|
||||
#include <cuda_runtime_api.h>
|
||||
#if CUDA_VERSION >= 11040
|
||||
# include <nv/target>
|
||||
#endif
|
||||
#include <thrust/version.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
// Only thing we care about is that these headers are found
|
||||
#include <cuda.h>
|
||||
#include <cuda_runtime_api.h>
|
||||
#if CUDA_VERSION >= 11040
|
||||
# include <nv/target>
|
||||
#endif
|
||||
#include <thrust/version.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user