summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-11-14 15:24:52 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-11-14 15:25:01 (GMT)
commit0e2a73fefd2899a2d5aa3ed99c71539fa6820b03 (patch)
treeff274a1cebf7e456881643b632e41a9f9ac74042 /Source
parent4bf832086a137dcf92a2c27a54d35f6c0a717585 (diff)
parent4d70a94545629affd3d68dda74ec71c62a3bb0c4 (diff)
downloadCMake-0e2a73fefd2899a2d5aa3ed99c71539fa6820b03.zip
CMake-0e2a73fefd2899a2d5aa3ed99c71539fa6820b03.tar.gz
CMake-0e2a73fefd2899a2d5aa3ed99c71539fa6820b03.tar.bz2
Merge topic 'profile-genex'
4d70a94545 Profiling: Profile genex evaluation 09d7f947d6 cmGeneratorExpression: Require cmake instance 553794e987 cmake::CreateProfilingEntry: Refactor to take lambda for args Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Acked-by: alcroito <alexandru.croitor@qt.io> Merge-request: !7898
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCustomCommandGenerator.cxx5
-rw-r--r--Source/cmExportFileGenerator.cxx2
-rw-r--r--Source/cmExportInstallFileGenerator.cxx4
-rw-r--r--Source/cmExportTryCompileFileGenerator.cxx2
-rw-r--r--Source/cmFileCommand.cxx6
-rw-r--r--Source/cmFileSet.cxx9
-rw-r--r--Source/cmFileSet.h4
-rw-r--r--Source/cmGeneratorExpression.cxx26
-rw-r--r--Source/cmGeneratorExpression.h13
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.cxx2
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx31
-rw-r--r--Source/cmGeneratorExpressionNode.cxx2
-rw-r--r--Source/cmGeneratorTarget.cxx59
-rw-r--r--Source/cmInstalledFile.cxx4
-rw-r--r--Source/cmLocalGenerator.cxx2
-rw-r--r--Source/cmLocalNinjaGenerator.cxx2
-rw-r--r--Source/cmMakefile.cxx15
-rw-r--r--Source/cmMakefileProfilingData.cxx29
-rw-r--r--Source/cmMakefileProfilingData.h14
-rw-r--r--Source/cmQtAutoGenInitializer.cxx2
-rw-r--r--Source/cmTarget.cxx5
-rw-r--r--Source/cmTestGenerator.cxx3
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx10
-rw-r--r--Source/cmake.h13
24 files changed, 169 insertions, 95 deletions
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index 41d4442..57b009a 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -172,7 +172,7 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(
};
}
- cmGeneratorExpression ge(cc.GetBacktrace());
+ cmGeneratorExpression ge(*lg->GetCMakeInstance(), cc.GetBacktrace());
cmGeneratorTarget const* target{ lg->FindGeneratorTargetToUse(
this->Target) };
@@ -417,7 +417,8 @@ std::string cmCustomCommandGenerator::GetDepfile() const
return "";
}
- cmGeneratorExpression ge(this->CC->GetBacktrace());
+ cmGeneratorExpression ge(*this->LG->GetCMakeInstance(),
+ this->CC->GetBacktrace());
return EvaluateDepfile(depfile, ge, this->LG, this->OutputConfig);
}
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 2c61163..bd2b6af 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -379,7 +379,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
const char* propName = "INTERFACE_INCLUDE_DIRECTORIES";
cmValue input = target->GetProperty(propName);
- cmGeneratorExpression ge;
+ cmGeneratorExpression ge(*target->Makefile->GetCMakeInstance());
std::string dirs = cmGeneratorExpression::Preprocess(
cmJoin(target->Target->GetInstallIncludeDirectoriesEntries(te), ";"),
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index 195737b..5e190f4 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -570,7 +570,7 @@ std::string cmExportInstallFileGenerator::GetFileSetDirectories(
auto configs =
gte->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
- cmGeneratorExpression ge;
+ cmGeneratorExpression ge(*gte->Makefile->GetCMakeInstance());
auto cge = ge.Parse(te->FileSetGenerators.at(fileSet)->GetDestination());
for (auto const& config : configs) {
@@ -617,7 +617,7 @@ std::string cmExportInstallFileGenerator::GetFileSetFiles(
auto fileEntries = fileSet->CompileFileEntries();
auto directoryEntries = fileSet->CompileDirectoryEntries();
- cmGeneratorExpression destGe;
+ cmGeneratorExpression destGe(*gte->Makefile->GetCMakeInstance());
auto destCge =
destGe.Parse(te->FileSetGenerators.at(fileSet)->GetDestination());
diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx
index e98aa05..33c057d 100644
--- a/Source/cmExportTryCompileFileGenerator.cxx
+++ b/Source/cmExportTryCompileFileGenerator.cxx
@@ -70,7 +70,7 @@ std::string cmExportTryCompileFileGenerator::FindTargets(
return std::string();
}
- cmGeneratorExpression ge;
+ cmGeneratorExpression ge(*tgt->Makefile->GetCMakeInstance());
std::unique_ptr<cmGeneratorExpressionDAGChecker> parentDagChecker;
if (propName == "INTERFACE_LINK_OPTIONS") {
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index cc9b256..b1d238c 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -2462,11 +2462,13 @@ void AddEvaluationFile(const std::string& inputName,
{
cmListFileBacktrace lfbt = status.GetMakefile().GetBacktrace();
- cmGeneratorExpression outputGe(lfbt);
+ cmGeneratorExpression outputGe(*status.GetMakefile().GetCMakeInstance(),
+ lfbt);
std::unique_ptr<cmCompiledGeneratorExpression> outputCge =
outputGe.Parse(outputExpr);
- cmGeneratorExpression conditionGe(lfbt);
+ cmGeneratorExpression conditionGe(*status.GetMakefile().GetCMakeInstance(),
+ lfbt);
std::unique_ptr<cmCompiledGeneratorExpression> conditionCge =
conditionGe.Parse(condition);
diff --git a/Source/cmFileSet.cxx b/Source/cmFileSet.cxx
index d6665a2..b96ba6e 100644
--- a/Source/cmFileSet.cxx
+++ b/Source/cmFileSet.cxx
@@ -78,9 +78,10 @@ bool cmFileSetVisibilityIsForInterface(cmFileSetVisibility vis)
return false;
}
-cmFileSet::cmFileSet(std::string name, std::string type,
+cmFileSet::cmFileSet(cmake& cmakeInstance, std::string name, std::string type,
cmFileSetVisibility visibility)
- : Name(std::move(name))
+ : CMakeInstance(cmakeInstance)
+ , Name(std::move(name))
, Type(std::move(type))
, Visibility(visibility)
{
@@ -113,7 +114,7 @@ cmFileSet::CompileFileEntries() const
for (auto const& entry : this->FileEntries) {
for (auto const& ex : cmExpandedList(entry.Value)) {
- cmGeneratorExpression ge(entry.Backtrace);
+ cmGeneratorExpression ge(this->CMakeInstance, entry.Backtrace);
auto cge = ge.Parse(ex);
result.push_back(std::move(cge));
}
@@ -129,7 +130,7 @@ cmFileSet::CompileDirectoryEntries() const
for (auto const& entry : this->DirectoryEntries) {
for (auto const& ex : cmExpandedList(entry.Value)) {
- cmGeneratorExpression ge(entry.Backtrace);
+ cmGeneratorExpression ge(this->CMakeInstance, entry.Backtrace);
auto cge = ge.Parse(ex);
result.push_back(std::move(cge));
}
diff --git a/Source/cmFileSet.h b/Source/cmFileSet.h
index 5357e77..54d430c 100644
--- a/Source/cmFileSet.h
+++ b/Source/cmFileSet.h
@@ -17,6 +17,7 @@ struct cmGeneratorExpressionDAGChecker;
class cmGeneratorTarget;
class cmLocalGenerator;
class cmMakefile;
+class cmake;
enum class cmFileSetVisibility
{
@@ -33,7 +34,7 @@ bool cmFileSetVisibilityIsForInterface(cmFileSetVisibility vis);
class cmFileSet
{
public:
- cmFileSet(std::string name, std::string type,
+ cmFileSet(cmake& cmakeInstance, std::string name, std::string type,
cmFileSetVisibility visibility);
const std::string& GetName() const { return this->Name; }
@@ -77,6 +78,7 @@ public:
static bool IsValidName(const std::string& name);
private:
+ cmake& CMakeInstance;
std::string Name;
std::string Type;
cmFileSetVisibility Visibility;
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index f988e54..21ace89 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -13,11 +13,15 @@
#include "cmGeneratorExpressionEvaluator.h"
#include "cmGeneratorExpressionLexer.h"
#include "cmGeneratorExpressionParser.h"
+#include "cmLocalGenerator.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
+#include "cmake.h"
-cmGeneratorExpression::cmGeneratorExpression(cmListFileBacktrace backtrace)
- : Backtrace(std::move(backtrace))
+cmGeneratorExpression::cmGeneratorExpression(cmake& cmakeInstance,
+ cmListFileBacktrace backtrace)
+ : CMakeInstance(cmakeInstance)
+ , Backtrace(std::move(backtrace))
{
}
@@ -29,7 +33,8 @@ std::unique_ptr<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse(
std::string input) const
{
return std::unique_ptr<cmCompiledGeneratorExpression>(
- new cmCompiledGeneratorExpression(this->Backtrace, std::move(input)));
+ new cmCompiledGeneratorExpression(this->CMakeInstance, this->Backtrace,
+ std::move(input)));
}
std::string cmGeneratorExpression::Evaluate(
@@ -39,7 +44,13 @@ std::string cmGeneratorExpression::Evaluate(
cmGeneratorTarget const* currentTarget, std::string const& language)
{
if (Find(input) != std::string::npos) {
- cmCompiledGeneratorExpression cge(cmListFileBacktrace(), std::move(input));
+#ifndef CMAKE_BOOTSTRAP
+ auto profilingRAII = lg->GetCMakeInstance()->CreateProfilingEntry(
+ "genex_compile_eval", input);
+#endif
+
+ cmCompiledGeneratorExpression cge(*lg->GetCMakeInstance(),
+ cmListFileBacktrace(), std::move(input));
return cge.Evaluate(lg, config, headTarget, dagChecker, currentTarget,
language);
}
@@ -97,10 +108,15 @@ const std::string& cmCompiledGeneratorExpression::EvaluateWithContext(
}
cmCompiledGeneratorExpression::cmCompiledGeneratorExpression(
- cmListFileBacktrace backtrace, std::string input)
+ cmake& cmakeInstance, cmListFileBacktrace backtrace, std::string input)
: Backtrace(std::move(backtrace))
, Input(std::move(input))
{
+#ifndef CMAKE_BOOTSTRAP
+ auto profilingRAII =
+ cmakeInstance.CreateProfilingEntry("genex_compile", this->Input);
+#endif
+
cmGeneratorExpressionLexer l;
std::vector<cmGeneratorExpressionToken> tokens = l.Tokenize(this->Input);
this->NeedsEvaluation = l.GetSawGeneratorExpression();
diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h
index 188993f..e22b8ab 100644
--- a/Source/cmGeneratorExpression.h
+++ b/Source/cmGeneratorExpression.h
@@ -12,10 +12,11 @@
#include <vector>
#include "cmListFileCache.h"
+#include "cmLocalGenerator.h"
+class cmake;
class cmCompiledGeneratorExpression;
class cmGeneratorTarget;
-class cmLocalGenerator;
struct cmGeneratorExpressionContext;
struct cmGeneratorExpressionDAGChecker;
struct cmGeneratorExpressionEvaluator;
@@ -33,7 +34,8 @@ class cmGeneratorExpression
{
public:
/** Construct. */
- cmGeneratorExpression(cmListFileBacktrace backtrace = cmListFileBacktrace());
+ cmGeneratorExpression(cmake& cmakeInstance,
+ cmListFileBacktrace backtrace = cmListFileBacktrace());
~cmGeneratorExpression();
cmGeneratorExpression(cmGeneratorExpression const&) = delete;
@@ -82,6 +84,7 @@ public:
const std::string& replacement);
private:
+ cmake& CMakeInstance;
cmListFileBacktrace Backtrace;
};
@@ -152,7 +155,8 @@ private:
cmGeneratorExpressionContext& context,
cmGeneratorExpressionDAGChecker* dagChecker) const;
- cmCompiledGeneratorExpression(cmListFileBacktrace backtrace,
+ cmCompiledGeneratorExpression(cmake& cmakeInstance,
+ cmListFileBacktrace backtrace,
std::string input);
friend class cmGeneratorExpression;
@@ -184,7 +188,8 @@ public:
std::string config,
cmGeneratorTarget const* headTarget,
std::string language = std::string())
- : LocalGenerator(localGenerator)
+ : GeneratorExpression(*localGenerator->GetCMakeInstance())
+ , LocalGenerator(localGenerator)
, Config(std::move(config))
, HeadTarget(headTarget)
, Language(std::move(language))
diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx
index 8f3ed4d..817437e 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.cxx
+++ b/Source/cmGeneratorExpressionEvaluationFile.cxx
@@ -165,7 +165,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg)
}
cmListFileBacktrace lfbt = this->OutputFileExpr->GetBacktrace();
- cmGeneratorExpression contentGE(lfbt);
+ cmGeneratorExpression contentGE(*lg->GetCMakeInstance(), lfbt);
std::unique_ptr<cmCompiledGeneratorExpression> inputExpression =
contentGE.Parse(inputContent);
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index fec309c..b239408 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -4,8 +4,14 @@
#include <sstream>
+#ifndef CMAKE_BOOTSTRAP
+# include <cm3p/json/value.h>
+#endif
+
#include "cmGeneratorExpressionContext.h"
#include "cmGeneratorExpressionNode.h"
+#include "cmLocalGenerator.h"
+#include "cmake.h"
GeneratorExpressionContent::GeneratorExpressionContent(
const char* startContent, size_t length)
@@ -61,6 +67,12 @@ std::string GeneratorExpressionContent::Evaluate(
cmGeneratorExpressionContext* context,
cmGeneratorExpressionDAGChecker* dagChecker) const
{
+#ifndef CMAKE_BOOTSTRAP
+ auto evalProfilingRAII =
+ context->LG->GetCMakeInstance()->CreateProfilingEntry(
+ "genex_eval", this->GetOriginalExpression());
+#endif
+
std::string identifier;
{
for (const auto& pExprEval : this->IdentifierChildren) {
@@ -101,7 +113,24 @@ std::string GeneratorExpressionContent::Evaluate(
return std::string();
}
- return node->Evaluate(parameters, context, this, dagChecker);
+ {
+#ifndef CMAKE_BOOTSTRAP
+ auto execProfilingRAII =
+ context->LG->GetCMakeInstance()->CreateProfilingEntry(
+ "genex_exec", identifier, [&parameters]() -> Json::Value {
+ Json::Value args = Json::objectValue;
+ if (!parameters.empty()) {
+ args["genexArgs"] = Json::arrayValue;
+ for (auto const& parameter : parameters) {
+ args["genexArgs"].append(parameter);
+ }
+ }
+ return args;
+ });
+#endif
+
+ return node->Evaluate(parameters, context, this, dagChecker);
+ }
}
std::string GeneratorExpressionContent::EvaluateParameters(
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 45d5a83..562c31e 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -57,7 +57,7 @@ std::string cmGeneratorExpressionNode::EvaluateDependentExpression(
cmGeneratorExpressionDAGChecker* dagChecker,
cmGeneratorTarget const* currentTarget)
{
- cmGeneratorExpression ge(context->Backtrace);
+ cmGeneratorExpression ge(*lg->GetCMakeInstance(), context->Backtrace);
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
cge->SetEvaluateForBuildsystem(context->EvaluateForBuildsystem);
cge->SetQuiet(context->Quiet);
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index becf244..6065285 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -241,15 +241,16 @@ private:
std::unique_ptr<
cmGeneratorTarget::
- TargetPropertyEntry> static CreateTargetPropertyEntry(const BT<std::
- string>&
+ TargetPropertyEntry> static CreateTargetPropertyEntry(cmake& cmakeInstance,
+ const BT<
+ std::string>&
propertyValue,
bool
evaluateForBuildsystem =
false)
{
if (cmGeneratorExpression::Find(propertyValue.Value) != std::string::npos) {
- cmGeneratorExpression ge(propertyValue.Backtrace);
+ cmGeneratorExpression ge(cmakeInstance, propertyValue.Backtrace);
std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(propertyValue.Value);
cge->SetEvaluateForBuildsystem(evaluateForBuildsystem);
@@ -262,12 +263,13 @@ std::unique_ptr<
}
static void CreatePropertyGeneratorExpressions(
- cmBTStringRange entries,
+ cmake& cmakeInstance, cmBTStringRange entries,
std::vector<std::unique_ptr<cmGeneratorTarget::TargetPropertyEntry>>& items,
bool evaluateForBuildsystem = false)
{
for (auto const& entry : entries) {
- items.push_back(CreateTargetPropertyEntry(entry, evaluateForBuildsystem));
+ items.push_back(
+ CreateTargetPropertyEntry(cmakeInstance, entry, evaluateForBuildsystem));
}
}
@@ -343,29 +345,36 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg)
this->GlobalGenerator->ComputeTargetObjectDirectory(this);
- CreatePropertyGeneratorExpressions(t->GetIncludeDirectoriesEntries(),
+ CreatePropertyGeneratorExpressions(*lg->GetCMakeInstance(),
+ t->GetIncludeDirectoriesEntries(),
this->IncludeDirectoriesEntries);
- CreatePropertyGeneratorExpressions(t->GetCompileOptionsEntries(),
+ CreatePropertyGeneratorExpressions(*lg->GetCMakeInstance(),
+ t->GetCompileOptionsEntries(),
this->CompileOptionsEntries);
- CreatePropertyGeneratorExpressions(t->GetCompileFeaturesEntries(),
+ CreatePropertyGeneratorExpressions(*lg->GetCMakeInstance(),
+ t->GetCompileFeaturesEntries(),
this->CompileFeaturesEntries);
- CreatePropertyGeneratorExpressions(t->GetCompileDefinitionsEntries(),
+ CreatePropertyGeneratorExpressions(*lg->GetCMakeInstance(),
+ t->GetCompileDefinitionsEntries(),
this->CompileDefinitionsEntries);
- CreatePropertyGeneratorExpressions(t->GetLinkOptionsEntries(),
+ CreatePropertyGeneratorExpressions(*lg->GetCMakeInstance(),
+ t->GetLinkOptionsEntries(),
this->LinkOptionsEntries);
- CreatePropertyGeneratorExpressions(t->GetLinkDirectoriesEntries(),
+ CreatePropertyGeneratorExpressions(*lg->GetCMakeInstance(),
+ t->GetLinkDirectoriesEntries(),
this->LinkDirectoriesEntries);
- CreatePropertyGeneratorExpressions(t->GetPrecompileHeadersEntries(),
+ CreatePropertyGeneratorExpressions(*lg->GetCMakeInstance(),
+ t->GetPrecompileHeadersEntries(),
this->PrecompileHeadersEntries);
- CreatePropertyGeneratorExpressions(t->GetSourceEntries(),
- this->SourceEntries, true);
+ CreatePropertyGeneratorExpressions(
+ *lg->GetCMakeInstance(), t->GetSourceEntries(), this->SourceEntries, true);
this->PolicyMap = t->GetPolicyMap();
@@ -753,6 +762,7 @@ void cmGeneratorTarget::AddSourceCommon(const std::string& src, bool before)
this->SourceEntries.insert(
before ? this->SourceEntries.begin() : this->SourceEntries.end(),
CreateTargetPropertyEntry(
+ *this->LocalGenerator->GetCMakeInstance(),
BT<std::string>(src, this->Makefile->GetBacktrace()), true));
this->ClearSourcesCache();
}
@@ -780,6 +790,7 @@ void cmGeneratorTarget::AddIncludeDirectory(const std::string& src,
before ? this->IncludeDirectoriesEntries.begin()
: this->IncludeDirectoriesEntries.end(),
CreateTargetPropertyEntry(
+ *this->Makefile->GetCMakeInstance(),
BT<std::string>(src, this->Makefile->GetBacktrace()), true));
}
@@ -1653,7 +1664,8 @@ void AddObjectEntries(cmGeneratorTarget const* headTarget,
headTarget->GetGlobalGenerator()->IndexGeneratorTargetUniquely(
lib.Target);
std::string genex = "$<TARGET_OBJECTS:" + std::move(uniqueName) + ">";
- cmGeneratorExpression ge(lib.Backtrace);
+ cmGeneratorExpression ge(*headTarget->Makefile->GetCMakeInstance(),
+ lib.Backtrace);
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(genex);
cge->SetEvaluateForBuildsystem(true);
@@ -4192,7 +4204,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileDefinitions(
}
case cmPolicies::OLD: {
std::unique_ptr<TargetPropertyEntry> entry =
- CreateTargetPropertyEntry(*configProp);
+ CreateTargetPropertyEntry(
+ *this->LocalGenerator->GetCMakeInstance(), *configProp);
entries.Entries.emplace_back(EvaluateTargetPropertyEntry(
this, config, language, &dagChecker, *entry));
} break;
@@ -4778,8 +4791,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetStaticLibraryLinkOptions(
if (cmValue linkOptions = this->GetProperty("STATIC_LIBRARY_OPTIONS")) {
std::vector<std::string> options = cmExpandedList(*linkOptions);
for (const auto& option : options) {
- std::unique_ptr<TargetPropertyEntry> entry =
- CreateTargetPropertyEntry(option);
+ std::unique_ptr<TargetPropertyEntry> entry = CreateTargetPropertyEntry(
+ *this->LocalGenerator->GetCMakeInstance(), option);
entries.Entries.emplace_back(EvaluateTargetPropertyEntry(
this, config, language, &dagChecker, *entry));
}
@@ -4931,8 +4944,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkDepends(
if (cmValue linkDepends = this->GetProperty("LINK_DEPENDS")) {
std::vector<std::string> depends = cmExpandedList(*linkDepends);
for (const auto& depend : depends) {
- std::unique_ptr<TargetPropertyEntry> entry =
- CreateTargetPropertyEntry(depend);
+ std::unique_ptr<TargetPropertyEntry> entry = CreateTargetPropertyEntry(
+ *this->LocalGenerator->GetCMakeInstance(), depend);
entries.Entries.emplace_back(EvaluateTargetPropertyEntry(
this, config, language, &dagChecker, *entry));
}
@@ -6756,7 +6769,8 @@ void cmGeneratorTarget::ExpandLinkItems(
cmMakefile const* mf = this->LocalGenerator->GetMakefile();
LookupLinkItemScope scope{ this->LocalGenerator };
for (BT<std::string> const& entry : entries) {
- cmGeneratorExpression ge(entry.Backtrace);
+ cmGeneratorExpression ge(*this->LocalGenerator->GetCMakeInstance(),
+ entry.Backtrace);
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(entry.Value);
cge->SetEvaluateForBuildsystem(true);
std::vector<std::string> libs = cmExpandedList(
@@ -8195,7 +8209,8 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
break;
}
}
- cmGeneratorExpression ge(entry.Backtrace);
+ cmGeneratorExpression ge(*this->LocalGenerator->GetCMakeInstance(),
+ entry.Backtrace);
std::unique_ptr<cmCompiledGeneratorExpression> const cge =
ge.Parse(entry.Value);
cge->SetEvaluateForBuildsystem(true);
diff --git a/Source/cmInstalledFile.cxx b/Source/cmInstalledFile.cxx
index 0974eea..5bf8320 100644
--- a/Source/cmInstalledFile.cxx
+++ b/Source/cmInstalledFile.cxx
@@ -21,7 +21,7 @@ cmInstalledFile::Property::~Property() = default;
void cmInstalledFile::SetName(cmMakefile* mf, const std::string& name)
{
cmListFileBacktrace backtrace = mf->GetBacktrace();
- cmGeneratorExpression ge(backtrace);
+ cmGeneratorExpression ge(*mf->GetCMakeInstance(), backtrace);
this->Name = name;
this->NameExpression = ge.Parse(name);
@@ -56,7 +56,7 @@ void cmInstalledFile::AppendProperty(cmMakefile const* mf,
bool /*asString*/)
{
cmListFileBacktrace backtrace = mf->GetBacktrace();
- cmGeneratorExpression ge(backtrace);
+ cmGeneratorExpression ge(*mf->GetCMakeInstance(), backtrace);
Property& property = this->Properties[prop];
property.ValueExpressions.push_back(ge.Parse(value));
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index fb269b2..31c6504 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -4503,7 +4503,7 @@ std::vector<std::string> cmLocalGenerator::ExpandCustomCommandOutputGenex(
std::string const& o, cmListFileBacktrace const& bt)
{
std::vector<std::string> allConfigOutputs;
- cmGeneratorExpression ge(bt);
+ cmGeneratorExpression ge(*this->GetCMakeInstance(), bt);
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(o);
std::vector<std::string> configs =
this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index c11f5b4..1e2ea2a 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -701,7 +701,7 @@ bool cmLocalNinjaGenerator::HasUniqueByproducts(
{
std::vector<std::string> configs =
this->GetMakefile()->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
- cmGeneratorExpression ge(bt);
+ cmGeneratorExpression ge(*this->GetCMakeInstance(), bt);
for (std::string const& p : byproducts) {
if (cmGeneratorExpression::Find(p) == std::string::npos) {
return false;
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 2091f27..db8f785 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -376,7 +376,20 @@ public:
this->Makefile->ExecutionStatusStack.push_back(&status);
#if !defined(CMAKE_BOOTSTRAP)
this->ProfilingDataRAII =
- this->Makefile->GetCMakeInstance()->CreateProfilingEntry(lff, lfc);
+ this->Makefile->GetCMakeInstance()->CreateProfilingEntry(
+ "script", lff.LowerCaseName(), [&lff, &lfc]() -> Json::Value {
+ Json::Value argsValue = Json::objectValue;
+ if (!lff.Arguments().empty()) {
+ std::string args;
+ for (auto const& a : lff.Arguments()) {
+ args = cmStrCat(args, args.empty() ? "" : " ", a.Value);
+ }
+ argsValue["functionArgs"] = args;
+ }
+ argsValue["location"] =
+ cmStrCat(lfc.FilePath, ':', std::to_string(lfc.Line));
+ return argsValue;
+ });
#endif
}
diff --git a/Source/cmMakefileProfilingData.cxx b/Source/cmMakefileProfilingData.cxx
index e4844f3..e903ae1 100644
--- a/Source/cmMakefileProfilingData.cxx
+++ b/Source/cmMakefileProfilingData.cxx
@@ -6,9 +6,6 @@
#include <stdexcept>
#include <type_traits>
#include <utility>
-#include <vector>
-
-#include <cm/utility>
#include <cm3p/json/value.h>
#include <cm3p/json/writer.h>
@@ -16,7 +13,6 @@
#include "cmsys/FStream.hxx"
#include "cmsys/SystemInformation.hxx"
-#include "cmListFileCache.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
@@ -47,22 +43,6 @@ cmMakefileProfilingData::~cmMakefileProfilingData() noexcept
}
}
-void cmMakefileProfilingData::StartEntry(const cmListFileFunction& lff,
- cmListFileContext const& lfc)
-{
- cm::optional<Json::Value> argsValue(cm::in_place, Json::objectValue);
- if (!lff.Arguments().empty()) {
- std::string args;
- for (auto const& a : lff.Arguments()) {
- args = cmStrCat(args, args.empty() ? "" : " ", a.Value);
- }
- (*argsValue)["functionArgs"] = args;
- }
- (*argsValue)["location"] =
- cmStrCat(lfc.FilePath, ':', std::to_string(lfc.Line));
- this->StartEntry("script", lff.LowerCaseName(), std::move(argsValue));
-}
-
void cmMakefileProfilingData::StartEntry(const std::string& category,
const std::string& name,
cm::optional<Json::Value> args)
@@ -127,6 +107,15 @@ void cmMakefileProfilingData::StopEntry()
}
}
+cmMakefileProfilingData::RAII::RAII(cmMakefileProfilingData& data,
+ const std::string& category,
+ const std::string& name,
+ cm::optional<Json::Value> args)
+ : Data(&data)
+{
+ this->Data->StartEntry(category, name, std::move(args));
+}
+
cmMakefileProfilingData::RAII::RAII(RAII&& other) noexcept
: Data(other.Data)
{
diff --git a/Source/cmMakefileProfilingData.h b/Source/cmMakefileProfilingData.h
index e8d7dfa..4cf0bfa 100644
--- a/Source/cmMakefileProfilingData.h
+++ b/Source/cmMakefileProfilingData.h
@@ -3,7 +3,6 @@
#pragma once
#include <memory>
#include <string>
-#include <utility>
#include <cm/optional>
@@ -15,15 +14,11 @@ namespace Json {
class StreamWriter;
}
-class cmListFileContext;
-class cmListFileFunction;
-
class cmMakefileProfilingData
{
public:
cmMakefileProfilingData(const std::string&);
~cmMakefileProfilingData() noexcept;
- void StartEntry(const cmListFileFunction& lff, cmListFileContext const& lfc);
void StartEntry(const std::string& category, const std::string& name,
cm::optional<Json::Value> args = cm::nullopt);
void StopEntry();
@@ -35,12 +30,9 @@ public:
RAII(const RAII&) = delete;
RAII(RAII&&) noexcept;
- template <typename... Args>
- RAII(cmMakefileProfilingData& data, Args&&... args)
- : Data(&data)
- {
- this->Data->StartEntry(std::forward<Args>(args)...);
- }
+ RAII(cmMakefileProfilingData& data, const std::string& category,
+ const std::string& name,
+ cm::optional<Json::Value> args = cm::nullopt);
~RAII();
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index 96649ab..6f78a46 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -2095,7 +2095,7 @@ bool cmQtAutoGenInitializer::GetQtExecutable(GenVarsT& genVars,
// Evaluate generator expression
{
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
- cmGeneratorExpression ge(lfbt);
+ cmGeneratorExpression ge(*this->Makefile->GetCMakeInstance(), lfbt);
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(val);
genVars.Executable = cge->Evaluate(this->LocalGen, "");
}
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 874195b..2955d7c 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -2656,8 +2656,9 @@ cmFileSet* cmTarget::GetFileSet(const std::string& name)
std::pair<cmFileSet*, bool> cmTarget::GetOrCreateFileSet(
const std::string& name, const std::string& type, cmFileSetVisibility vis)
{
- auto result = this->impl->FileSets.emplace(
- std::make_pair(name, cmFileSet(name, type, vis)));
+ auto result = this->impl->FileSets.emplace(std::make_pair(
+ name,
+ cmFileSet(*this->GetMakefile()->GetCMakeInstance(), name, type, vis)));
if (result.second) {
auto bt = this->impl->Makefile->GetBacktrace();
if (type == this->impl->HeadersFileSets.TypeName) {
diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx
index dbb0876..5e325dd 100644
--- a/Source/cmTestGenerator.cxx
+++ b/Source/cmTestGenerator.cxx
@@ -127,7 +127,8 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
this->TestGenerated = true;
// Set up generator expression evaluation context.
- cmGeneratorExpression ge(this->Test->GetBacktrace());
+ cmGeneratorExpression ge(*this->Test->GetMakefile()->GetCMakeInstance(),
+ this->Test->GetBacktrace());
// Determine if policy CMP0110 is set to NEW.
const bool quote_test_name =
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 9393389..7e43bee 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2090,7 +2090,7 @@ void cmVisualStudio10TargetGenerator::ParseSettingsProperty(
const std::string& settingsPropertyValue, ConfigToSettings& toolSettings)
{
if (!settingsPropertyValue.empty()) {
- cmGeneratorExpression ge;
+ cmGeneratorExpression ge(*this->LocalGenerator->GetCMakeInstance());
std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(settingsPropertyValue);
@@ -2190,7 +2190,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(
}
// Figure out if there's any additional flags to use
if (cmValue saf = sf->GetProperty("VS_SHADER_FLAGS")) {
- cmGeneratorExpression ge;
+ cmGeneratorExpression ge(*this->LocalGenerator->GetCMakeInstance());
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*saf);
for (const std::string& config : this->Configurations) {
@@ -2203,7 +2203,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(
}
// Figure out if debug information should be generated
if (cmValue sed = sf->GetProperty("VS_SHADER_ENABLE_DEBUG")) {
- cmGeneratorExpression ge;
+ cmGeneratorExpression ge(*this->LocalGenerator->GetCMakeInstance());
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*sed);
for (const std::string& config : this->Configurations) {
@@ -2217,7 +2217,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(
}
// Figure out if optimizations should be disabled
if (cmValue sdo = sf->GetProperty("VS_SHADER_DISABLE_OPTIMIZATIONS")) {
- cmGeneratorExpression ge;
+ cmGeneratorExpression ge(*this->LocalGenerator->GetCMakeInstance());
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*sdo);
for (const std::string& config : this->Configurations) {
@@ -2331,7 +2331,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(
this->FinishWritingSource(e2, toolSettings);
if (!deployContent.empty()) {
- cmGeneratorExpression ge;
+ cmGeneratorExpression ge(*this->LocalGenerator->GetCMakeInstance());
std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(deployContent);
// Deployment location cannot be set on a configuration basis
diff --git a/Source/cmake.h b/Source/cmake.h
index 2f7f7bd..6b585a1 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -638,13 +638,20 @@ public:
cmMakefileProfilingData& GetProfilingOutput();
bool IsProfilingEnabled() const;
- template <typename... Args>
cm::optional<cmMakefileProfilingData::RAII> CreateProfilingEntry(
- Args&&... args)
+ const std::string& category, const std::string& name)
+ {
+ return this->CreateProfilingEntry(
+ category, name, []() -> cm::nullopt_t { return cm::nullopt; });
+ }
+
+ template <typename ArgsFunc>
+ cm::optional<cmMakefileProfilingData::RAII> CreateProfilingEntry(
+ const std::string& category, const std::string& name, ArgsFunc&& argsFunc)
{
if (this->IsProfilingEnabled()) {
return cm::make_optional<cmMakefileProfilingData::RAII>(
- this->GetProfilingOutput(), std::forward<Args>(args)...);
+ this->GetProfilingOutput(), category, name, argsFunc());
}
return cm::nullopt;
}