summaryrefslogtreecommitdiffstats
path: root/Source/cmFileAPICodemodel.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmFileAPICodemodel.cxx')
-rw-r--r--Source/cmFileAPICodemodel.cxx70
1 files changed, 57 insertions, 13 deletions
diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx
index 955195f..fe331ec 100644
--- a/Source/cmFileAPICodemodel.cxx
+++ b/Source/cmFileAPICodemodel.cxx
@@ -17,7 +17,7 @@
#include <cmext/algorithm>
-#include "cm_jsoncpp_value.h"
+#include <cm3p/json/value.h>
#include "cmCryptoHash.h"
#include "cmFileAPI.h"
@@ -31,6 +31,7 @@
#include "cmListFileCache.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
+#include "cmProperty.h"
#include "cmSourceFile.h"
#include "cmSourceGroup.h"
#include "cmState.h"
@@ -278,12 +279,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 +316,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 +376,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 +833,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)
@@ -855,8 +868,8 @@ CompileData Target::BuildCompileData(cmSourceFile* sf)
fd.Language);
const std::string COMPILE_FLAGS("COMPILE_FLAGS");
- if (const char* cflags = sf->GetProperty(COMPILE_FLAGS)) {
- std::string flags = genexInterpreter.Evaluate(cflags, COMPILE_FLAGS);
+ if (cmProp cflags = sf->GetProperty(COMPILE_FLAGS)) {
+ std::string flags = genexInterpreter.Evaluate(*cflags, COMPILE_FLAGS);
fd.Flags.emplace_back(std::move(flags), JBTIndex());
}
const std::string COMPILE_OPTIONS("COMPILE_OPTIONS");
@@ -872,14 +885,27 @@ CompileData Target::BuildCompileData(cmSourceFile* sf)
}
// Add precompile headers compile options.
- const std::string pchSource =
- this->GT->GetPchSource(this->Config, fd.Language);
+ std::vector<std::string> architectures;
+ this->GT->GetAppleArchs(this->Config, architectures);
+ if (architectures.empty()) {
+ architectures.emplace_back();
+ }
+
+ std::unordered_map<std::string, std::string> pchSources;
+ for (const std::string& arch : architectures) {
+ const std::string pchSource =
+ this->GT->GetPchSource(this->Config, fd.Language, arch);
+ if (!pchSource.empty()) {
+ pchSources.insert(std::make_pair(pchSource, arch));
+ }
+ }
- if (!pchSource.empty() && !sf->GetProperty("SKIP_PRECOMPILE_HEADERS")) {
+ if (!pchSources.empty() && !sf->GetProperty("SKIP_PRECOMPILE_HEADERS")) {
std::string pchOptions;
- if (sf->ResolveFullPath() == pchSource) {
- pchOptions =
- this->GT->GetPchCreateCompileOptions(this->Config, fd.Language);
+ auto pchIt = pchSources.find(sf->ResolveFullPath());
+ if (pchIt != pchSources.end()) {
+ pchOptions = this->GT->GetPchCreateCompileOptions(
+ this->Config, fd.Language, pchIt->second);
} else {
pchOptions =
this->GT->GetPchUseCompileOptions(this->Config, fd.Language);
@@ -936,10 +962,10 @@ CompileData Target::BuildCompileData(cmSourceFile* sf)
std::set<std::string> configFileDefines;
const std::string defPropName =
"COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(this->Config);
- if (const char* config_defs = sf->GetProperty(defPropName)) {
+ if (cmProp config_defs = sf->GetProperty(defPropName)) {
lg->AppendDefines(
configFileDefines,
- genexInterpreter.Evaluate(config_defs, COMPILE_DEFINITIONS));
+ genexInterpreter.Evaluate(*config_defs, COMPILE_DEFINITIONS));
}
fd.Defines.reserve(fileDefines.size() + configFileDefines.size());
@@ -967,6 +993,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());
@@ -1117,6 +1146,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;
}
@@ -1132,6 +1168,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;
@@ -1411,9 +1455,9 @@ Json::Value Target::DumpDependency(cmTargetDepend const& td)
Json::Value Target::DumpFolder()
{
Json::Value folder;
- if (const char* f = this->GT->GetProperty("FOLDER")) {
+ if (cmProp f = this->GT->GetProperty("FOLDER")) {
folder = Json::objectValue;
- folder["name"] = f;
+ folder["name"] = *f;
}
return folder;
}