mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
Merge branch 'cmake_provide_include_dir_for_toolkit' into release
This commit is contained in:
@@ -16,6 +16,8 @@ set(CMAKE_CUDA_SOURCE_FILE_EXTENSIONS cu)
|
||||
set(CMAKE_CUDA_LINKER_PREFERENCE 15)
|
||||
set(CMAKE_CUDA_LINKER_PREFERENCE_PROPAGATES 1)
|
||||
|
||||
set(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES "@CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES@")
|
||||
|
||||
set(CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES "@CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES@")
|
||||
set(CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES "@CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES@")
|
||||
set(CMAKE_CUDA_HOST_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_CUDA_HOST_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@")
|
||||
|
||||
@@ -84,20 +84,20 @@ endif()
|
||||
#the compiler with cuda-fake-ld and pass too CMAKE_PARSE_IMPLICIT_LINK_INFO
|
||||
if(CMAKE_CUDA_COMPILER_ID STREQUAL NVIDIA)
|
||||
set(_nvcc_log "")
|
||||
string(REPLACE "\r" "" _nvcc_output "${CMAKE_CUDA_COMPILER_PRODUCED_OUTPUT}")
|
||||
if(_nvcc_output MATCHES "#\\\$ +LIBRARIES= *([^\n]*)\n")
|
||||
string(REPLACE "\r" "" _nvcc_output_orig "${CMAKE_CUDA_COMPILER_PRODUCED_OUTPUT}")
|
||||
if(_nvcc_output_orig MATCHES "#\\\$ +LIBRARIES= *([^\n]*)\n")
|
||||
set(_nvcc_libraries "${CMAKE_MATCH_1}")
|
||||
string(APPEND _nvcc_log " found 'LIBRARIES=' string: [${_nvcc_libraries}]\n")
|
||||
else()
|
||||
set(_nvcc_libraries "")
|
||||
string(REPLACE "\n" "\n " _nvcc_output_log "\n${_nvcc_output}")
|
||||
string(REPLACE "\n" "\n " _nvcc_output_log "\n${_nvcc_output_orig}")
|
||||
string(APPEND _nvcc_log " no 'LIBRARIES=' string found in nvcc output:${_nvcc_output_log}\n")
|
||||
endif()
|
||||
|
||||
set(_nvcc_link_line "")
|
||||
if(_nvcc_libraries)
|
||||
# Remove variable assignments.
|
||||
string(REGEX REPLACE "#\\\$ *[^= ]+=[^\n]*\n" "" _nvcc_output "${_nvcc_output}")
|
||||
string(REGEX REPLACE "#\\\$ *[^= ]+=[^\n]*\n" "" _nvcc_output "${_nvcc_output_orig}")
|
||||
# Split lines.
|
||||
string(REGEX REPLACE "\n+(#\\\$ )?" ";" _nvcc_output "${_nvcc_output}")
|
||||
foreach(line IN LISTS _nvcc_output)
|
||||
@@ -150,6 +150,32 @@ if(CMAKE_CUDA_COMPILER_ID STREQUAL NVIDIA)
|
||||
message(FATAL_ERROR "Failed to extract nvcc implicit link line.")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES )
|
||||
if(_nvcc_output_orig MATCHES "#\\\$ +INCLUDES= *([^\n]*)\n")
|
||||
set(_nvcc_includes "${CMAKE_MATCH_1}")
|
||||
string(APPEND _nvcc_log " found 'INCLUDES=' string: [${_nvcc_includes}]\n")
|
||||
else()
|
||||
set(_nvcc_includes "")
|
||||
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_includes)
|
||||
# across all operating system each include directory is prefixed with -I
|
||||
separate_arguments(_nvcc_output UNIX_COMMAND "${_nvcc_includes}")
|
||||
foreach(line IN LISTS _nvcc_output)
|
||||
string(REGEX REPLACE "^-I" "" line "${line}")
|
||||
get_filename_component(line "${line}" ABSOLUTE)
|
||||
list(APPEND CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES "${line}")
|
||||
endforeach()
|
||||
|
||||
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||
"Parsed CUDA nvcc include information from above output:\n${_nvcc_log}\n${log}\n\n")
|
||||
else()
|
||||
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||
"Failed to detect CUDA nvcc include information:\n${_nvcc_log}\n\n")
|
||||
endif()
|
||||
|
||||
|
||||
endif()
|
||||
|
||||
# configure all variables set in this file
|
||||
|
||||
Reference in New Issue
Block a user