Merge branch 'backport-4.3-cmp0210-trycompile-policy-order'

This commit is contained in:
Brad King
2026-09-21 11:47:20 -04:00
12 changed files with 27 additions and 9 deletions
+7 -9
View File
@@ -691,6 +691,13 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
*cmp0197 == "NEW"_s ? "NEW" : "OLD");
}
/* Set per-language link flags policy to match outer project.
It affects platform modules. */
if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0210) !=
cmPolicies::NEW) {
fprintf(fout, "cmake_policy(SET CMP0210 OLD)\n");
}
std::string projectLangs;
for (std::string const& li : testLangs) {
projectLangs += cmStrCat(' ', li);
@@ -907,15 +914,6 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
? "NEW"
: "OLD");
/* Set the appropriate policy information for passing
* CMAKE_<LANG>_LINK_FLAGS
*/
fprintf(fout, "cmake_policy(SET CMP0210 %s)\n",
this->Makefile->GetPolicyStatus(cmPolicies::CMP0210) ==
cmPolicies::NEW
? "NEW"
: "OLD");
// Honor CMAKE_EXE_LINKER_FLAGS in Swift if the outer project does.
fprintf(fout, "cmake_policy(SET CMP0214 %s)\n",
this->Makefile->GetPolicyStatus(cmPolicies::CMP0214) ==
@@ -0,0 +1 @@
^try_compile CMP0210='NEW'
@@ -0,0 +1 @@
include("${CMAKE_CURRENT_LIST_DIR}/CMP0210-toolchain.cmake")
@@ -0,0 +1,2 @@
cmake_policy(SET CMP0210 NEW)
enable_language(C)
@@ -0,0 +1 @@
^try_compile CMP0210='OLD'
@@ -0,0 +1 @@
include("${CMAKE_CURRENT_LIST_DIR}/CMP0210-toolchain.cmake")
@@ -0,0 +1,2 @@
cmake_policy(SET CMP0210 OLD)
enable_language(C)
@@ -0,0 +1 @@
^try_compile CMP0210='OLD'
@@ -0,0 +1 @@
include("${CMAKE_CURRENT_LIST_DIR}/CMP0210-toolchain.cmake")
@@ -0,0 +1,2 @@
# leave CMP0210 unset
enable_language(C)
@@ -0,0 +1,5 @@
get_property(_IN_TC GLOBAL PROPERTY IN_TRY_COMPILE)
if(_IN_TC)
cmake_policy(GET CMP0210 cmp0210)
message("try_compile CMP0210='${cmp0210}'")
endif()
@@ -14,6 +14,9 @@ run_cmake_toolchain(LinkFlagsInit)
run_cmake_toolchain(CMP0126-NEW)
run_cmake_toolchain(CMP0126-OLD)
run_cmake_toolchain(CMP0126-WARN)
run_cmake_toolchain(CMP0210-NEW)
run_cmake_toolchain(CMP0210-OLD)
run_cmake_toolchain(CMP0210-WARN)
run_cmake_toolchain(SetCompilerLoaded)
run_cmake_toolchain(SetCrossCompiling)