summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-02-14 13:30:30 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2017-02-14 13:30:30 (GMT)
commitb7d8d80a62d2e2c31863efedd41945c2e9db9bcf (patch)
tree84a8e182a22b845bb5455d1e41fb0505820a9fe4 /Modules
parent31e96ccca23a034700e780470bf48cff0d7fd15e (diff)
parent44f3acb202c316bc6a863a1823aaafae486c899a (diff)
downloadCMake-b7d8d80a62d2e2c31863efedd41945c2e9db9bcf.zip
CMake-b7d8d80a62d2e2c31863efedd41945c2e9db9bcf.tar.gz
CMake-b7d8d80a62d2e2c31863efedd41945c2e9db9bcf.tar.bz2
Merge topic 'cmake_provide_include_dir_for_toolkit'
44f3acb2 CUDA: Detect the toolkit include directories
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakeCUDACompiler.cmake.in2
-rw-r--r--Modules/CMakeDetermineCUDACompiler.cmake34
2 files changed, 32 insertions, 4 deletions
diff --git a/Modules/CMakeCUDACompiler.cmake.in b/Modules/CMakeCUDACompiler.cmake.in
index 158d12b..f524e5f 100644
--- a/Modules/CMakeCUDACompiler.cmake.in
+++ b/Modules/CMakeCUDACompiler.cmake.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@")
diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake
index bef6d0e..7b6d17b 100644
--- a/Modules/CMakeDetermineCUDACompiler.cmake
+++ b/Modules/CMakeDetermineCUDACompiler.cmake
@@ -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