summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-10-16 13:40:30 (GMT)
committerBrad King <brad.king@kitware.com>2020-12-10 12:06:20 (GMT)
commit1902d28ebc50ee93acb1be2320b79f2e844f7f41 (patch)
tree4edd3206a52bdbdaac2b8e7a38a2575e99b92da0 /Source/cmLocalGenerator.cxx
parente4034eabe930fb677fb9b5c65cf29336d1ff123c (diff)
downloadCMake-1902d28ebc50ee93acb1be2320b79f2e844f7f41.zip
CMake-1902d28ebc50ee93acb1be2320b79f2e844f7f41.tar.gz
CMake-1902d28ebc50ee93acb1be2320b79f2e844f7f41.tar.bz2
cmLocalGenerator: Refactor UpdateOutputToSourceMap to avoid boolean trap
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r--Source/cmLocalGenerator.cxx17
1 files changed, 8 insertions, 9 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 5739c03..832c36c 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -3924,7 +3924,9 @@ cmSourceFile* AddCustomCommand(
cc->SetJobPool(job_pool);
file->SetCustomCommand(std::move(cc));
- lg.AddSourceOutputs(file, outputs, byproducts);
+ lg.AddSourceOutputs(file, outputs, cmLocalGenerator::OutputRole::Primary);
+ lg.AddSourceOutputs(file, byproducts,
+ cmLocalGenerator::OutputRole::Byproduct);
}
return file;
}
@@ -4177,13 +4179,10 @@ void cmLocalGenerator::AddTargetByproducts(
void cmLocalGenerator::AddSourceOutputs(
cmSourceFile* source, const std::vector<std::string>& outputs,
- const std::vector<std::string>& byproducts)
+ OutputRole role)
{
for (std::string const& o : outputs) {
- this->UpdateOutputToSourceMap(o, source, false);
- }
- for (std::string const& o : byproducts) {
- this->UpdateOutputToSourceMap(o, source, true);
+ this->UpdateOutputToSourceMap(o, source, role);
}
}
@@ -4211,18 +4210,18 @@ void cmLocalGenerator::UpdateOutputToSourceMap(std::string const& byproduct,
void cmLocalGenerator::UpdateOutputToSourceMap(std::string const& output,
cmSourceFile* source,
- bool byproduct)
+ OutputRole role)
{
SourceEntry entry;
entry.Sources.Source = source;
- entry.Sources.SourceIsByproduct = byproduct;
+ entry.Sources.SourceIsByproduct = role == OutputRole::Byproduct;
auto pr = this->OutputToSource.emplace(output, entry);
if (!pr.second) {
SourceEntry& current = pr.first->second;
// Outputs take precedence over byproducts
if (!current.Sources.Source ||
- (current.Sources.SourceIsByproduct && !byproduct)) {
+ (current.Sources.SourceIsByproduct && role == OutputRole::Primary)) {
current.Sources.Source = source;
current.Sources.SourceIsByproduct = false;
} else {