mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-18 05:01:50 -06:00
CUDA: get header deps from compiler invocation when possible
Before CUDA 10.2 `nvcc` didn't support providing header dependency information while compiling.
This commit is contained in:
@@ -148,11 +148,11 @@ if(NOT CMAKE_CUDA_COMPILE_WHOLE_COMPILATION)
|
|||||||
"<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -c <SOURCE> -o <OBJECT>")
|
"<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -c <SOURCE> -o <OBJECT>")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_GENERATOR STREQUAL "Ninja")
|
if(CMAKE_GENERATOR STREQUAL "Ninja" AND NOT CMAKE_DEPFILE_FLAGS_CUDA )
|
||||||
set(CMAKE_CUDA_COMPILE_DEPENDENCY_DETECTION
|
set(CMAKE_CUDA_COMPILE_DEPENDENCY_DETECTION
|
||||||
"<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -M <SOURCE> -MT <OBJECT> -o $DEP_FILE")
|
"<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -M <SOURCE> -MT <OBJECT> -o $DEP_FILE")
|
||||||
#The Ninja generator uses the make file dependency files to determine what
|
#The Ninja generator uses the make file dependency files to determine what
|
||||||
#files need to be recompiled. Unfortunately, nvcc doesn't support building
|
#files need to be recompiled. Unfortunately, nvcc < 10.2 doesn't support building
|
||||||
#a source file and generating the dependencies of said file in a single
|
#a source file and generating the dependencies of said file in a single
|
||||||
#invocation. Instead we have to state that you need to chain two commands.
|
#invocation. Instead we have to state that you need to chain two commands.
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -18,6 +18,13 @@ else()
|
|||||||
set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "")
|
set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (NOT CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 10.2)
|
||||||
|
# The -MD flag was only added to nvcc in 10.2 so
|
||||||
|
# before that we had to invoke the compiler twice
|
||||||
|
# to get header dependency information
|
||||||
|
set(CMAKE_DEPFILE_FLAGS_CUDA "-MD -MT <OBJECT> -MF <DEPFILE>")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT "x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC")
|
if(NOT "x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC")
|
||||||
set(CMAKE_CUDA_COMPILE_OPTIONS_PIE -Xcompiler=-fPIE)
|
set(CMAKE_CUDA_COMPILE_OPTIONS_PIE -Xcompiler=-fPIE)
|
||||||
set(CMAKE_CUDA_COMPILE_OPTIONS_PIC -Xcompiler=-fPIC)
|
set(CMAKE_CUDA_COMPILE_OPTIONS_PIC -Xcompiler=-fPIC)
|
||||||
|
|||||||
Reference in New Issue
Block a user