mirror of
https://github.com/Kitware/CMake.git
synced 2026-07-08 23:57:29 +00:00
cmCustomCommandGenerator: Collect genex target references in commands
These will become target-level dependencies.
This commit is contained in:
@@ -62,6 +62,10 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
|
||||
for (std::string const& clarg : cmdline) {
|
||||
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(clarg);
|
||||
std::string parsed_arg = cge->Evaluate(this->LG, this->Config);
|
||||
for (cmGeneratorTarget* gt : cge->GetTargets()) {
|
||||
this->Utilities.emplace(BT<std::pair<std::string, bool>>(
|
||||
{ gt->GetName(), true }, cge->GetBacktrace()));
|
||||
}
|
||||
if (this->CC->GetCommandExpandLists()) {
|
||||
cm::append(argv, cmExpandedList(parsed_arg));
|
||||
} else {
|
||||
@@ -69,10 +73,18 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
|
||||
}
|
||||
}
|
||||
|
||||
// Later code assumes at least one entry exists, but expanding
|
||||
// lists on an empty command may have left this empty.
|
||||
// FIXME: Should we define behavior for removing empty commands?
|
||||
if (argv.empty()) {
|
||||
if (!argv.empty()) {
|
||||
// If the command references an executable target by name,
|
||||
// collect the target to add a target-level dependency on it.
|
||||
cmGeneratorTarget* gt = this->LG->FindGeneratorTargetToUse(argv.front());
|
||||
if (gt && gt->GetType() == cmStateEnums::EXECUTABLE) {
|
||||
this->Utilities.emplace(BT<std::pair<std::string, bool>>(
|
||||
{ gt->GetName(), true }, cc.GetBacktrace()));
|
||||
}
|
||||
} else {
|
||||
// Later code assumes at least one entry exists, but expanding
|
||||
// lists on an empty command may have left this empty.
|
||||
// FIXME: Should we define behavior for removing empty commands?
|
||||
argv.emplace_back();
|
||||
}
|
||||
|
||||
@@ -326,3 +338,9 @@ std::vector<std::string> const& cmCustomCommandGenerator::GetDepends() const
|
||||
{
|
||||
return this->Depends;
|
||||
}
|
||||
|
||||
std::set<BT<std::pair<std::string, bool>>> const&
|
||||
cmCustomCommandGenerator::GetUtilities() const
|
||||
{
|
||||
return this->Utilities;
|
||||
}
|
||||
|
||||
@@ -4,10 +4,13 @@
|
||||
|
||||
#include "cmConfigure.h" // IWYU pragma: keep
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "cmCustomCommandLines.h"
|
||||
#include "cmListFileCache.h"
|
||||
|
||||
class cmCustomCommand;
|
||||
class cmLocalGenerator;
|
||||
@@ -24,6 +27,7 @@ class cmCustomCommandGenerator
|
||||
std::vector<std::string> Byproducts;
|
||||
std::vector<std::string> Depends;
|
||||
std::string WorkingDirectory;
|
||||
std::set<BT<std::pair<std::string, bool>>> Utilities;
|
||||
|
||||
void FillEmulatorsWithArguments();
|
||||
std::vector<std::string> GetCrossCompilingEmulator(unsigned int c) const;
|
||||
@@ -46,6 +50,7 @@ public:
|
||||
std::vector<std::string> const& GetOutputs() const;
|
||||
std::vector<std::string> const& GetByproducts() const;
|
||||
std::vector<std::string> const& GetDepends() const;
|
||||
std::set<BT<std::pair<std::string, bool>>> const& GetUtilities() const;
|
||||
bool HasOnlyEmptyCommandLines() const;
|
||||
std::string GetFullDepfile() const;
|
||||
std::string GetInternalDepfile() const;
|
||||
|
||||
Reference in New Issue
Block a user