summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNAKAMURA Takumi <geek4civic@gmail.com>2021-11-03 04:23:03 (GMT)
committerBrad King <brad.king@kitware.com>2021-11-18 17:02:37 (GMT)
commitd0158b765b0660bcfe304830e179fa9bbdffd5d9 (patch)
tree06283349a5b741130cec4cf5e6045a94bc4b1613
parent2bad0145af7fab909ce9c8272b2057be52f0b40d (diff)
downloadCMake-d0158b765b0660bcfe304830e179fa9bbdffd5d9.zip
CMake-d0158b765b0660bcfe304830e179fa9bbdffd5d9.tar.gz
CMake-d0158b765b0660bcfe304830e179fa9bbdffd5d9.tar.bz2
cmMakefile: Move CMP0116 lookup into Add{Custom,Utility}Command
Avoid repeating it at every call site.
-rw-r--r--Source/cmAddCustomCommandCommand.cxx14
-rw-r--r--Source/cmAddCustomTargetCommand.cxx5
-rw-r--r--Source/cmCPluginAPI.cxx12
-rw-r--r--Source/cmFLTKWrapUICommand.cxx7
-rw-r--r--Source/cmMakefile.cxx44
-rw-r--r--Source/cmMakefile.h34
-rw-r--r--Source/cmQTWrapCPPCommand.cxx7
-rw-r--r--Source/cmQTWrapUICommand.cxx10
8 files changed, 58 insertions, 75 deletions
diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx
index a7ce3a6..ff2cc3e 100644
--- a/Source/cmAddCustomCommandCommand.cxx
+++ b/Source/cmAddCustomCommandCommand.cxx
@@ -320,16 +320,15 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
if (source.empty() && output.empty()) {
// Source is empty, use the target.
std::vector<std::string> no_depends;
- mf.AddCustomCommandToTarget(
- target, byproducts, no_depends, commandLines, cctype, comment,
- working.c_str(), mf.GetPolicyStatus(cmPolicies::CMP0116), escapeOldStyle,
- uses_terminal, depfile, job_pool, command_expand_lists);
+ mf.AddCustomCommandToTarget(target, byproducts, no_depends, commandLines,
+ cctype, comment, working.c_str(),
+ escapeOldStyle, uses_terminal, depfile,
+ job_pool, command_expand_lists);
} else if (target.empty()) {
// Target is empty, use the output.
mf.AddCustomCommandToOutput(
output, byproducts, depends, main_dependency, implicit_depends,
- commandLines, comment, working.c_str(),
- mf.GetPolicyStatus(cmPolicies::CMP0116), nullptr, false, escapeOldStyle,
+ commandLines, comment, working.c_str(), nullptr, false, escapeOldStyle,
uses_terminal, command_expand_lists, depfile, job_pool);
} else if (!byproducts.empty()) {
status.SetError("BYPRODUCTS may not be specified with SOURCE signatures");
@@ -366,8 +365,7 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
// Use the old-style mode for backward compatibility.
mf.AddCustomCommandOldStyle(target, outputs, depends, source, commandLines,
- comment,
- mf.GetPolicyStatus(cmPolicies::CMP0116));
+ comment);
}
return true;
diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx
index 2b19aad..104065f 100644
--- a/Source/cmAddCustomTargetCommand.cxx
+++ b/Source/cmAddCustomTargetCommand.cxx
@@ -10,7 +10,6 @@
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
-#include "cmPolicies.h"
#include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
@@ -214,8 +213,8 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args,
bool escapeOldStyle = !verbatim;
cmTarget* target = mf.AddUtilityCommand(
targetName, excludeFromAll, working_directory.c_str(), byproducts, depends,
- commandLines, mf.GetPolicyStatus(cmPolicies::CMP0116), escapeOldStyle,
- comment, uses_terminal, command_expand_lists, job_pool);
+ commandLines, escapeOldStyle, comment, uses_terminal, command_expand_lists,
+ job_pool);
// Add additional user-specified source files to the target.
target->AddSources(sources);
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index c49347d..6f44739 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -225,8 +225,7 @@ static void CCONV cmAddUtilityCommand(void* arg, const char* utilityName,
// Pass the call to the makefile instance.
std::vector<std::string> no_byproducts;
mf->AddUtilityCommand(utilityName, !all, nullptr, no_byproducts, depends2,
- commandLines,
- mf->GetPolicyStatus(cmPolicies::CMP0116));
+ commandLines);
}
static void CCONV cmAddCustomCommand(void* arg, const char* source,
@@ -267,8 +266,7 @@ static void CCONV cmAddCustomCommand(void* arg, const char* source,
// Pass the call to the makefile instance.
const char* no_comment = nullptr;
mf->AddCustomCommandOldStyle(target, outputs2, depends2, source,
- commandLines, no_comment,
- mf->GetPolicyStatus(cmPolicies::CMP0116));
+ commandLines, no_comment);
}
static void CCONV cmAddCustomCommandToOutput(void* arg, const char* output,
@@ -304,8 +302,7 @@ static void CCONV cmAddCustomCommandToOutput(void* arg, const char* output,
const char* no_comment = nullptr;
const char* no_working_dir = nullptr;
mf->AddCustomCommandToOutput(output, depends2, main_dependency, commandLines,
- no_comment, no_working_dir,
- mf->GetPolicyStatus(cmPolicies::CMP0116));
+ no_comment, no_working_dir);
}
static void CCONV cmAddCustomCommandToTarget(void* arg, const char* target,
@@ -348,8 +345,7 @@ static void CCONV cmAddCustomCommandToTarget(void* arg, const char* target,
const char* no_comment = nullptr;
const char* no_working_dir = nullptr;
mf->AddCustomCommandToTarget(target, no_byproducts, no_depends, commandLines,
- cctype, no_comment, no_working_dir,
- mf->GetPolicyStatus(cmPolicies::CMP0116));
+ cctype, no_comment, no_working_dir);
}
static void addLinkLibrary(cmMakefile* mf, std::string const& target,
diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx
index 77d5795..d88617a 100644
--- a/Source/cmFLTKWrapUICommand.cxx
+++ b/Source/cmFLTKWrapUICommand.cxx
@@ -10,7 +10,6 @@
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
-#include "cmPolicies.h"
#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmStringAlgorithms.h"
@@ -99,11 +98,9 @@ bool cmFLTKWrapUICommand(std::vector<std::string> const& args,
const char* no_comment = nullptr;
const char* no_working_dir = nullptr;
mf.AddCustomCommandToOutput(cxxres, depends, no_main_dependency,
- commandLines, no_comment, no_working_dir,
- mf.GetPolicyStatus(cmPolicies::CMP0116));
+ commandLines, no_comment, no_working_dir);
mf.AddCustomCommandToOutput(hname, depends, no_main_dependency,
- commandLines, no_comment, no_working_dir,
- mf.GetPolicyStatus(cmPolicies::CMP0116));
+ commandLines, no_comment, no_working_dir);
cmSourceFile* sf = mf.GetSource(cxxres);
sf->AddDepend(hname);
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index bf3e217..e376323 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1059,9 +1059,8 @@ cmTarget* cmMakefile::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,
+ const char* comment, const char* workingDir, bool escapeOldStyle,
+ bool uses_terminal, const std::string& depfile, const std::string& job_pool,
bool command_expand_lists, bool stdPipesUTF8)
{
cmTarget* t = this->GetCustomCommandTarget(
@@ -1075,6 +1074,8 @@ cmTarget* cmMakefile::AddCustomCommandToTarget(
// Always create the byproduct sources and mark them generated.
this->CreateGeneratedOutputs(byproducts);
+ auto cmp0116 = this->GetPolicyStatus(cmPolicies::CMP0116);
+
// Strings could be moved into the callback function with C++14.
cm::optional<std::string> commentStr = MakeOptionalString(comment);
cm::optional<std::string> workingStr = MakeOptionalString(workingDir);
@@ -1097,18 +1098,16 @@ void cmMakefile::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, const CommandSourceCallback& callback,
- bool replace, bool escapeOldStyle, bool uses_terminal,
- bool command_expand_lists, const std::string& depfile,
+ const CommandSourceCallback& callback, 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;
this->AddCustomCommandToOutput(
{ output }, no_byproducts, depends, main_dependency, no_implicit_depends,
- commandLines, comment, workingDir, cmp0116, callback, replace,
- escapeOldStyle, uses_terminal, command_expand_lists, depfile, job_pool,
- stdPipesUTF8);
+ commandLines, comment, workingDir, callback, replace, escapeOldStyle,
+ uses_terminal, command_expand_lists, depfile, job_pool, stdPipesUTF8);
}
void cmMakefile::AddCustomCommandToOutput(
@@ -1117,10 +1116,9 @@ void cmMakefile::AddCustomCommandToOutput(
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,
- const CommandSourceCallback& callback, bool replace, bool escapeOldStyle,
- bool uses_terminal, bool command_expand_lists, const std::string& depfile,
- const std::string& job_pool, bool stdPipesUTF8)
+ const char* workingDir, const CommandSourceCallback& callback, bool replace,
+ bool escapeOldStyle, bool uses_terminal, bool command_expand_lists,
+ const std::string& depfile, const std::string& job_pool, bool stdPipesUTF8)
{
// Make sure there is at least one output.
if (outputs.empty()) {
@@ -1137,6 +1135,8 @@ void cmMakefile::AddCustomCommandToOutput(
this->CreateGeneratedOutputs(outputs);
this->CreateGeneratedOutputs(byproducts);
+ auto cmp0116 = this->GetPolicyStatus(cmPolicies::CMP0116);
+
// Strings could be moved into the callback function with C++14.
cm::optional<std::string> commentStr = MakeOptionalString(comment);
cm::optional<std::string> workingStr = MakeOptionalString(workingDir);
@@ -1160,8 +1160,7 @@ void cmMakefile::AddCustomCommandToOutput(
void cmMakefile::AddCustomCommandOldStyle(
const std::string& target, const std::vector<std::string>& outputs,
const std::vector<std::string>& depends, const std::string& source,
- const cmCustomCommandLines& commandLines, const char* comment,
- cmPolicies::PolicyStatus cmp0116)
+ const cmCustomCommandLines& commandLines, const char* comment)
{
// Translate the old-style signature to one of the new-style
// signatures.
@@ -1172,7 +1171,7 @@ void cmMakefile::AddCustomCommandOldStyle(
std::vector<std::string> no_byproducts;
this->AddCustomCommandToTarget(
target, no_byproducts, depends, commandLines,
- cmCustomCommandType::POST_BUILD, comment, nullptr, cmp0116);
+ cmCustomCommandType::POST_BUILD, comment, nullptr);
return;
}
@@ -1205,8 +1204,7 @@ void cmMakefile::AddCustomCommandOldStyle(
// The source looks like a real file. Use it as the main dependency.
for (std::string const& output : outputs) {
this->AddCustomCommandToOutput(output, depends, source, commandLines,
- comment, nullptr, cmp0116,
- addRuleFileToTarget);
+ comment, nullptr, addRuleFileToTarget);
}
} else {
std::string no_main_dependency;
@@ -1216,7 +1214,7 @@ void cmMakefile::AddCustomCommandOldStyle(
// The source may not be a real file. Do not use a main dependency.
for (std::string const& output : outputs) {
this->AddCustomCommandToOutput(output, depends2, no_main_dependency,
- commandLines, comment, nullptr, cmp0116,
+ commandLines, comment, nullptr,
addRuleFileToTarget);
}
}
@@ -1243,9 +1241,9 @@ cmTarget* cmMakefile::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 cmCustomCommandLines& commandLines, bool escapeOldStyle,
+ const char* comment, bool uses_terminal, bool command_expand_lists,
+ const std::string& job_pool, bool stdPipesUTF8)
{
cmTarget* target = this->AddNewUtilityTarget(utilityName, excludeFromAll);
@@ -1258,6 +1256,8 @@ cmTarget* cmMakefile::AddUtilityCommand(
// Always create the byproduct sources and mark them generated.
this->CreateGeneratedOutputs(byproducts);
+ auto cmp0116 = this->GetPolicyStatus(cmPolicies::CMP0116);
+
// Strings could be moved into the callback function with C++14.
cm::optional<std::string> commentStr = MakeOptionalString(comment);
cm::optional<std::string> workingStr = MakeOptionalString(workingDir);
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 671cdab..c29fb00 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -169,8 +169,7 @@ public:
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,
+ const char* comment, const char* workingDir, bool escapeOldStyle = true,
bool uses_terminal = false, const std::string& depfile = "",
const std::string& job_pool = "", bool command_expand_lists = false,
bool stdPipesUTF8 = false);
@@ -187,11 +186,11 @@ public:
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,
- const CommandSourceCallback& callback = nullptr, 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);
+ const char* workingDir, const CommandSourceCallback& callback = nullptr,
+ 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);
void AddCustomCommandToOutput(
const std::vector<std::string>& outputs,
const std::vector<std::string>& byproducts,
@@ -199,18 +198,17 @@ public:
const std::string& main_dependency,
const cmImplicitDependsList& implicit_depends,
const cmCustomCommandLines& commandLines, const char* comment,
- const char* workingDir, cmPolicies::PolicyStatus cmp0116,
- const CommandSourceCallback& callback = nullptr, 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);
+ const char* workingDir, const CommandSourceCallback& callback = nullptr,
+ 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);
void AddCustomCommandOldStyle(const std::string& target,
const std::vector<std::string>& outputs,
const std::vector<std::string>& depends,
const std::string& source,
const cmCustomCommandLines& commandLines,
- const char* comment,
- cmPolicies::PolicyStatus cmp0116);
+ const char* comment);
void AppendCustomCommandToOutput(
const std::string& output, const std::vector<std::string>& depends,
const cmImplicitDependsList& implicit_depends,
@@ -256,10 +254,10 @@ public:
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);
+ const cmCustomCommandLines& commandLines, bool escapeOldStyle = true,
+ const char* comment = nullptr, bool uses_terminal = false,
+ bool command_expand_lists = false, const std::string& job_pool = "",
+ bool stdPipesUTF8 = false);
/**
* Add a subdirectory to the build.
diff --git a/Source/cmQTWrapCPPCommand.cxx b/Source/cmQTWrapCPPCommand.cxx
index ca0b259..cc4df8f 100644
--- a/Source/cmQTWrapCPPCommand.cxx
+++ b/Source/cmQTWrapCPPCommand.cxx
@@ -5,7 +5,6 @@
#include "cmCustomCommandLines.h"
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
-#include "cmPolicies.h"
#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmStringAlgorithms.h"
@@ -73,9 +72,9 @@ bool cmQTWrapCPPCommand(std::vector<std::string> const& args,
std::string no_main_dependency;
const char* no_working_dir = nullptr;
- mf.AddCustomCommandToOutput(
- newName, depends, no_main_dependency, commandLines, "Qt Wrapped File",
- no_working_dir, mf.GetPolicyStatus(cmPolicies::CMP0116));
+ mf.AddCustomCommandToOutput(newName, depends, no_main_dependency,
+ commandLines, "Qt Wrapped File",
+ no_working_dir);
}
}
diff --git a/Source/cmQTWrapUICommand.cxx b/Source/cmQTWrapUICommand.cxx
index f98f0b3..66c0228 100644
--- a/Source/cmQTWrapUICommand.cxx
+++ b/Source/cmQTWrapUICommand.cxx
@@ -5,7 +5,6 @@
#include "cmCustomCommandLines.h"
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
-#include "cmPolicies.h"
#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmStringAlgorithms.h"
@@ -88,19 +87,16 @@ bool cmQTWrapUICommand(std::vector<std::string> const& args,
const char* no_comment = nullptr;
const char* no_working_dir = nullptr;
mf.AddCustomCommandToOutput(hName, depends, no_main_dependency,
- hCommandLines, no_comment, no_working_dir,
- mf.GetPolicyStatus(cmPolicies::CMP0116));
+ hCommandLines, no_comment, no_working_dir);
depends.push_back(hName);
mf.AddCustomCommandToOutput(cxxName, depends, no_main_dependency,
- cxxCommandLines, no_comment, no_working_dir,
- mf.GetPolicyStatus(cmPolicies::CMP0116));
+ cxxCommandLines, no_comment, no_working_dir);
depends.clear();
depends.push_back(hName);
mf.AddCustomCommandToOutput(mocName, depends, no_main_dependency,
- mocCommandLines, no_comment, no_working_dir,
- mf.GetPolicyStatus(cmPolicies::CMP0116));
+ mocCommandLines, no_comment, no_working_dir);
}
}