summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-06-04 12:30:18 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-06-04 12:30:26 (GMT)
commitd4108f5585ae4e0ab79c9b192f9d6a0614f868cd (patch)
treef5c302804e2fc294d4b1e08cbcac475deed33094 /Modules
parent99b9b01c020a0b20c0eefa73a39138471c01a053 (diff)
parentfada8cbfd6ae13d15b015f667a85096b15dc07b1 (diff)
downloadCMake-d4108f5585ae4e0ab79c9b192f9d6a0614f868cd.zip
CMake-d4108f5585ae4e0ab79c9b192f9d6a0614f868cd.tar.gz
CMake-d4108f5585ae4e0ab79c9b192f9d6a0614f868cd.tar.bz2
Merge topic 'check_language_respects_cuda_host_compiler'
fada8cbfd6 CheckLanguage: Report CMAKE_CUDA_HOST_COMPILER if needed for compilation Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3407
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CheckLanguage.cmake27
1 files changed, 23 insertions, 4 deletions
diff --git a/Modules/CheckLanguage.cmake b/Modules/CheckLanguage.cmake
index d096849..a1a3a7a 100644
--- a/Modules/CheckLanguage.cmake
+++ b/Modules/CheckLanguage.cmake
@@ -18,7 +18,9 @@ such as ``Fortran``. If :variable:`CMAKE_<LANG>_COMPILER` is already defined
the check does nothing. Otherwise it tries enabling the language in a
test project. The result is cached in :variable:`CMAKE_<LANG>_COMPILER`
as the compiler that was found, or ``NOTFOUND`` if the language cannot be
-enabled.
+enabled. For CUDA which can have an explicit host compiler, the cache
+:variable:`CMAKE_CUDA_HOST_COMPILER` variable will be set if it was required
+for compilation.
Example:
@@ -39,13 +41,23 @@ macro(check_language lang)
set(_desc "Looking for a ${lang} compiler")
message(STATUS ${_desc})
file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang})
- file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang}/CMakeLists.txt"
+
+ set(extra_compiler_variables)
+ if(lang STREQUAL CUDA)
+ set(extra_compiler_variables "set(CMAKE_CUDA_HOST_COMPILER \\\"\${CMAKE_CUDA_HOST_COMPILER}\\\")")
+ endif()
+
+ set(content
"cmake_minimum_required(VERSION ${CMAKE_VERSION})
project(Check${lang} ${lang})
file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\"
\"set(CMAKE_${lang}_COMPILER \\\"\${CMAKE_${lang}_COMPILER}\\\")\\n\"
- )
-")
+ \"${extra_compiler_variables}\\n\"
+ )"
+ )
+
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang}/CMakeLists.txt"
+ "${content}")
if(CMAKE_GENERATOR_INSTANCE)
set(_D_CMAKE_GENERATOR_INSTANCE "-DCMAKE_GENERATOR_INSTANCE:INTERNAL=${CMAKE_GENERATOR_INSTANCE}")
else()
@@ -75,5 +87,12 @@ file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\"
message(STATUS "${_desc} - ${CMAKE_${lang}_COMPILER}")
set(CMAKE_${lang}_COMPILER "${CMAKE_${lang}_COMPILER}" CACHE FILEPATH "${lang} compiler")
mark_as_advanced(CMAKE_${lang}_COMPILER)
+
+ if(CMAKE_${lang}_HOST_COMPILER)
+ message(STATUS "Looking for a ${lang} host compiler - ${CMAKE_${lang}_HOST_COMPILER}")
+ set(CMAKE_${lang}_HOST_COMPILER "${CMAKE_${lang}_HOST_COMPILER}" CACHE FILEPATH "${lang} host compiler")
+ mark_as_advanced(CMAKE_${lang}_HOST_COMPILER)
+ endif()
+
endif()
endmacro()