Merge topic 'backport-4.3-cmp0210-trycompile-policy-order' into release-4.3

92320466dd try_compile: Restore platform-default link flags in pre-CMP0210 projects

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12525
This commit is contained in:
Brad King
2026-09-21 13:40:54 -04:00
12 changed files with 27 additions and 9 deletions
+7 -9
View File
@@ -692,6 +692,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);
@@ -912,15 +919,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");
// Workaround for -Wl,-headerpad_max_install_names issue until we can
// avoid adding that flag in the platform and compiler language files
fprintf(fout,
@@ -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(SetCrossCompiling)
function(run_IncludeDirectories)