summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2016-08-31 08:36:47 -0400
committerRobert Maynard <robert.maynard@kitware.com>2016-11-14 11:36:44 -0500
commita92f8d96162b9e6c29ad0bd81b8fd05b387d94a9 (patch)
treeef466320752bfda4f1ba600a1b42172fc5a9a714 /Modules
parentec6ce623351ea3fda95dda49a72fc279a63aee87 (diff)
downloadcmake-a92f8d96162b9e6c29ad0bd81b8fd05b387d94a9.tar.gz
CUDA: Enable header dependency scanning.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakeCUDAInformation.cmake15
1 files changed, 14 insertions, 1 deletions
diff --git a/Modules/CMakeCUDAInformation.cmake b/Modules/CMakeCUDAInformation.cmake
index d3278e75d5..41ed34f9aa 100644
--- a/Modules/CMakeCUDAInformation.cmake
+++ b/Modules/CMakeCUDAInformation.cmake
@@ -85,7 +85,20 @@ endif()
# compile a cu file into an object file
if(NOT CMAKE_CUDA_COMPILE_OBJECT)
set(CMAKE_CUDA_COMPILE_OBJECT
- "<CMAKE_CUDA_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -x cu -c <SOURCE>")
+ "<CMAKE_CUDA_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -x cu -c <SOURCE> -o <OBJECT>")
+
+ #The Ninja generator uses the make file dependency files to determine what
+ #files need to be recompiled. Unfortunately, nvcc doesn't support building
+ #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.
+ #
+ #The makefile generators uses the custom CMake dependency scanner, and thus
+ #it is exempt from this logic.
+ if(CMAKE_GENERATOR STREQUAL "Ninja")
+ list(APPEND CMAKE_CUDA_COMPILE_OBJECT
+ "<CMAKE_CUDA_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -x cu -M <SOURCE> -MT <OBJECT> -o $DEP_FILE")
+ endif()
+
endif()
# compile a cu file into an executable