summaryrefslogtreecommitdiffstats
path: root/Source/cmCoreTryCompile.cxx
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2024-05-18 08:48:00 (GMT)
committerCraig Scott <craig.scott@crascit.com>2024-05-30 09:01:03 (GMT)
commit4cb5bb014d0c09a7df4d64ad0f87d782acf95c14 (patch)
tree983abea6d32e0d6217459d3b875076935787a99c /Source/cmCoreTryCompile.cxx
parentff12b19786557560ec24bc5ad6a084dd6e96616c (diff)
downloadCMake-4cb5bb014d0c09a7df4d64ad0f87d782acf95c14.zip
CMake-4cb5bb014d0c09a7df4d64ad0f87d782acf95c14.tar.gz
CMake-4cb5bb014d0c09a7df4d64ad0f87d782acf95c14.tar.bz2
try_compile: Propagating top level includes into whole-project calls
Fixes: #24151
Diffstat (limited to 'Source/cmCoreTryCompile.cxx')
-rw-r--r--Source/cmCoreTryCompile.cxx11
1 files changed, 11 insertions, 0 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 6d3e01c..4d739ff 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -1240,6 +1240,17 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
}
}
+ if (!this->SrcFileSignature &&
+ this->Makefile->GetState()->GetGlobalPropertyAsBool(
+ "PROPAGATE_TOP_LEVEL_INCLUDES_TO_TRY_COMPILE")) {
+ const std::string var = "CMAKE_PROJECT_TOP_LEVEL_INCLUDES";
+ if (cmValue val = this->Makefile->GetDefinition(var)) {
+ std::string flag = cmStrCat("-D", var, "=\'", *val, '\'');
+ arguments.CMakeFlags.emplace_back(std::move(flag));
+ cmakeVariables.emplace(var, *val);
+ }
+ }
+
if (this->Makefile->GetState()->UseGhsMultiIDE()) {
// Forward the GHS variables to the inner project cache.
for (std::string const& var : ghs_platform_vars) {