summaryrefslogtreecommitdiff
path: root/Source/cmQtAutoGenInitializer.cxx
diff options
context:
space:
mode:
authorNAKAMURA Takumi <geek4civic@gmail.com>2021-11-07 12:45:49 +0900
committerBrad King <brad.king@kitware.com>2021-11-18 12:02:38 -0500
commitc46b041a3bcede9447c36de2f3359eb4c17f3f50 (patch)
tree6940fb1d08650b7451916dcf65a3414a15663ca9 /Source/cmQtAutoGenInitializer.cxx
parent68b4e3b255be7a8d0831d19b206f701efdb001c8 (diff)
downloadcmake-c46b041a3bcede9447c36de2f3359eb4c17f3f50.tar.gz
cmLocalGenerator: Simplify Add{Custom,Utility}Command
Diffstat (limited to 'Source/cmQtAutoGenInitializer.cxx')
-rw-r--r--Source/cmQtAutoGenInitializer.cxx93
1 files changed, 57 insertions, 36 deletions
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index e124758f82..64d8ea9979 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);