summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-10-18 13:12:10 (GMT)
committerBrad King <brad.king@kitware.com>2022-10-18 17:38:00 (GMT)
commit50e90e282847f1109e5559d49fc12214b3493fff (patch)
treeeb14171de7c42a755f0afab1b7db20b97dbf07fc /Source
parent367f10f4cbeb5d782e08a6e29ea5678fa4e71d14 (diff)
downloadCMake-50e90e282847f1109e5559d49fc12214b3493fff.zip
CMake-50e90e282847f1109e5559d49fc12214b3493fff.tar.gz
CMake-50e90e282847f1109e5559d49fc12214b3493fff.tar.bz2
try_compile: Honor CMP0128 setting in test project
Some projects pass a raw `-std=` flag to the compiler in the `try_compile` project. If they do not set CMP0128 to NEW, we should not append a `-std=` flag where we did not before the policy was added. Fixes: #24063
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCoreTryCompile.cxx6
1 files changed, 6 insertions, 0 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 324ce87..8d7c5fa 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -577,6 +577,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
fprintf(fout, "cmake_policy(SET CMP0126 OLD)\n");
}
+ /* Set language extensions policy to match outer project. */
+ if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0128) !=
+ cmPolicies::NEW) {
+ fprintf(fout, "cmake_policy(SET CMP0128 OLD)\n");
+ }
+
std::string projectLangs;
for (std::string const& li : testLangs) {
projectLangs += " " + li;