try_compile: Restore toleration of toolchain file setting internal variable

Prior to commit 243462fafe (try_compile: Tolerate compile features from
non-enabled languages, 2026-05-18, v4.4.0-rc1~84^2) we accidentally
tolerated toolchain files setting `CMAKE_<LANG>_COMPILER_LOADED`.
Meson accidentally relied on this, so restore toleration of it.

Fixes: #27971
This commit is contained in:
Brad King
2026-07-20 14:52:47 -04:00
parent 062fe1d224
commit 39cc425791
4 changed files with 12 additions and 2 deletions
+5 -2
View File
@@ -850,8 +850,11 @@ void cmGlobalGenerator::EnableLanguage(
this->SetLanguageEnabled("NONE", mf);
continue;
}
std::string loadedLang = cmStrCat("CMAKE_", lang, "_COMPILER_LOADED");
if (!mf->GetDefinition(loadedLang)) {
// Compiler information may have already been detected and saved.
// Load it if we have not enabled the language anywhere yet, or
// if we have not loaded compiler information in this directory.
if (!this->GetLanguageEnabled(lang) ||
!mf->GetDefinition(cmStrCat("CMAKE_", lang, "_COMPILER_LOADED"))) {
fpath = cmStrCat(rootBin, "/CMake", lang, "Compiler.cmake");
// If the existing build tree was already configured with this
@@ -14,6 +14,7 @@ run_cmake_toolchain(LinkFlagsInit)
run_cmake_toolchain(CMP0126-NEW)
run_cmake_toolchain(CMP0126-OLD)
run_cmake_toolchain(CMP0126-WARN)
run_cmake_toolchain(SetCompilerLoaded)
run_cmake_toolchain(SetCrossCompiling)
function(run_IncludeDirectories)
@@ -0,0 +1 @@
set(CMAKE_C_COMPILER_LOADED 1)
@@ -0,0 +1,5 @@
enable_language(C)
try_compile(SHOULD_PASS SOURCE_FROM_CONTENT "main.c" "int main(void) { return 0; }")
if(NOT SHOULD_PASS)
message(FATAL_ERROR "try_compile failed but should have passed!")
endif()