mirror of
https://github.com/Kitware/CMake.git
synced 2025-05-08 22:37:04 +08:00
CheckLanguage: Bias compiler selection using already-enabled languages
In a project that has enabled C or CXX, we bias ASM and Fortran compiler selection to match. Propagate this bias into the `check_language` test project so that if it succeeds, we will select the same compiler when enabling the tested language in the calling project. Fixes: #19350
This commit is contained in:
parent
f290240b0b
commit
89df8efba4
@ -4,7 +4,11 @@
|
||||
|
||||
macro(_cmake_find_compiler lang)
|
||||
# Use already-enabled languages for reference.
|
||||
get_property(_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||
if(DEFINED _CMAKE_CHECK_ENABLED_LANGUAGES)
|
||||
set(_languages "${_CMAKE_CHECK_ENABLED_LANGUAGES}")
|
||||
else()
|
||||
get_property(_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||
endif()
|
||||
list(REMOVE_ITEM _languages "${lang}")
|
||||
|
||||
if(CMAKE_${lang}_COMPILER_INIT)
|
||||
|
@ -78,6 +78,19 @@ macro(check_language lang)
|
||||
file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang})
|
||||
|
||||
set(_input_variables "set(CMAKE_MODULE_PATH \"${CMAKE_MODULE_PATH}\")\n")
|
||||
get_property(_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||
list(REMOVE_ITEM _languages "NONE")
|
||||
if(NOT _languages STREQUAL "")
|
||||
string(APPEND _input_variables "set(_CMAKE_CHECK_ENABLED_LANGUAGES \"${_languages}\")\n")
|
||||
foreach(l IN LISTS _languages)
|
||||
string(APPEND _input_variables
|
||||
"set(CMAKE_${l}_COMPILER \"${CMAKE_${l}_COMPILER}\")\n"
|
||||
"set(CMAKE_${l}_COMPILER_ID \"${CMAKE_${l}_COMPILER_ID}\")\n"
|
||||
"set(CMAKE_${l}_COMPILER_LOADED ${CMAKE_${l}_COMPILER_LOADED})\n"
|
||||
"set(CMAKE_${l}_COMPILER_VERSION \"${CMAKE_${l}_COMPILER_VERSION}\")\n"
|
||||
)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
set(_output_variables "set(CMAKE_${lang}_COMPILER \\\"\${CMAKE_${lang}_COMPILER}\\\")\n")
|
||||
if("${lang}" MATCHES "^(CUDA|HIP)$" AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||
|
Loading…
x
Reference in New Issue
Block a user