mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 05:26:58 +08:00
CompilerId: Tolerate variables named for languages
If a project or user sets a variable or cache entry named `C`, `CXX`,
`CUDA`, `Fortran`, `CSharp`, or `ISPC`, we were previously comparing
each enabled language name to the value of that variable, rather than
the name itself. Double-quote the string to take advantage of policy
`CMP0054`, but also add "x" prefixes to support projects that do not set
the policy.
This extends a similar fix in commit bd16a985fc
(CompilerId/Features:
Tolerate variables named for languages, 2021-04-28) in more places. In
particular, ensure that we consider the proper list of compiler ids.
Issue: #22125
This commit is contained in:

committed by
Brad King

parent
d64d2d12c3
commit
c8eb357738
@@ -13,8 +13,8 @@ endfunction()
|
|||||||
|
|
||||||
function(compiler_id_detection outvar lang)
|
function(compiler_id_detection outvar lang)
|
||||||
|
|
||||||
if (NOT lang STREQUAL Fortran AND NOT lang STREQUAL CSharp
|
if (NOT "x${lang}" STREQUAL "xFortran" AND NOT "x${lang}" STREQUAL "xCSharp"
|
||||||
AND NOT lang STREQUAL ISPC)
|
AND NOT "x${lang}" STREQUAL "xISPC")
|
||||||
file(GLOB lang_files
|
file(GLOB lang_files
|
||||||
"${CMAKE_ROOT}/Modules/Compiler/*-DetermineCompiler.cmake")
|
"${CMAKE_ROOT}/Modules/Compiler/*-DetermineCompiler.cmake")
|
||||||
set(nonlang CXX)
|
set(nonlang CXX)
|
||||||
@@ -42,7 +42,7 @@ function(compiler_id_detection outvar lang)
|
|||||||
|
|
||||||
# Order is relevant here. For example, compilers which pretend to be
|
# Order is relevant here. For example, compilers which pretend to be
|
||||||
# GCC must appear before the actual GCC.
|
# GCC must appear before the actual GCC.
|
||||||
if (lang STREQUAL CXX)
|
if ("x${lang}" STREQUAL "xCXX")
|
||||||
list(APPEND ordered_compilers
|
list(APPEND ordered_compilers
|
||||||
Comeau
|
Comeau
|
||||||
)
|
)
|
||||||
@@ -70,7 +70,7 @@ function(compiler_id_detection outvar lang)
|
|||||||
Fujitsu
|
Fujitsu
|
||||||
GHS
|
GHS
|
||||||
)
|
)
|
||||||
if (lang STREQUAL C)
|
if ("x${lang}" STREQUAL "xC")
|
||||||
list(APPEND ordered_compilers
|
list(APPEND ordered_compilers
|
||||||
TinyCC
|
TinyCC
|
||||||
Bruce
|
Bruce
|
||||||
@@ -92,13 +92,13 @@ function(compiler_id_detection outvar lang)
|
|||||||
ADSP
|
ADSP
|
||||||
IAR
|
IAR
|
||||||
)
|
)
|
||||||
if (lang STREQUAL C)
|
if ("x${lang}" STREQUAL "xC")
|
||||||
list(APPEND ordered_compilers
|
list(APPEND ordered_compilers
|
||||||
SDCC
|
SDCC
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(lang STREQUAL CUDA)
|
if("x${lang}" STREQUAL "xCUDA")
|
||||||
set(ordered_compilers NVIDIA Clang)
|
set(ordered_compilers NVIDIA Clang)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user