diff options
author | Brad King <brad.king@kitware.com> | 2020-05-25 14:40:47 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-05-25 14:40:56 (GMT) |
commit | 15b9b41d72d1de2299dbfd9e4f05c456b7a9124e (patch) | |
tree | 04a423ef2278228cd3cf31ac51b3a76e1d0ace64 /Source/cmFileAPICodemodel.cxx | |
parent | 54baf639652a0590825fef4f600645919ef13913 (diff) | |
parent | 9f6d40ee23113f1317e54d662316752adb9f368e (diff) | |
download | CMake-15b9b41d72d1de2299dbfd9e4f05c456b7a9124e.zip CMake-15b9b41d72d1de2299dbfd9e4f05c456b7a9124e.tar.gz CMake-15b9b41d72d1de2299dbfd9e4f05c456b7a9124e.tar.bz2 |
Merge topic 'fileApiAddPrecompileHeadersBacktrace'
9f6d40ee23 fileapi: Extend codemodel targets with PRECOMPILE_HEADERS
b698764a31 Tests: Add a PCH example to RunCMake.FileAPI codemodel-v2
b3812c0e54 Tests: Fix indentation in RunCMake.FileAPI cxx_exe.json
9c48804b69 PCH: Fix source group of per-architecture PCH headers
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4684
Diffstat (limited to 'Source/cmFileAPICodemodel.cxx')
-rw-r--r-- | Source/cmFileAPICodemodel.cxx | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index b983b21..b7daebe 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -278,12 +278,14 @@ struct CompileData std::string Sysroot; std::vector<JBT<std::string>> Flags; std::vector<JBT<std::string>> Defines; + std::vector<JBT<std::string>> PrecompileHeaders; std::vector<IncludeEntry> Includes; friend bool operator==(CompileData const& l, CompileData const& r) { return (l.Language == r.Language && l.Sysroot == r.Sysroot && l.Flags == r.Flags && l.Defines == r.Defines && + l.PrecompileHeaders == r.PrecompileHeaders && l.Includes == r.Includes); } }; @@ -313,6 +315,10 @@ struct hash<CompileData> result = result ^ hash<std::string>()(i.Value) ^ hash<Json::ArrayIndex>()(i.Backtrace.Index); } + for (auto const& i : in.PrecompileHeaders) { + result = result ^ hash<std::string>()(i.Value) ^ + hash<Json::ArrayIndex>()(i.Backtrace.Index); + } return result; } }; @@ -369,6 +375,7 @@ class Target Json::Value DumpPaths(); Json::Value DumpCompileData(CompileData const& cd); Json::Value DumpInclude(CompileData::IncludeEntry const& inc); + Json::Value DumpPrecompileHeader(JBT<std::string> const& header); Json::Value DumpDefine(JBT<std::string> const& def); Json::Value DumpSources(); Json::Value DumpSource(cmGeneratorTarget::SourceAndKind const& sk, @@ -825,6 +832,11 @@ void Target::ProcessLanguage(std::string const& lang) this->ToJBT(i), this->GT->IsSystemIncludeDirectory(i.Value, this->Config, lang)); } + std::vector<BT<std::string>> precompileHeaders = + this->GT->GetPrecompileHeaders(this->Config, lang); + for (BT<std::string> const& pch : precompileHeaders) { + cd.PrecompileHeaders.emplace_back(this->ToJBT(pch)); + } } Json::ArrayIndex Target::AddSourceGroup(cmSourceGroup* sg, Json::ArrayIndex si) @@ -980,6 +992,9 @@ CompileData Target::MergeCompileData(CompileData const& fd) // All compile groups share the sysroot of the target. cd.Sysroot = td.Sysroot; + // All compile groups share the precompile headers of the target. + cd.PrecompileHeaders = td.PrecompileHeaders; + // Use target-wide flags followed by source-specific flags. cd.Flags.reserve(td.Flags.size() + fd.Flags.size()); cd.Flags.insert(cd.Flags.end(), td.Flags.begin(), td.Flags.end()); @@ -1130,6 +1145,13 @@ Json::Value Target::DumpCompileData(CompileData const& cd) } result["defines"] = std::move(defines); } + if (!cd.PrecompileHeaders.empty()) { + Json::Value precompileHeaders = Json::arrayValue; + for (JBT<std::string> const& pch : cd.PrecompileHeaders) { + precompileHeaders.append(this->DumpPrecompileHeader(pch)); + } + result["precompileHeaders"] = std::move(precompileHeaders); + } return result; } @@ -1145,6 +1167,14 @@ Json::Value Target::DumpInclude(CompileData::IncludeEntry const& inc) return include; } +Json::Value Target::DumpPrecompileHeader(JBT<std::string> const& header) +{ + Json::Value precompileHeader = Json::objectValue; + precompileHeader["header"] = header.Value; + this->AddBacktrace(precompileHeader, header.Backtrace); + return precompileHeader; +} + Json::Value Target::DumpDefine(JBT<std::string> const& def) { Json::Value define = Json::objectValue; |