diff options
author | Brad King <brad.king@kitware.com> | 2021-04-28 18:37:51 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-05-03 14:22:23 (GMT) |
commit | bd16a985fcc26a2138e20ed11c248cd716eb5497 (patch) | |
tree | dc80e9edd83ec8a0f70f6568e4f5990958d84956 /Modules/CMakeDetermineCompileFeatures.cmake | |
parent | 49c6d0f26199c252b493ed5f816dbcb2e9701112 (diff) | |
download | CMake-bd16a985fcc26a2138e20ed11c248cd716eb5497.zip CMake-bd16a985fcc26a2138e20ed11c248cd716eb5497.tar.gz CMake-bd16a985fcc26a2138e20ed11c248cd716eb5497.tar.bz2 |
CompilerId/Features: Tolerate variables named for languages
If a `CMakeLists.txt` or `CMAKE_TOOLCHAIN_FILE` sets a variable named
`C`, `CXX`, or `CUDA`, 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.
Fixes: #22125
Diffstat (limited to 'Modules/CMakeDetermineCompileFeatures.cmake')
-rw-r--r-- | Modules/CMakeDetermineCompileFeatures.cmake | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Modules/CMakeDetermineCompileFeatures.cmake b/Modules/CMakeDetermineCompileFeatures.cmake index f767847..ee7fedb 100644 --- a/Modules/CMakeDetermineCompileFeatures.cmake +++ b/Modules/CMakeDetermineCompileFeatures.cmake @@ -4,7 +4,7 @@ function(cmake_determine_compile_features lang) - if(lang STREQUAL C AND COMMAND cmake_record_c_compile_features) + if("x${lang}" STREQUAL "xC" AND COMMAND cmake_record_c_compile_features) message(CHECK_START "Detecting ${lang} compile features") set(CMAKE_C90_COMPILE_FEATURES) @@ -54,7 +54,7 @@ function(cmake_determine_compile_features lang) message(CHECK_PASS "done") - elseif(lang STREQUAL CXX AND COMMAND cmake_record_cxx_compile_features) + elseif("x${lang}" STREQUAL "xCXX" AND COMMAND cmake_record_cxx_compile_features) message(CHECK_START "Detecting ${lang} compile features") set(CMAKE_CXX98_COMPILE_FEATURES) @@ -110,7 +110,7 @@ function(cmake_determine_compile_features lang) message(CHECK_PASS "done") - elseif(lang STREQUAL CUDA AND COMMAND cmake_record_cuda_compile_features) + elseif("x${lang}" STREQUAL "xCUDA" AND COMMAND cmake_record_cuda_compile_features) message(CHECK_START "Detecting ${lang} compile features") set(CMAKE_CUDA03_COMPILE_FEATURES) |