diff options
author | Orkun Tokdemir <ilhanorkuntokdemir@gmail.com> | 2023-04-27 09:18:26 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-05-03 13:03:46 (GMT) |
commit | 033dc7ee2f02b0ebdfd1bc4edbcb24d1fc8c4152 (patch) | |
tree | b2674b6026bda729a8f75c221819cf4f79d11874 /Source | |
parent | 8ba16db1637940540fbb254cad7f85c2323c6a3a (diff) | |
download | CMake-033dc7ee2f02b0ebdfd1bc4edbcb24d1fc8c4152.zip CMake-033dc7ee2f02b0ebdfd1bc4edbcb24d1fc8c4152.tar.gz CMake-033dc7ee2f02b0ebdfd1bc4edbcb24d1fc8c4152.tar.bz2 |
Autogen: Add AUTOGEN_USE_SYSTEM_INCLUDE target property
`AUTOGEN_USE_SYSTEM_INCLUDE` was added. `AUTOGEN_USE_SYSTEM_INCLUDE`
is a boolean property that can be set on a target to indicate that the
autogen target include directory should be added as a system include
directory or normal include directory to the target.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 23 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 2 | ||||
-rw-r--r-- | Source/cmQtAutoGenInitializer.cxx | 15 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 1 |
4 files changed, 40 insertions, 1 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index db3d7e6..e7145b2 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 87227fd..8b44eb5 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/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 4c45949..deb2c04 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -576,7 +576,20 @@ 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 { + addBefore = true; + } + this->GenTarget->AddIncludeDirectory(this->Dir.IncludeGenExp, addBefore); } // Scan files diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 4f14648..c156f69 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -546,6 +546,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++ |