diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2021-11-07 03:45:49 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-11-18 17:02:38 (GMT) |
commit | c46b041a3bcede9447c36de2f3359eb4c17f3f50 (patch) | |
tree | 6940fb1d08650b7451916dcf65a3414a15663ca9 | |
parent | 68b4e3b255be7a8d0831d19b206f701efdb001c8 (diff) | |
download | CMake-c46b041a3bcede9447c36de2f3359eb4c17f3f50.zip CMake-c46b041a3bcede9447c36de2f3359eb4c17f3f50.tar.gz CMake-c46b041a3bcede9447c36de2f3359eb4c17f3f50.tar.bz2 |
cmLocalGenerator: Simplify Add{Custom,Utility}Command
-rw-r--r-- | Source/cmGlobalVisualStudio8Generator.cxx | 45 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudioGenerator.cxx | 13 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 33 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 116 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 47 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 24 | ||||
-rw-r--r-- | Source/cmQtAutoGenGlobalInitializer.cxx | 15 | ||||
-rw-r--r-- | Source/cmQtAutoGenInitializer.cxx | 93 |
8 files changed, 154 insertions, 232 deletions
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index c4da8c3..48c662c 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -147,13 +147,10 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() auto& lg = cm::static_reference_cast<cmLocalVisualStudio7Generator>(generators[0]); - const char* no_working_directory = nullptr; - std::vector<std::string> no_byproducts; - std::vector<std::string> no_depends; - cmCustomCommandLines no_commands; - cmTarget* tgt = lg.AddUtilityCommand( - CMAKE_CHECK_BUILD_SYSTEM_TARGET, false, no_working_directory, - no_byproducts, no_depends, no_commands, cmPolicies::NEW); + auto cc = cm::make_unique<cmCustomCommand>(); + cc->SetCMP0116Status(cmPolicies::NEW); + cmTarget* tgt = lg.AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false, + std::move(cc)); auto ptr = cm::make_unique<cmGeneratorTarget>(tgt, &lg); auto gt = ptr.get(); @@ -203,17 +200,15 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() std::vector<std::string> byproducts; byproducts.push_back(cm->GetGlobVerifyStamp()); - lg.AddCustomCommandToTarget( - CMAKE_CHECK_BUILD_SYSTEM_TARGET, byproducts, no_depends, - verifyCommandLines, cmCustomCommandType::PRE_BUILD, - "Checking File Globs", no_working_directory, cmPolicies::NEW, - /*escapeOldStyle=*/true, - /*uses_terminal=*/false, - /*depfile=*/"", - /*job_pool=*/"", - /*command_expand_lists=*/false, - /*objLibCommands=*/cmObjectLibraryCommands::Reject, - /*stdPipesUTF8=*/stdPipesUTF8); + cc = cm::make_unique<cmCustomCommand>(); + cc->SetByproducts(byproducts); + cc->SetCommandLines(verifyCommandLines); + cc->SetComment("Checking File Globs"); + cc->SetCMP0116Status(cmPolicies::NEW); + cc->SetStdPipesUTF8(stdPipesUTF8); + lg.AddCustomCommandToTarget(CMAKE_CHECK_BUILD_SYSTEM_TARGET, + cmCustomCommandType::PRE_BUILD, + std::move(cc)); // Ensure ZERO_CHECK always runs in Visual Studio using MSBuild, // otherwise the prebuild command will not be run. @@ -241,12 +236,16 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() // overwritten by the CreateVCProjBuildRule. // (this could be avoided with per-target source files) std::string no_main_dependency; - cmImplicitDependsList no_implicit_depends; + cc = cm::make_unique<cmCustomCommand>(); + cc->SetOutputs(stamps); + cc->SetDepends(listFiles); + cc->SetCommandLines(commandLines); + cc->SetComment("Checking Build System"); + cc->SetCMP0116Status(cmPolicies::NEW); + cc->SetEscapeOldStyle(false); + cc->SetStdPipesUTF8(stdPipesUTF8); if (cmSourceFile* file = lg.AddCustomCommandToOutput( - stamps, no_byproducts, listFiles, no_main_dependency, - no_implicit_depends, commandLines, "Checking Build System", - no_working_directory, cmPolicies::NEW, true, false, false, false, "", - "", stdPipesUTF8)) { + no_main_dependency, std::move(cc), true)) { gt->AddSource(file->ResolveFullPath()); } else { cmSystemTools::Error("Error adding rule for " + stamps[0]); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 580c82b..f6011d1 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -199,19 +199,18 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets() { // Add a special target that depends on ALL projects for easy build // of one configuration only. - const char* no_working_dir = nullptr; - std::vector<std::string> no_byproducts; - std::vector<std::string> no_depends; - cmCustomCommandLines no_commands; for (auto const& it : this->ProjectMap) { std::vector<cmLocalGenerator*> const& gen = it.second; // add the ALL_BUILD to the first local generator of each project if (!gen.empty()) { // Use no actual command lines so that the target itself is not // considered always out of date. - cmTarget* allBuild = gen[0]->AddUtilityCommand( - "ALL_BUILD", true, no_working_dir, no_byproducts, no_depends, - no_commands, cmPolicies::NEW, false, "Build all projects"); + auto cc = cm::make_unique<cmCustomCommand>(); + cc->SetCMP0116Status(cmPolicies::NEW); + cc->SetEscapeOldStyle(false); + cc->SetComment("Build all projects"); + cmTarget* allBuild = + gen[0]->AddUtilityCommand("ALL_BUILD", true, std::move(cc)); gen[0]->AddGeneratorTarget( cm::make_unique<cmGeneratorTarget>(allBuild, gen[0])); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index a836f43..44a3eb7 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -608,15 +608,13 @@ std::string cmGlobalXCodeGenerator::PostBuildMakeTarget( void cmGlobalXCodeGenerator::AddExtraTargets( cmLocalGenerator* root, std::vector<cmLocalGenerator*>& gens) { - const char* no_working_directory = nullptr; - std::vector<std::string> no_byproducts; - std::vector<std::string> no_depends; - // Add ALL_BUILD - cmTarget* allbuild = root->AddUtilityCommand( - "ALL_BUILD", true, no_working_directory, no_byproducts, no_depends, - cmMakeSingleCommandLine({ "echo", "Build all projects" }), - cmPolicies::NEW); + auto cc = cm::make_unique<cmCustomCommand>(); + cc->SetCommandLines( + cmMakeSingleCommandLine({ "echo", "Build all projects" })); + cc->SetCMP0116Status(cmPolicies::NEW); + cmTarget* allbuild = + root->AddUtilityCommand("ALL_BUILD", true, std::move(cc)); root->AddGeneratorTarget(cm::make_unique<cmGeneratorTarget>(allbuild, root)); @@ -642,10 +640,11 @@ void cmGlobalXCodeGenerator::AddExtraTargets( std::string file = this->ConvertToRelativeForMake(this->CurrentReRunCMakeMakefile); cmSystemTools::ReplaceString(file, "\\ ", " "); - cmTarget* check = root->AddUtilityCommand( - CMAKE_CHECK_BUILD_SYSTEM_TARGET, true, no_working_directory, - no_byproducts, no_depends, - cmMakeSingleCommandLine({ "make", "-f", file }), cmPolicies::NEW); + cc = cm::make_unique<cmCustomCommand>(); + cc->SetCommandLines(cmMakeSingleCommandLine({ "make", "-f", file })); + cc->SetCMP0116Status(cmPolicies::NEW); + cmTarget* check = root->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, + true, std::move(cc)); root->AddGeneratorTarget(cm::make_unique<cmGeneratorTarget>(check, root)); } @@ -671,11 +670,13 @@ void cmGlobalXCodeGenerator::AddExtraTargets( target->GetType() == cmStateEnums::OBJECT_LIBRARY) { legacyDependHelperCommandLines.front().back() = // fill placeholder this->PostBuildMakeTarget(target->GetName(), "$(CONFIGURATION)"); + cc = cm::make_unique<cmCustomCommand>(); + cc->SetCommandLines(legacyDependHelperCommandLines); + cc->SetComment("Depend check for xcode"); + cc->SetWorkingDirectory(legacyDependHelperDir.c_str()); + cc->SetCMP0116Status(cmPolicies::NEW); gen->AddCustomCommandToTarget( - target->GetName(), no_byproducts, no_depends, - legacyDependHelperCommandLines, cmCustomCommandType::POST_BUILD, - "Depend check for xcode", legacyDependHelperDir.c_str(), - cmPolicies::NEW, true, false, "", "", false, + target->GetName(), cmCustomCommandType::POST_BUILD, std::move(cc), cmObjectLibraryCommands::Accept); } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 98f8fcc..5e37fe4 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1057,14 +1057,8 @@ void cmLocalGenerator::AddCompileOptions(std::vector<BT<std::string>>& flags, } cmTarget* cmLocalGenerator::AddCustomCommandToTarget( - const std::string& target, const std::vector<std::string>& byproducts, - const std::vector<std::string>& depends, - const cmCustomCommandLines& commandLines, cmCustomCommandType type, - const char* comment, const char* workingDir, - cmPolicies::PolicyStatus cmp0116, bool escapeOldStyle, bool uses_terminal, - const std::string& depfile, const std::string& job_pool, - bool command_expand_lists, cmObjectLibraryCommands objLibCommands, - bool stdPipesUTF8) + const std::string& target, cmCustomCommandType type, + std::unique_ptr<cmCustomCommand> cc, cmObjectLibraryCommands objLibCommands) { cmTarget* t = this->Makefile->GetCustomCommandTarget( target, objLibCommands, this->DirectoryBacktrace); @@ -1072,20 +1066,8 @@ cmTarget* cmLocalGenerator::AddCustomCommandToTarget( return nullptr; } - auto cc = cm::make_unique<cmCustomCommand>(); cc->SetBacktrace(this->DirectoryBacktrace); - cc->SetByproducts(byproducts); - cc->SetDepends(depends); - cc->SetCommandLines(commandLines); - cc->SetComment(comment); - cc->SetWorkingDirectory(workingDir); - cc->SetEscapeOldStyle(escapeOldStyle); - cc->SetUsesTerminal(uses_terminal); - cc->SetDepfile(depfile); - cc->SetJobPool(job_pool); - cc->SetCommandExpandLists(command_expand_lists); - cc->SetStdPipesUTF8(stdPipesUTF8); - cc->SetCMP0116Status(cmp0116); + detail::AddCustomCommandToTarget(*this, cmCommandOrigin::Generator, t, type, std::move(cc)); @@ -1093,87 +1075,34 @@ cmTarget* cmLocalGenerator::AddCustomCommandToTarget( } cmSourceFile* cmLocalGenerator::AddCustomCommandToOutput( - const std::string& output, const std::vector<std::string>& depends, - const std::string& main_dependency, const cmCustomCommandLines& commandLines, - const char* comment, const char* workingDir, - cmPolicies::PolicyStatus cmp0116, bool replace, bool escapeOldStyle, - bool uses_terminal, bool command_expand_lists, const std::string& depfile, - const std::string& job_pool, bool stdPipesUTF8) -{ - std::vector<std::string> no_byproducts; - cmImplicitDependsList no_implicit_depends; - return this->AddCustomCommandToOutput( - { output }, no_byproducts, depends, main_dependency, no_implicit_depends, - commandLines, comment, workingDir, cmp0116, replace, escapeOldStyle, - uses_terminal, command_expand_lists, depfile, job_pool, stdPipesUTF8); -} - -cmSourceFile* cmLocalGenerator::AddCustomCommandToOutput( - const std::vector<std::string>& outputs, - const std::vector<std::string>& byproducts, - const std::vector<std::string>& depends, const std::string& main_dependency, - const cmImplicitDependsList& implicit_depends, - const cmCustomCommandLines& commandLines, const char* comment, - const char* workingDir, cmPolicies::PolicyStatus cmp0116, bool replace, - bool escapeOldStyle, bool uses_terminal, bool command_expand_lists, - const std::string& depfile, const std::string& job_pool, bool stdPipesUTF8) + const std::string& main_dependency, std::unique_ptr<cmCustomCommand> cc, + bool replace) { // Make sure there is at least one output. - if (outputs.empty()) { + if (cc->GetOutputs().empty()) { cmSystemTools::Error("Attempt to add a custom rule with no output!"); return nullptr; } - auto cc = cm::make_unique<cmCustomCommand>(); cc->SetBacktrace(this->DirectoryBacktrace); - cc->SetOutputs(outputs); - cc->SetByproducts(byproducts); - cc->SetDepends(depends); - cc->SetImplicitDepends(implicit_depends); - cc->SetCommandLines(commandLines); - cc->SetComment(comment); - cc->SetWorkingDirectory(workingDir); - cc->SetEscapeOldStyle(escapeOldStyle); - cc->SetUsesTerminal(uses_terminal); - cc->SetCommandExpandLists(command_expand_lists); - cc->SetDepfile(depfile); - cc->SetJobPool(job_pool); - cc->SetStdPipesUTF8(stdPipesUTF8); - cc->SetCMP0116Status(cmp0116); return detail::AddCustomCommandToOutput(*this, cmCommandOrigin::Generator, main_dependency, std::move(cc), replace); } cmTarget* cmLocalGenerator::AddUtilityCommand( - const std::string& utilityName, bool excludeFromAll, const char* workingDir, - const std::vector<std::string>& byproducts, - const std::vector<std::string>& depends, - const cmCustomCommandLines& commandLines, cmPolicies::PolicyStatus cmp0116, - bool escapeOldStyle, const char* comment, bool uses_terminal, - bool command_expand_lists, const std::string& job_pool, bool stdPipesUTF8) + const std::string& utilityName, bool excludeFromAll, + std::unique_ptr<cmCustomCommand> cc) { cmTarget* target = this->Makefile->AddNewUtilityTarget(utilityName, excludeFromAll); target->SetIsGeneratorProvided(true); - if (commandLines.empty() && depends.empty()) { + if (cc->GetCommandLines().empty() && cc->GetDepends().empty()) { return target; } - auto cc = cm::make_unique<cmCustomCommand>(); cc->SetBacktrace(this->DirectoryBacktrace); - cc->SetWorkingDirectory(workingDir); - cc->SetByproducts(byproducts); - cc->SetDepends(depends); - cc->SetCommandLines(commandLines); - cc->SetEscapeOldStyle(escapeOldStyle); - cc->SetComment(comment); - cc->SetUsesTerminal(uses_terminal); - cc->SetCommandExpandLists(command_expand_lists); - cc->SetJobPool(job_pool); - cc->SetStdPipesUTF8(stdPipesUTF8); - cc->SetCMP0116Status(cmp0116); detail::AddUtilityCommand(*this, cmCommandOrigin::Generator, target, std::move(cc)); @@ -2786,8 +2715,6 @@ void cmLocalGenerator::CopyPchCompilePdb( file << "endforeach()\n"; } - bool stdPipesUTF8 = true; - auto configGenex = [&](cm::string_view expr) -> std::string { if (this->GetGlobalGenerator()->IsMultiConfig()) { return cmStrCat("$<$<CONFIG:", config, ">:", expr, ">"); @@ -2801,28 +2728,27 @@ void cmLocalGenerator::CopyPchCompilePdb( configGenex(copy_script) }); const std::string no_main_dependency; - const std::vector<std::string> no_deps; const char* no_message = ""; - const char* no_current_dir = nullptr; - const cmPolicies::PolicyStatus cmp0116_new = cmPolicies::NEW; - std::vector<std::string> no_byproducts; std::vector<std::string> outputs; outputs.push_back(configGenex( cmStrCat(target_compile_pdb_dir, pdb_prefix, ReuseFrom, ".pdb"))); + auto cc = cm::make_unique<cmCustomCommand>(); + cc->SetCommandLines(commandLines); + cc->SetComment(no_message); + cc->SetCMP0116Status(cmPolicies::NEW); + cc->SetStdPipesUTF8(true); + if (this->GetGlobalGenerator()->IsVisualStudio()) { + cc->SetByproducts(outputs); this->AddCustomCommandToTarget( - target->GetName(), outputs, no_deps, commandLines, - cmCustomCommandType::PRE_BUILD, no_message, no_current_dir, cmp0116_new, - true, false, "", "", false, cmObjectLibraryCommands::Accept, - stdPipesUTF8); + target->GetName(), cmCustomCommandType::PRE_BUILD, std::move(cc), + cmObjectLibraryCommands::Accept); } else { - cmImplicitDependsList no_implicit_depends; - cmSourceFile* copy_rule = this->AddCustomCommandToOutput( - outputs, no_byproducts, no_deps, no_main_dependency, no_implicit_depends, - commandLines, no_message, no_current_dir, cmp0116_new, false, true, - false, false, "", "", stdPipesUTF8); + cc->SetOutputs(outputs); + cmSourceFile* copy_rule = + this->AddCustomCommandToOutput(no_main_dependency, std::move(cc)); if (copy_rule) { target->AddSource(copy_rule->ResolveFullPath()); diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 1304d81..3edf5dc 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -329,53 +329,24 @@ public: * Add a custom PRE_BUILD, PRE_LINK, or POST_BUILD command to a target. */ cmTarget* AddCustomCommandToTarget( - const std::string& target, const std::vector<std::string>& byproducts, - const std::vector<std::string>& depends, - const cmCustomCommandLines& commandLines, cmCustomCommandType type, - const char* comment, const char* workingDir, - cmPolicies::PolicyStatus cmp0116, bool escapeOldStyle = true, - bool uses_terminal = false, const std::string& depfile = "", - const std::string& job_pool = "", bool command_expand_lists = false, - cmObjectLibraryCommands objLibCommands = cmObjectLibraryCommands::Reject, - bool stdPipesUTF8 = false); + const std::string& target, cmCustomCommandType type, + std::unique_ptr<cmCustomCommand> cc, + cmObjectLibraryCommands objLibCommands = cmObjectLibraryCommands::Reject); /** * Add a custom command to a source file. */ - cmSourceFile* AddCustomCommandToOutput( - const std::string& output, const std::vector<std::string>& depends, - const std::string& main_dependency, - const cmCustomCommandLines& commandLines, const char* comment, - const char* workingDir, cmPolicies::PolicyStatus cmp0116, - bool replace = false, bool escapeOldStyle = true, - bool uses_terminal = false, bool command_expand_lists = false, - const std::string& depfile = "", const std::string& job_pool = "", - bool stdPipesUTF8 = false); - cmSourceFile* AddCustomCommandToOutput( - const std::vector<std::string>& outputs, - const std::vector<std::string>& byproducts, - const std::vector<std::string>& depends, - const std::string& main_dependency, - const cmImplicitDependsList& implicit_depends, - const cmCustomCommandLines& commandLines, const char* comment, - const char* workingDir, cmPolicies::PolicyStatus cmp0116, - bool replace = false, bool escapeOldStyle = true, - bool uses_terminal = false, bool command_expand_lists = false, - const std::string& depfile = "", const std::string& job_pool = "", - bool stdPipesUTF8 = false); + cmSourceFile* AddCustomCommandToOutput(const std::string& main_dependency, + std::unique_ptr<cmCustomCommand> cc, + bool replace = false); /** * Add a utility to the build. A utility target is a command that is run * every time the target is built. */ - cmTarget* AddUtilityCommand( - const std::string& utilityName, bool excludeFromAll, - const char* workingDir, const std::vector<std::string>& byproducts, - const std::vector<std::string>& depends, - const cmCustomCommandLines& commandLines, cmPolicies::PolicyStatus cmp0116, - bool escapeOldStyle = true, const char* comment = nullptr, - bool uses_terminal = false, bool command_expand_lists = false, - const std::string& job_pool = "", bool stdPipesUTF8 = false); + cmTarget* AddUtilityCommand(const std::string& utilityName, + bool excludeFromAll, + std::unique_ptr<cmCustomCommand> cc); virtual std::string CreateUtilityOutput( std::string const& targetName, std::vector<std::string> const& byproducts, diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 7223049..886a4e8 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -110,7 +110,6 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() const auto& tgts = this->GetGeneratorTargets(); for (auto& l : tgts) { if (l->GetType() == cmStateEnums::GLOBAL_TARGET) { - std::vector<std::string> no_depends; cmCustomCommandLines force_commands = cmMakeSingleCommandLine({ "cd", "." }); std::string no_main_dependency; @@ -120,9 +119,13 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() this->Makefile->GetOrCreateGeneratedSource(force)) { sf->SetProperty("SYMBOLIC", "1"); } + auto cc = cm::make_unique<cmCustomCommand>(); + cc->SetOutputs(force); + cc->SetCommandLines(force_commands); + cc->SetComment(" "); + cc->SetCMP0116Status(cmPolicies::NEW); if (cmSourceFile* file = this->AddCustomCommandToOutput( - force, no_depends, no_main_dependency, force_commands, " ", - nullptr, cmPolicies::NEW, true)) { + no_main_dependency, std::move(cc), true)) { l->AddSource(file->ResolveFullPath()); } } @@ -240,16 +243,19 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule() std::string argB = cmStrCat("-B", this->GetBinaryDirectory()); std::string stampName = cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles/generate.stamp"); - bool stdPipesUTF8 = true; cmCustomCommandLines commandLines = cmMakeSingleCommandLine({ cmSystemTools::GetCMakeCommand(), argS, argB, "--check-stamp-file", stampName }); std::string comment = cmStrCat("Building Custom Rule ", makefileIn); - const char* no_working_directory = nullptr; - this->AddCustomCommandToOutput(stampName, listFiles, makefileIn, - commandLines, comment.c_str(), - no_working_directory, cmPolicies::NEW, true, - false, false, false, "", "", stdPipesUTF8); + auto cc = cm::make_unique<cmCustomCommand>(); + cc->SetOutputs(stampName); + cc->SetDepends(listFiles); + cc->SetCommandLines(commandLines); + cc->SetComment(comment.c_str()); + cc->SetCMP0116Status(cmPolicies::NEW); + cc->SetEscapeOldStyle(false); + cc->SetStdPipesUTF8(true); + this->AddCustomCommandToOutput(makefileIn, std::move(cc), true); if (cmSourceFile* file = this->Makefile->GetSource(makefileIn)) { // Finalize the source file path now since we're adding this after // the generator validated all project-named sources. diff --git a/Source/cmQtAutoGenGlobalInitializer.cxx b/Source/cmQtAutoGenGlobalInitializer.cxx index f9e889a..b7ea7d6 100644 --- a/Source/cmQtAutoGenGlobalInitializer.cxx +++ b/Source/cmQtAutoGenGlobalInitializer.cxx @@ -7,7 +7,7 @@ #include <cm/memory> -#include "cmCustomCommandLines.h" +#include "cmCustomCommand.h" #include "cmDuration.h" #include "cmGeneratorTarget.h" #include "cmLocalGenerator.h" @@ -171,13 +171,12 @@ void cmQtAutoGenGlobalInitializer::GetOrCreateGlobalTarget( cmMakefile* makefile = localGen->GetMakefile(); // Create utility target - std::vector<std::string> no_byproducts; - std::vector<std::string> no_depends; - cmCustomCommandLines no_commands; - const cmPolicies::PolicyStatus cmp0116_new = cmPolicies::NEW; - cmTarget* target = localGen->AddUtilityCommand( - name, true, makefile->GetHomeOutputDirectory().c_str(), no_byproducts, - no_depends, no_commands, cmp0116_new, false, comment.c_str()); + auto cc = cm::make_unique<cmCustomCommand>(); + cc->SetWorkingDirectory(makefile->GetHomeOutputDirectory().c_str()); + cc->SetCMP0116Status(cmPolicies::NEW); + cc->SetEscapeOldStyle(false); + cc->SetComment(comment.c_str()); + cmTarget* target = localGen->AddUtilityCommand(name, true, std::move(cc)); localGen->AddGeneratorTarget( cm::make_unique<cmGeneratorTarget>(target, localGen)); diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index e124758..64d8ea9 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1231,14 +1231,16 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() // Add a rule file to cause the target to build if a dependency has // changed, which will trigger the pre-build command to run autogen std::string no_main_dependency; - cmCustomCommandLines no_command_lines; - this->LocalGen->AddCustomCommandToOutput( - timestampFileGenex, uicDependencies, no_main_dependency, - no_command_lines, /*comment=*/"", this->Dir.Work.c_str(), - /*cmp0116=*/cmPolicies::NEW, /*replace=*/false, - /*escapeOldStyle=*/false, /*uses_terminal=*/false, - /*command_expand_lists=*/false, /*depfile=*/"", /*job_pool=*/"", - stdPipesUTF8); + auto cc = cm::make_unique<cmCustomCommand>(); + cc->SetOutputs(timestampFileGenex); + cc->SetDepends(uicDependencies); + cc->SetComment(""); + cc->SetWorkingDirectory(this->Dir.Work.c_str()); + cc->SetCMP0116Status(cmPolicies::NEW); + cc->SetEscapeOldStyle(false); + cc->SetStdPipesUTF8(stdPipesUTF8); + this->LocalGen->AddCustomCommandToOutput(no_main_dependency, + std::move(cc)); } // Add the pre-build command directly to bypass the OBJECT_LIBRARY @@ -1323,11 +1325,15 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() dependencies.push_back(depname); } + auto cc = cm::make_unique<cmCustomCommand>(); + cc->SetWorkingDirectory(this->Dir.Work.c_str()); + cc->SetByproducts(timestampTargetProvides); + cc->SetDepends(dependencies); + cc->SetCommandLines(timestampTargetCommandLines); + cc->SetCMP0116Status(cmPolicies::NEW); + cc->SetEscapeOldStyle(false); cmTarget* timestampTarget = this->LocalGen->AddUtilityCommand( - timestampTargetName, true, this->Dir.Work.c_str(), - /*byproducts=*/timestampTargetProvides, - /*depends=*/dependencies, timestampTargetCommandLines, cmPolicies::NEW, - false, nullptr); + timestampTargetName, true, std::move(cc)); this->LocalGen->AddGeneratorTarget( cm::make_unique<cmGeneratorTarget>(timestampTarget, this->LocalGen)); @@ -1357,15 +1363,19 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() this->AddGeneratedSource(outputFile, this->Moc); const std::string no_main_dependency; - this->LocalGen->AddCustomCommandToOutput( - { outputFile }, timestampByproducts, dependencies, no_main_dependency, - /*implicit_depends=*/{}, commandLines, autogenComment.c_str(), - this->Dir.Work.c_str(), - /*cmp0116=*/cmPolicies::NEW, /*replace=*/false, - /*escapeOldStyle=*/false, - /*uses_terminal=*/false, - /*command_expand_lists=*/false, this->AutogenTarget.DepFile, "", - stdPipesUTF8); + cc = cm::make_unique<cmCustomCommand>(); + cc->SetOutputs(outputFile); + cc->SetByproducts(timestampByproducts); + cc->SetDepends(dependencies); + cc->SetCommandLines(commandLines); + cc->SetComment(autogenComment.c_str()); + cc->SetWorkingDirectory(this->Dir.Work.c_str()); + cc->SetCMP0116Status(cmPolicies::NEW); + cc->SetEscapeOldStyle(false); + cc->SetDepfile(this->AutogenTarget.DepFile); + cc->SetStdPipesUTF8(stdPipesUTF8); + this->LocalGen->AddCustomCommandToOutput(no_main_dependency, + std::move(cc)); // Alter variables for the autogen target which now merely wraps the // custom command @@ -1376,11 +1386,16 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() } // Create autogen target + auto cc = cm::make_unique<cmCustomCommand>(); + cc->SetWorkingDirectory(this->Dir.Work.c_str()); + cc->SetByproducts(autogenByproducts); + cc->SetDepends(dependencies); + cc->SetCommandLines(commandLines); + cc->SetCMP0116Status(cmPolicies::NEW); + cc->SetEscapeOldStyle(false); + cc->SetComment(autogenComment.c_str()); cmTarget* autogenTarget = this->LocalGen->AddUtilityCommand( - this->AutogenTarget.Name, true, this->Dir.Work.c_str(), - /*byproducts=*/autogenByproducts, - /*depends=*/dependencies, commandLines, cmPolicies::NEW, false, - autogenComment.c_str()); + this->AutogenTarget.Name, true, std::move(cc)); // Create autogen generator target this->LocalGen->AddGeneratorTarget( cm::make_unique<cmGeneratorTarget>(autogenTarget, this->LocalGen)); @@ -1437,7 +1452,6 @@ bool cmQtAutoGenInitializer::InitRccTargets() ccDepends.push_back(qrc.QrcFile); ccDepends.push_back(qrc.InfoFile); - bool stdPipesUTF8 = true; cmCustomCommandLines commandLines; if (this->MultiConfig) { // Build for all configurations @@ -1455,6 +1469,13 @@ bool cmQtAutoGenInitializer::InitRccTargets() cmStrCat("Automatic RCC for ", FileProjectRelativePath(this->Makefile, qrc.QrcFile)); + auto cc = cm::make_unique<cmCustomCommand>(); + cc->SetWorkingDirectory(this->Dir.Work.c_str()); + cc->SetCommandLines(commandLines); + cc->SetCMP0116Status(cmPolicies::NEW); + cc->SetComment(ccComment.c_str()); + cc->SetStdPipesUTF8(true); + if (qrc.Generated || this->Rcc.GlobalTarget) { // Create custom rcc target std::string ccName; @@ -1464,10 +1485,11 @@ bool cmQtAutoGenInitializer::InitRccTargets() ccName += cmStrCat('_', qrc.QrcPathChecksum); } - cmTarget* autoRccTarget = this->LocalGen->AddUtilityCommand( - ccName, true, this->Dir.Work.c_str(), ccOutput, ccDepends, - commandLines, cmPolicies::NEW, false, ccComment.c_str(), false, - false, "", stdPipesUTF8); + cc->SetByproducts(ccOutput); + cc->SetDepends(ccDepends); + cc->SetEscapeOldStyle(false); + cmTarget* autoRccTarget = + this->LocalGen->AddUtilityCommand(ccName, true, std::move(cc)); // Create autogen generator target this->LocalGen->AddGeneratorTarget( @@ -1503,12 +1525,11 @@ bool cmQtAutoGenInitializer::InitRccTargets() ccDepends.push_back(this->Rcc.ExecutableTargetName); } std::string no_main_dependency; - cmImplicitDependsList no_implicit_depends; - this->LocalGen->AddCustomCommandToOutput( - ccOutput, ccByproducts, ccDepends, no_main_dependency, - no_implicit_depends, commandLines, ccComment.c_str(), - this->Dir.Work.c_str(), cmPolicies::NEW, false, true, false, false, - "", "", stdPipesUTF8); + cc->SetOutputs(ccOutput); + cc->SetByproducts(ccByproducts); + cc->SetDepends(ccDepends); + this->LocalGen->AddCustomCommandToOutput(no_main_dependency, + std::move(cc)); } // Reconfigure when .qrc file changes this->Makefile->AddCMakeDependFile(qrc.QrcFile); |