summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-05-04 13:00:51 +0000
committerKitware Robot <kwrobot@kitware.com>2023-05-04 09:01:08 -0400
commit28dd02c3ba9dafb3df614565ec83223f61f30280 (patch)
treedac83df715fdfc46c6cf25e66ee2b59085aa89b8 /Source
parent7a4ec8d6cc3226185f4a04db7421d9414b1cada7 (diff)
parent7bf4e3009000b0ab576f364abc779e9a1599af08 (diff)
downloadcmake-28dd02c3ba9dafb3df614565ec83223f61f30280.tar.gz
Merge topic 'autogen-system-include'
7bf4e30090 Autogen: Default AUTOGEN_USE_SYSTEM_INCLUDE to ON if it is not set 033dc7ee2f Autogen: Add AUTOGEN_USE_SYSTEM_INCLUDE target property 8ba16db163 Tests/RunCMake: Add option for dynamic expected output Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !8400
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorTarget.cxx23
-rw-r--r--Source/cmGeneratorTarget.h2
-rw-r--r--Source/cmPolicies.h4
-rw-r--r--Source/cmQtAutoGenInitializer.cxx26
-rw-r--r--Source/cmTarget.cxx1
5 files changed, 55 insertions, 1 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 1c37e52bee..2eae2451bb 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -731,6 +731,29 @@ void cmGeneratorTarget::AddIncludeDirectory(const std::string& src,
BT<std::string>(src, this->Makefile->GetBacktrace()), true));
}
+void cmGeneratorTarget::AddSystemIncludeDirectory(std::string const& inc,
+ std::string const& lang)
+{
+ std::string config_upper;
+ auto const& configs =
+ this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
+
+ for (auto const& config : configs) {
+ std::string inc_with_config = inc;
+ if (!config.empty()) {
+ cmSystemTools::ReplaceString(inc_with_config, "$<CONFIG>", config);
+ config_upper = cmSystemTools::UpperCase(config);
+ }
+ auto const& key = cmStrCat(config_upper, "/", lang);
+ this->Target->AddSystemIncludeDirectories({ inc_with_config });
+ this->SystemIncludesCache[key].emplace_back(inc_with_config);
+
+ // SystemIncludesCache should be sorted so that binary search can be used
+ std::sort(this->SystemIncludesCache[key].begin(),
+ this->SystemIncludesCache[key].end());
+ }
+}
+
std::vector<cmSourceFile*> const* cmGeneratorTarget::GetSourceDepends(
cmSourceFile const* sf) const
{
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 87227fd29c..8b44eb50a9 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -912,6 +912,8 @@ public:
std::vector<std::string> GetGeneratedISPCObjects(
std::string const& config) const;
+ void AddSystemIncludeDirectory(std::string const& inc,
+ std::string const& lang);
bool AddHeaderSetVerification();
std::string GenerateHeaderSetVerificationFile(
cmSourceFile& source, const std::string& dir,
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 23e50a9715..a0030d3dc1 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -455,6 +455,10 @@ class cmMakefile;
"ExternalProject_Add and FetchContent_Declare commands " \
"treat relative GIT_REPOSITORY paths as being relative " \
"to the parent project's remote.", \
+ 3, 27, 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0151, \
+ "AUTOMOC include directory is a system include directory by " \
+ "default.", \
3, 27, 0, cmPolicies::WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index 5c32093b91..d897f0e5be 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -574,7 +574,31 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
// Add autogen include directory to the origin target INCLUDE_DIRECTORIES
if (this->MocOrUicEnabled() || (this->Rcc.Enabled && this->MultiConfig)) {
- this->GenTarget->AddIncludeDirectory(this->Dir.IncludeGenExp, true);
+ auto addBefore = false;
+ auto const& value =
+ this->GenTarget->GetProperty("AUTOGEN_USE_SYSTEM_INCLUDE");
+ if (value.IsSet()) {
+ if (cmIsOn(value)) {
+ this->GenTarget->AddSystemIncludeDirectory(this->Dir.IncludeGenExp,
+ "CXX");
+ } else {
+ addBefore = true;
+ }
+ } else {
+ switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0151)) {
+ case cmPolicies::WARN:
+ case cmPolicies::OLD:
+ addBefore = true;
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::NEW:
+ this->GenTarget->AddSystemIncludeDirectory(this->Dir.IncludeGenExp,
+ "CXX");
+ break;
+ }
+ }
+ this->GenTarget->AddIncludeDirectory(this->Dir.IncludeGenExp, addBefore);
}
// Scan files
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 01c5cc3410..0fbe430140 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -550,6 +550,7 @@ TargetProperty const StaticTargetProperties[] = {
// -- Autogen
{ "AUTOGEN_ORIGIN_DEPENDS"_s, IC::CanCompileSources },
{ "AUTOGEN_PARALLEL"_s, IC::CanCompileSources },
+ { "AUTOGEN_USE_SYSTEM_INCLUDE"_s, IC::CanCompileSources },
// -- moc
{ "AUTOMOC_DEPEND_FILTERS"_s, IC::CanCompileSources },
// -- C++