summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2016-09-04 20:29:44 (GMT)
committerRobert Maynard <robert.maynard@kitware.com>2016-11-14 16:36:44 (GMT)
commitbbaf24341026cdacd1e313dd3f8e3501e9c4070e (patch)
treeb88916748a529370a937b85c1b49b3da7887f310 /Modules
parenta92f8d96162b9e6c29ad0bd81b8fd05b387d94a9 (diff)
downloadCMake-bbaf24341026cdacd1e313dd3f8e3501e9c4070e.zip
CMake-bbaf24341026cdacd1e313dd3f8e3501e9c4070e.tar.gz
CMake-bbaf24341026cdacd1e313dd3f8e3501e9c4070e.tar.bz2
CUDA: add support for specifying an explicit host compiler.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakeCUDAInformation.cmake14
-rw-r--r--Modules/CMakeDetermineCUDACompiler.cmake13
2 files changed, 22 insertions, 5 deletions
diff --git a/Modules/CMakeCUDAInformation.cmake b/Modules/CMakeCUDAInformation.cmake
index 41ed34f..858fee7 100644
--- a/Modules/CMakeCUDAInformation.cmake
+++ b/Modules/CMakeCUDAInformation.cmake
@@ -59,10 +59,16 @@ include(CMakeCommonLanguageInclude)
# CMAKE_CUDA_COMPILE_OBJECT
# CMAKE_CUDA_LINK_EXECUTABLE
+if(CMAKE_CUDA_HOST_COMPILER)
+ set(CMAKE_CUDA_HOST_FLAGS "-ccbin \"${CMAKE_CUDA_HOST_COMPILER}\" ")
+else()
+ set(CMAKE_CUDA_HOST_FLAGS "")
+endif()
+
# create a shared library
if(NOT CMAKE_CUDA_CREATE_SHARED_LIBRARY)
set(CMAKE_CUDA_CREATE_SHARED_LIBRARY
- "<CMAKE_CUDA_COMPILER> <CMAKE_SHARED_LIBRARY_CUDA_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CUDA_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
+ "<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <CMAKE_SHARED_LIBRARY_CUDA_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CUDA_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
endif()
# create a shared module copy the shared library rule by default
@@ -85,7 +91,7 @@ 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> -x cu -c <SOURCE> -o <OBJECT>")
+ "<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <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
@@ -96,7 +102,7 @@ if(NOT CMAKE_CUDA_COMPILE_OBJECT)
#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")
+ "<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -M <SOURCE> -MT <OBJECT> -o $DEP_FILE")
endif()
endif()
@@ -104,7 +110,7 @@ endif()
# compile a cu file into an executable
if(NOT CMAKE_CUDA_LINK_EXECUTABLE)
set(CMAKE_CUDA_LINK_EXECUTABLE
- "<CMAKE_CUDA_COMPILER> <FLAGS> <CMAKE_CUDA_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
+ "<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <FLAGS> <CMAKE_CUDA_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
endif()
diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake
index a6863ef..d5dc9f4 100644
--- a/Modules/CMakeDetermineCUDACompiler.cmake
+++ b/Modules/CMakeDetermineCUDACompiler.cmake
@@ -23,6 +23,10 @@ endif()
mark_as_advanced(CMAKE_CUDA_COMPILER)
+#Allow the user to specify a host compiler
+#todo: need to specify this to compiler test passes
+set(CMAKE_CUDA_HOST_COMPILER "" CACHE FILEPATH "Host compiler to be used by nvcc")
+
# Build a small source file to identify the compiler.
if(NOT CMAKE_CUDA_COMPILER_ID_RUN)
set(CMAKE_CUDA_COMPILER_ID_RUN 1)
@@ -39,9 +43,16 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN)
set(CMAKE_CXX_COMPILER_ID_TOOL_MATCH_REGEX "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerIdCUDA/(\\./)?(CompilerIdCUDA.xctest/)?CompilerIdCUDA[ \t\n\\\"]")
set(CMAKE_CXX_COMPILER_ID_TOOL_MATCH_INDEX 2)
+ if(CMAKE_CUDA_HOST_COMPILER)
+ # Each entry in this list is a set of extra flags to try
+ # adding to the compile line to see if it helps produce
+ # a valid identification file. In our case this would just
+ # be the explicit host compiler
+ set(CMAKE_CUDA_COMPILER_ID_TEST_FLAGS_FIRST "-ccbin=${CMAKE_CUDA_HOST_COMPILER}")
+ endif()
+
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake)
CMAKE_DETERMINE_COMPILER_ID(CUDA CUDAFLAGS CMakeCUDACompilerId.cu)
-
endif()
include(CMakeFindBinUtils)