summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-09-10 14:59:21 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-09-10 14:59:39 (GMT)
commit95d4a2d05562c5f0a4113527d31dadef4d7756bd (patch)
tree3df381ebc8637e7ae234003d8da116147d4930e4
parent054d626c9cca0facb372ba740b8a797d463141a3 (diff)
parent75692393628d757a3dadb090179e167cd9539e2f (diff)
downloadCMake-95d4a2d05562c5f0a4113527d31dadef4d7756bd.zip
CMake-95d4a2d05562c5f0a4113527d31dadef4d7756bd.tar.gz
CMake-95d4a2d05562c5f0a4113527d31dadef4d7756bd.tar.bz2
Merge topic 'move-setting-GENERATE-upfront'
7569239362 cmMakefile: set GENERATED property of outputs upfront Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3789
-rw-r--r--Source/cmMakefile.cxx48
-rw-r--r--Source/cmMakefile.h5
2 files changed, 25 insertions, 28 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 411add3..d729451 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -860,7 +860,7 @@ void cmMakefile::AddCustomCommandToTarget(
e << "No TARGET '" << target
<< "' has been created in this directory.";
}
- IssueMessage(messageType, e.str());
+ this->IssueMessage(messageType, e.str());
}
return;
@@ -886,11 +886,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;
@@ -940,6 +936,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()) {
@@ -987,20 +987,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.
@@ -1180,6 +1166,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 = "";
@@ -1187,6 +1174,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;
@@ -1205,14 +1195,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;
}
@@ -3325,6 +3307,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)
{
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 09f53c9..52464d6 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -1030,6 +1030,11 @@ private:
bool escapeQuotes, bool noEscapes,
bool atOnly, const char* filename,
long line, bool replaceAt) const;
+
+ void CreateGeneratedSources(
+ const std::vector<std::string>& outputs,
+ cmSourceFileLocationKind kind = cmSourceFileLocationKind::Ambiguous);
+
/**
* Old version of GetSourceFileWithOutput(const std::string&) kept for
* backward-compatibility. It implements a linear search and support