summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx48
1 files changed, 20 insertions, 28 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 5f83746..16cc453 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -859,7 +859,7 @@ void cmMakefile::AddCustomCommandToTarget(
e << "No TARGET '" << target
<< "' has been created in this directory.";
}
- IssueMessage(messageType, e.str());
+ this->IssueMessage(messageType, e.str());
}
return;
@@ -885,11 +885,7 @@ void cmMakefile::AddCustomCommandToTarget(
}
// Always create the byproduct sources and mark them generated.
- for (std::string const& o : byproducts) {
- if (cmSourceFile* out = this->GetOrCreateSource(o, true)) {
- out->SetProperty("GENERATED", "1");
- }
- }
+ this->CreateGeneratedSources(byproducts);
// Add the command to the appropriate build step for the target.
std::vector<std::string> no_output;
@@ -939,6 +935,10 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput(
}
}
+ // Always create the output sources and mark them generated.
+ this->CreateGeneratedSources(outputs, cmSourceFileLocationKind::Known);
+ this->CreateGeneratedSources(byproducts, cmSourceFileLocationKind::Known);
+
// Choose a source file on which to store the custom command.
cmSourceFile* file = nullptr;
if (!commandLines.empty() && !main_dependency.empty()) {
@@ -986,20 +986,6 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput(
file->SetProperty("__CMAKE_RULE", "1");
}
- // Always create the output sources and mark them generated.
- for (std::string const& o : outputs) {
- if (cmSourceFile* out =
- this->GetOrCreateSource(o, true, cmSourceFileLocationKind::Known)) {
- out->SetProperty("GENERATED", "1");
- }
- }
- for (std::string const& o : byproducts) {
- if (cmSourceFile* out =
- this->GetOrCreateSource(o, true, cmSourceFileLocationKind::Known)) {
- out->SetProperty("GENERATED", "1");
- }
- }
-
// Attach the custom command to the file.
if (file) {
// Construct a complete list of dependencies.
@@ -1179,6 +1165,7 @@ cmTarget* cmMakefile::AddUtilityCommand(
if (excludeFromAll || this->GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
}
+
if (!comment) {
// Use an empty comment to avoid generation of default comment.
comment = "";
@@ -1186,6 +1173,9 @@ cmTarget* cmMakefile::AddUtilityCommand(
// Store the custom command in the target.
if (!commandLines.empty() || !depends.empty()) {
+ // Always create the byproduct sources and mark them generated.
+ this->CreateGeneratedSources(byproducts, cmSourceFileLocationKind::Known);
+
std::string force =
cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles/", utilityName);
std::vector<std::string> forced;
@@ -1204,14 +1194,6 @@ cmTarget* cmMakefile::AddUtilityCommand(
} else {
cmSystemTools::Error("Could not get source file entry for " + force);
}
-
- // Always create the byproduct sources and mark them generated.
- for (std::string const& byproduct : byproducts) {
- if (cmSourceFile* out = this->GetOrCreateSource(
- byproduct, true, cmSourceFileLocationKind::Known)) {
- out->SetProperty("GENERATED", "1");
- }
- }
}
return target;
}
@@ -3319,6 +3301,16 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName,
return this->CreateSource(sourceName, generated, kind);
}
+void cmMakefile::CreateGeneratedSources(
+ const std::vector<std::string>& outputs, cmSourceFileLocationKind kind)
+{
+ for (std::string const& output : outputs) {
+ if (cmSourceFile* out = this->GetOrCreateSource(output, true, kind)) {
+ out->SetProperty("GENERATED", "1");
+ }
+ }
+}
+
void cmMakefile::AddTargetObject(std::string const& tgtName,
std::string const& objFile)
{