mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-23 07:28:51 -06:00
cmMakefile: Drop unnecessary custom command APPEND check
Since commit 777ceaea94 (cmMakefile: Delay custom command creation,
2019-10-17, v3.17.0-rc1~352^2) we process custom command declarations
at generate time. This includes the append-to-non-existing-command
check, so we do not need it at configure time.
This commit is contained in:
@@ -314,16 +314,9 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
|
||||
|
||||
// Check for an append request.
|
||||
if (append) {
|
||||
if (mf.AppendCustomCommandToOutput(output[0], depends, implicit_depends,
|
||||
commandLines)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// No command for this output exists.
|
||||
status.SetError(
|
||||
cmStrCat("given APPEND option with output\n ", output[0],
|
||||
"\nwhich is not already a custom command output."));
|
||||
return false;
|
||||
mf.AppendCustomCommandToOutput(output[0], depends, implicit_depends,
|
||||
commandLines);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (uses_terminal && !job_pool.empty()) {
|
||||
|
||||
@@ -4008,7 +4008,7 @@ void AppendCustomCommandToOutput(cmLocalGenerator& lg,
|
||||
// No existing command found.
|
||||
lg.GetCMakeInstance()->IssueMessage(
|
||||
MessageType::FATAL_ERROR,
|
||||
cmStrCat("Attempt to append to output\n ", output,
|
||||
cmStrCat("Attempt to APPEND to custom command with output\n ", output,
|
||||
"\nwhich is not already a custom command output."),
|
||||
lfbt);
|
||||
}
|
||||
|
||||
@@ -939,8 +939,6 @@ void cmMakefile::DoGenerate(cmLocalGenerator& lg)
|
||||
action.Value(lg, action.Backtrace);
|
||||
}
|
||||
this->GeneratorActionsInvoked = true;
|
||||
this->DelayedOutputFiles.clear();
|
||||
this->DelayedOutputFilesHaveGenex = false;
|
||||
|
||||
// go through all configured files and see which ones still exist.
|
||||
// we don't want cmake to re-run if a configured file is created and deleted
|
||||
@@ -1247,16 +1245,11 @@ void cmMakefile::AddCustomCommandOldStyle(
|
||||
}
|
||||
}
|
||||
|
||||
bool cmMakefile::AppendCustomCommandToOutput(
|
||||
void cmMakefile::AppendCustomCommandToOutput(
|
||||
const std::string& output, const std::vector<std::string>& depends,
|
||||
const cmImplicitDependsList& implicit_depends,
|
||||
const cmCustomCommandLines& commandLines)
|
||||
{
|
||||
// Check as good as we can if there will be a command for this output.
|
||||
if (!this->MightHaveCustomCommand(output)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate custom commands.
|
||||
if (this->ValidateCustomCommand(commandLines)) {
|
||||
// Dispatch command creation to allow generator expressions in outputs.
|
||||
@@ -1267,8 +1260,6 @@ bool cmMakefile::AppendCustomCommandToOutput(
|
||||
implicit_depends, commandLines);
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
cmUtilityOutput cmMakefile::GetUtilityOutput(cmTarget* target)
|
||||
@@ -2271,26 +2262,6 @@ cmSourceFile* cmMakefile::GetSourceFileWithOutput(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool cmMakefile::MightHaveCustomCommand(const std::string& name) const
|
||||
{
|
||||
if (this->DelayedOutputFilesHaveGenex ||
|
||||
cmGeneratorExpression::Find(name) != std::string::npos) {
|
||||
// Could be more restrictive, but for now we assume that there could always
|
||||
// be a match when generator expressions are involved.
|
||||
return true;
|
||||
}
|
||||
// Also see LinearGetSourceFileWithOutput.
|
||||
if (!cmSystemTools::FileIsFullPath(name)) {
|
||||
return AnyOutputMatches(name, this->DelayedOutputFiles);
|
||||
}
|
||||
// Otherwise we use an efficient lookup map.
|
||||
auto o = this->OutputToSource.find(name);
|
||||
if (o != this->OutputToSource.end()) {
|
||||
return o->second.SourceMightBeOutput;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void cmMakefile::AddTargetByproducts(
|
||||
cmTarget* target, const std::vector<std::string>& byproducts)
|
||||
{
|
||||
@@ -2339,7 +2310,6 @@ void cmMakefile::UpdateOutputToSourceMap(std::string const& output,
|
||||
SourceEntry entry;
|
||||
entry.Sources.Source = source;
|
||||
entry.Sources.SourceIsByproduct = byproduct;
|
||||
entry.SourceMightBeOutput = !byproduct;
|
||||
|
||||
auto pr = this->OutputToSource.emplace(output, entry);
|
||||
if (!pr.second) {
|
||||
@@ -2349,7 +2319,6 @@ void cmMakefile::UpdateOutputToSourceMap(std::string const& output,
|
||||
(current.Sources.SourceIsByproduct && !byproduct)) {
|
||||
current.Sources.Source = source;
|
||||
current.Sources.SourceIsByproduct = false;
|
||||
current.SourceMightBeOutput = true;
|
||||
} else {
|
||||
// Multiple custom commands produce the same output but may
|
||||
// be attached to a different source file (MAIN_DEPENDENCY).
|
||||
@@ -3676,9 +3645,6 @@ void cmMakefile::CreateGeneratedOutputs(
|
||||
for (std::string const& o : outputs) {
|
||||
if (cmGeneratorExpression::Find(o) == std::string::npos) {
|
||||
this->GetOrCreateGeneratedSource(o);
|
||||
this->AddDelayedOutput(o);
|
||||
} else {
|
||||
this->DelayedOutputFilesHaveGenex = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3693,21 +3659,6 @@ void cmMakefile::CreateGeneratedByproducts(
|
||||
}
|
||||
}
|
||||
|
||||
void cmMakefile::AddDelayedOutput(std::string const& output)
|
||||
{
|
||||
// Note that this vector might contain the output names in a different order
|
||||
// than in source file iteration order.
|
||||
this->DelayedOutputFiles.push_back(output);
|
||||
|
||||
SourceEntry entry;
|
||||
entry.SourceMightBeOutput = true;
|
||||
|
||||
auto pr = this->OutputToSource.emplace(output, entry);
|
||||
if (!pr.second) {
|
||||
pr.first->second.SourceMightBeOutput = true;
|
||||
}
|
||||
}
|
||||
|
||||
void cmMakefile::AddTargetObject(std::string const& tgtName,
|
||||
std::string const& objFile)
|
||||
{
|
||||
|
||||
@@ -225,7 +225,7 @@ public:
|
||||
const std::string& source,
|
||||
const cmCustomCommandLines& commandLines,
|
||||
const char* comment);
|
||||
bool AppendCustomCommandToOutput(
|
||||
void AppendCustomCommandToOutput(
|
||||
const std::string& output, const std::vector<std::string>& depends,
|
||||
const cmImplicitDependsList& implicit_depends,
|
||||
const cmCustomCommandLines& commandLines);
|
||||
@@ -1133,10 +1133,6 @@ private:
|
||||
|
||||
std::vector<BT<GeneratorAction>> GeneratorActions;
|
||||
bool GeneratorActionsInvoked = false;
|
||||
bool DelayedOutputFilesHaveGenex = false;
|
||||
std::vector<std::string> DelayedOutputFiles;
|
||||
|
||||
void AddDelayedOutput(std::string const& output);
|
||||
|
||||
/**
|
||||
* See LinearGetSourceFileWithOutput for background information
|
||||
@@ -1156,7 +1152,6 @@ private:
|
||||
struct SourceEntry
|
||||
{
|
||||
cmSourcesWithOutput Sources;
|
||||
bool SourceMightBeOutput = false;
|
||||
};
|
||||
|
||||
// A map for fast output to input look up.
|
||||
@@ -1167,11 +1162,6 @@ private:
|
||||
void UpdateOutputToSourceMap(std::string const& output, cmSourceFile* source,
|
||||
bool byproduct);
|
||||
|
||||
/**
|
||||
* Return if the provided source file might have a custom command.
|
||||
*/
|
||||
bool MightHaveCustomCommand(const std::string& name) const;
|
||||
|
||||
bool CheckSystemVars;
|
||||
bool CheckCMP0000;
|
||||
std::set<std::string> WarnedCMP0074;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
CMake Error at AppendNotOutput.cmake:1 \(add_custom_command\):
|
||||
add_custom_command given APPEND option with output
|
||||
Attempt to APPEND to custom command with output
|
||||
|
||||
.*RunCMake/add_custom_command/AppendNotOutput-build/out
|
||||
|
||||
|
||||
Reference in New Issue
Block a user