diff options
author | Brad King <brad.king@kitware.com> | 2020-10-30 15:48:43 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-12-15 12:00:53 (GMT) |
commit | 15467f12f796205f97721f43ae7d9ee7cdc47466 (patch) | |
tree | 17fb00d71cb6698bd75a03b560faf7eeab557f6c /Source | |
parent | 7b64b0cd5a4046bf8743c3e2d3c57cb470bfa95f (diff) | |
download | CMake-15467f12f796205f97721f43ae7d9ee7cdc47466.zip CMake-15467f12f796205f97721f43ae7d9ee7cdc47466.tar.gz CMake-15467f12f796205f97721f43ae7d9ee7cdc47466.tar.bz2 |
cmLocalGenerator: Adopt custom target 'force' output name generation
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 28 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 4 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 22 | ||||
-rw-r--r-- | Source/cmMakefile.h | 5 |
4 files changed, 27 insertions, 32 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index dc4a3fc..cd18670 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1129,9 +1129,8 @@ cmTarget* cmLocalGenerator::AddUtilityCommand( detail::AddUtilityCommand( *this, this->DirectoryBacktrace, cmCommandOrigin::Generator, target, - this->Makefile->GetUtilityOutput(target), workingDir, byproducts, depends, - commandLines, escapeOldStyle, comment, uses_terminal, command_expand_lists, - job_pool, stdPipesUTF8); + workingDir, byproducts, depends, commandLines, escapeOldStyle, comment, + uses_terminal, command_expand_lists, job_pool, stdPipesUTF8); return target; } @@ -4115,7 +4114,7 @@ void AppendCustomCommandToOutput(cmLocalGenerator& lg, void AddUtilityCommand(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt, cmCommandOrigin origin, cmTarget* target, - std::string const& force, const char* workingDir, + const char* workingDir, const std::vector<std::string>& byproducts, const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, @@ -4128,10 +4127,13 @@ void AddUtilityCommand(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt, comment = ""; } + // Create the generated symbolic output name of the utility target. + std::string output = lg.CreateUtilityOutput(target->GetName()); + std::string no_main_dependency; cmImplicitDependsList no_implicit_depends; cmSourceFile* rule = AddCustomCommand( - lg, lfbt, origin, { force }, byproducts, depends, no_main_dependency, + lg, lfbt, origin, { output }, byproducts, depends, no_main_dependency, no_implicit_depends, commandLines, comment, workingDir, /*replace=*/false, escapeOldStyle, uses_terminal, command_expand_lists, /*depfile=*/"", job_pool, stdPipesUTF8); @@ -4139,7 +4141,7 @@ void AddUtilityCommand(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt, lg.AddTargetByproducts(target, byproducts, lfbt, origin); } - target->AddSource(force); + target->AddSource(output); } std::vector<std::string> ComputeISPCObjectSuffixes(cmGeneratorTarget* target) @@ -4232,6 +4234,20 @@ cmSourceFile* cmLocalGenerator::GetSourceFileWithOutput( return nullptr; } +std::string cmLocalGenerator::CreateUtilityOutput( + std::string const& targetName) +{ + std::string force = + cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles/", targetName); + // The output is not actually created so mark it symbolic. + if (cmSourceFile* sf = this->Makefile->GetOrCreateGeneratedSource(force)) { + sf->SetProperty("SYMBOLIC", "1"); + } else { + cmSystemTools::Error("Could not get source file entry for " + force); + } + return force; +} + std::vector<cmCustomCommandGenerator> cmLocalGenerator::MakeCustomCommandGenerators(cmCustomCommand const& cc, std::string const& config) diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index db239c0..d9c2c1e 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -364,6 +364,8 @@ public: bool command_expand_lists = false, const std::string& job_pool = "", bool stdPipesUTF8 = false); + std::string CreateUtilityOutput(std::string const& targetName); + virtual std::vector<cmCustomCommandGenerator> MakeCustomCommandGenerators( cmCustomCommand const& cc, std::string const& config); @@ -688,7 +690,7 @@ void AppendCustomCommandToOutput(cmLocalGenerator& lg, void AddUtilityCommand(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt, cmCommandOrigin origin, cmTarget* target, - std::string const& force, const char* workingDir, + const char* workingDir, const std::vector<std::string>& byproducts, const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 6743a89..028688d 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1257,20 +1257,6 @@ void cmMakefile::AppendCustomCommandToOutput( } } -std::string cmMakefile::GetUtilityOutput(cmTarget* target) -{ - std::string force = cmStrCat(this->GetCurrentBinaryDirectory(), - "/CMakeFiles/", target->GetName()); - // The output is not actually created so mark it symbolic. - if (cmSourceFile* sf = this->GetOrCreateSource( - force, false, cmSourceFileLocationKind::Known)) { - sf->SetProperty("SYMBOLIC", "1"); - } else { - cmSystemTools::Error("Could not get source file entry for " + force); - } - return force; -} - cmTarget* cmMakefile::AddUtilityCommand( const std::string& utilityName, bool excludeFromAll, const char* workingDir, const std::vector<std::string>& byproducts, @@ -1287,10 +1273,6 @@ cmTarget* cmMakefile::AddUtilityCommand( return target; } - // Get the output name of the utility target and mark it generated. - std::string force = this->GetUtilityOutput(target); - this->GetOrCreateGeneratedSource(force); - // Always create the byproduct sources and mark them generated. this->CreateGeneratedOutputs(byproducts); @@ -1303,8 +1285,8 @@ cmTarget* cmMakefile::AddUtilityCommand( [=](cmLocalGenerator& lg, const cmListFileBacktrace& lfbt) { BacktraceGuard guard(this->Backtrace, lfbt); detail::AddUtilityCommand(lg, lfbt, cmCommandOrigin::Project, target, - force, GetCStrOrNull(workingStr), byproducts, - depends, commandLines, escapeOldStyle, + GetCStrOrNull(workingStr), byproducts, depends, + commandLines, escapeOldStyle, GetCStrOrNull(commentStr), uses_terminal, command_expand_lists, job_pool, stdPipesUTF8); }); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index cab3e17..f18f70c 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -243,11 +243,6 @@ public: bool excludeFromAll = false); /** - * Return the utility target output source file name. - */ - std::string GetUtilityOutput(cmTarget* target); - - /** * Dispatch adding a utility to the build. A utility target is a command * that is run every time the target is built. */ |