1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

cmCustomCommand: Record value of CMP0116 at time of creation

This commit is contained in:
Kyle Edwards
2021-02-22 15:24:52 -05:00
parent 33d93089ef
commit f01f10e8fb
18 changed files with 190 additions and 145 deletions

View File

@@ -320,15 +320,16 @@ 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(),
escapeOldStyle, uses_terminal, depfile,
job_pool, command_expand_lists);
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);
} else if (target.empty()) {
// Target is empty, use the output.
mf.AddCustomCommandToOutput(
output, byproducts, depends, main_dependency, implicit_depends,
commandLines, comment, working.c_str(), nullptr, false, escapeOldStyle,
commandLines, comment, working.c_str(),
mf.GetPolicyStatus(cmPolicies::CMP0116), 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");
@@ -365,7 +366,8 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
// Use the old-style mode for backward compatibility.
mf.AddCustomCommandOldStyle(target, outputs, depends, source, commandLines,
comment);
comment,
mf.GetPolicyStatus(cmPolicies::CMP0116));
}
return true;

View File

@@ -10,6 +10,7 @@
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
@@ -213,8 +214,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, escapeOldStyle, comment, uses_terminal, command_expand_lists,
job_pool);
commandLines, mf.GetPolicyStatus(cmPolicies::CMP0116), escapeOldStyle,
comment, uses_terminal, command_expand_lists, job_pool);
// Add additional user-specified source files to the target.
target->AddSources(sources);

View File

@@ -222,7 +222,8 @@ 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);
commandLines,
mf->GetPolicyStatus(cmPolicies::CMP0116));
}
void CCONV cmAddCustomCommand(void* arg, const char* source,
@@ -263,7 +264,8 @@ 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);
commandLines, no_comment,
mf->GetPolicyStatus(cmPolicies::CMP0116));
}
void CCONV cmAddCustomCommandToOutput(void* arg, const char* output,
@@ -298,7 +300,8 @@ 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);
no_comment, no_working_dir,
mf->GetPolicyStatus(cmPolicies::CMP0116));
}
void CCONV cmAddCustomCommandToTarget(void* arg, const char* target,
@@ -340,7 +343,8 @@ 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);
cctype, no_comment, no_working_dir,
mf->GetPolicyStatus(cmPolicies::CMP0116));
}
static void addLinkLibrary(cmMakefile* mf, std::string const& target,

View File

@@ -140,3 +140,13 @@ void cmCustomCommand::SetJobPool(const std::string& job_pool)
{
this->JobPool = job_pool;
}
cmPolicies::PolicyStatus cmCustomCommand::GetCMP0116Status() const
{
return this->CMP0116Status;
}
void cmCustomCommand::SetCMP0116Status(cmPolicies::PolicyStatus cmp0116)
{
this->CMP0116Status = cmp0116;
}

View File

@@ -10,6 +10,7 @@
#include "cmCustomCommandLines.h"
#include "cmListFileCache.h"
#include "cmPolicies.h"
class cmImplicitDependsList
: public std::vector<std::pair<std::string, std::string>>
@@ -95,6 +96,10 @@ public:
const std::string& GetJobPool() const;
void SetJobPool(const std::string& job_pool);
/** Set/Get the CMP0116 status (used by the Ninja generator) */
cmPolicies::PolicyStatus GetCMP0116Status() const;
void SetCMP0116Status(cmPolicies::PolicyStatus cmp0116);
private:
std::vector<std::string> Outputs;
std::vector<std::string> Byproducts;
@@ -112,4 +117,5 @@ private:
bool UsesTerminal = false;
bool CommandExpandLists = false;
bool StdPipesUTF8 = false;
cmPolicies::PolicyStatus CMP0116Status = cmPolicies::WARN;
};

View File

@@ -10,6 +10,7 @@
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmStringAlgorithms.h"
@@ -98,9 +99,11 @@ 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);
commandLines, no_comment, no_working_dir,
mf.GetPolicyStatus(cmPolicies::CMP0116));
mf.AddCustomCommandToOutput(hname, depends, no_main_dependency,
commandLines, no_comment, no_working_dir);
commandLines, no_comment, no_working_dir,
mf.GetPolicyStatus(cmPolicies::CMP0116));
cmSourceFile* sf = mf.GetSource(cxxres);
sf->AddDepend(hname);

View File

@@ -108,9 +108,9 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
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);
cmTarget* tgt = lg.AddUtilityCommand(
CMAKE_CHECK_BUILD_SYSTEM_TARGET, false, no_working_directory,
no_byproducts, no_depends, no_commands, cmPolicies::NEW);
auto ptr = cm::make_unique<cmGeneratorTarget>(tgt, &lg);
auto gt = ptr.get();
@@ -160,10 +160,11 @@ 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, stdPipesUTF8);
lg.AddCustomCommandToTarget(CMAKE_CHECK_BUILD_SYSTEM_TARGET, byproducts,
no_depends, verifyCommandLines,
cmCustomCommandType::PRE_BUILD,
"Checking File Globs", no_working_directory,
cmPolicies::NEW, stdPipesUTF8);
// Ensure ZERO_CHECK always runs in Visual Studio using MSBuild,
// otherwise the prebuild command will not be run.
@@ -195,8 +196,8 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
if (cmSourceFile* file = lg.AddCustomCommandToOutput(
stamps, no_byproducts, listFiles, no_main_dependency,
no_implicit_depends, commandLines, "Checking Build System",
no_working_directory, true, false, false, false, "", "",
stdPipesUTF8)) {
no_working_directory, cmPolicies::NEW, true, false, false, false, "",
"", stdPipesUTF8)) {
gt->AddSource(file->ResolveFullPath());
} else {
cmSystemTools::Error("Error adding rule for " + stamps[0]);

View File

@@ -200,7 +200,7 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets()
// considered always out of date.
cmTarget* allBuild = gen[0]->AddUtilityCommand(
"ALL_BUILD", true, no_working_dir, no_byproducts, no_depends,
no_commands, false, "Build all projects");
no_commands, cmPolicies::NEW, false, "Build all projects");
gen[0]->AddGeneratorTarget(
cm::make_unique<cmGeneratorTarget>(allBuild, gen[0]));

View File

@@ -620,7 +620,8 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
// Add ALL_BUILD
cmTarget* allbuild = root->AddUtilityCommand(
"ALL_BUILD", true, no_working_directory, no_byproducts, no_depends,
cmMakeSingleCommandLine({ "echo", "Build all projects" }));
cmMakeSingleCommandLine({ "echo", "Build all projects" }),
cmPolicies::NEW);
root->AddGeneratorTarget(cm::make_unique<cmGeneratorTarget>(allbuild, root));
@@ -646,10 +647,10 @@ 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 }));
cmTarget* check = root->AddUtilityCommand(
CMAKE_CHECK_BUILD_SYSTEM_TARGET, true, no_working_directory,
no_byproducts, no_depends,
cmMakeSingleCommandLine({ "make", "-f", file }), cmPolicies::NEW);
root->AddGeneratorTarget(cm::make_unique<cmGeneratorTarget>(check, root));
}
@@ -678,8 +679,9 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
gen->AddCustomCommandToTarget(
target->GetName(), no_byproducts, no_depends,
legacyDependHelperCommandLines, cmCustomCommandType::POST_BUILD,
"Depend check for xcode", legacyDependHelperDir.c_str(), true, false,
"", "", false, cmObjectLibraryCommands::Accept);
"Depend check for xcode", legacyDependHelperDir.c_str(),
cmPolicies::NEW, true, false, "", "", false,
cmObjectLibraryCommands::Accept);
}
if (!this->IsExcluded(gens[0], target.get())) {

View File

@@ -1056,8 +1056,9 @@ 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, bool escapeOldStyle,
bool uses_terminal, const std::string& depfile, const std::string& job_pool,
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)
{
@@ -1070,7 +1071,8 @@ cmTarget* cmLocalGenerator::AddCustomCommandToTarget(
detail::AddCustomCommandToTarget(
*this, this->DirectoryBacktrace, cmCommandOrigin::Generator, t, byproducts,
depends, commandLines, type, comment, workingDir, escapeOldStyle,
uses_terminal, depfile, job_pool, command_expand_lists, stdPipesUTF8);
uses_terminal, depfile, job_pool, command_expand_lists, stdPipesUTF8,
cmp0116);
return t;
}
@@ -1078,16 +1080,17 @@ 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, bool replace,
bool escapeOldStyle, bool uses_terminal, bool command_expand_lists,
const std::string& depfile, const std::string& job_pool, bool stdPipesUTF8)
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, replace, escapeOldStyle, uses_terminal,
command_expand_lists, depfile, job_pool, stdPipesUTF8);
commandLines, comment, workingDir, cmp0116, replace, escapeOldStyle,
uses_terminal, command_expand_lists, depfile, job_pool, stdPipesUTF8);
}
cmSourceFile* cmLocalGenerator::AddCustomCommandToOutput(
@@ -1096,9 +1099,9 @@ cmSourceFile* cmLocalGenerator::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, 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, 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)
{
// Make sure there is at least one output.
if (outputs.empty()) {
@@ -1110,16 +1113,16 @@ cmSourceFile* cmLocalGenerator::AddCustomCommandToOutput(
*this, this->DirectoryBacktrace, cmCommandOrigin::Generator, outputs,
byproducts, depends, main_dependency, implicit_depends, commandLines,
comment, workingDir, replace, escapeOldStyle, uses_terminal,
command_expand_lists, depfile, job_pool, stdPipesUTF8);
command_expand_lists, depfile, job_pool, stdPipesUTF8, cmp0116);
}
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, bool escapeOldStyle,
const char* comment, bool uses_terminal, bool command_expand_lists,
const std::string& job_pool, bool stdPipesUTF8)
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)
{
cmTarget* target =
this->Makefile->AddNewUtilityTarget(utilityName, excludeFromAll);
@@ -1132,7 +1135,7 @@ cmTarget* cmLocalGenerator::AddUtilityCommand(
detail::AddUtilityCommand(
*this, this->DirectoryBacktrace, cmCommandOrigin::Generator, target,
workingDir, byproducts, depends, commandLines, escapeOldStyle, comment,
uses_terminal, command_expand_lists, job_pool, stdPipesUTF8);
uses_terminal, command_expand_lists, job_pool, stdPipesUTF8, cmp0116);
return target;
}
@@ -2739,6 +2742,7 @@ void cmLocalGenerator::CopyPchCompilePdb(
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;
@@ -2748,14 +2752,15 @@ void cmLocalGenerator::CopyPchCompilePdb(
if (this->GetGlobalGenerator()->IsVisualStudio()) {
this->AddCustomCommandToTarget(
target->GetName(), outputs, no_deps, commandLines,
cmCustomCommandType::PRE_BUILD, no_message, no_current_dir, true, false,
"", "", false, cmObjectLibraryCommands::Accept, stdPipesUTF8);
cmCustomCommandType::PRE_BUILD, no_message, no_current_dir, cmp0116_new,
true, false, "", "", false, cmObjectLibraryCommands::Accept,
stdPipesUTF8);
} 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, false, true, false, false, "",
"", stdPipesUTF8);
commandLines, no_message, no_current_dir, cmp0116_new, false, true,
false, false, "", "", stdPipesUTF8);
if (copy_rule) {
target->AddSource(copy_rule->ResolveFullPath());
@@ -3960,7 +3965,8 @@ cmSourceFile* AddCustomCommand(
const cmCustomCommandLines& commandLines, const char* comment,
const char* workingDir, 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& job_pool, bool stdPipesUTF8,
cmPolicies::PolicyStatus cmp0116)
{
cmMakefile* mf = lg.GetMakefile();
@@ -4032,6 +4038,7 @@ cmSourceFile* AddCustomCommand(
cc->SetCommandExpandLists(command_expand_lists);
cc->SetDepfile(depfile);
cc->SetJobPool(job_pool);
cc->SetCMP0116Status(cmp0116);
file->SetCustomCommand(std::move(cc));
lg.AddSourceOutputs(file, outputs, cmLocalGenerator::OutputRole::Primary,
@@ -4076,7 +4083,8 @@ void AddCustomCommandToTarget(cmLocalGenerator& lg,
const char* workingDir, bool escapeOldStyle,
bool uses_terminal, const std::string& depfile,
const std::string& job_pool,
bool command_expand_lists, bool stdPipesUTF8)
bool command_expand_lists, bool stdPipesUTF8,
cmPolicies::PolicyStatus cmp0116)
{
// Add the command to the appropriate build step for the target.
std::vector<std::string> no_output;
@@ -4088,6 +4096,7 @@ void AddCustomCommandToTarget(cmLocalGenerator& lg,
cc.SetCommandExpandLists(command_expand_lists);
cc.SetDepfile(depfile);
cc.SetJobPool(job_pool);
cc.SetCMP0116Status(cmp0116);
switch (type) {
case cmCustomCommandType::PRE_BUILD:
target->AddPreBuildCommand(std::move(cc));
@@ -4112,13 +4121,14 @@ cmSourceFile* AddCustomCommandToOutput(
const cmCustomCommandLines& commandLines, const char* comment,
const char* workingDir, 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& job_pool, bool stdPipesUTF8,
cmPolicies::PolicyStatus cmp0116)
{
return AddCustomCommand(lg, lfbt, origin, outputs, byproducts, depends,
main_dependency, implicit_depends, commandLines,
comment, workingDir, replace, escapeOldStyle,
uses_terminal, command_expand_lists, depfile,
job_pool, stdPipesUTF8);
job_pool, stdPipesUTF8, cmp0116);
}
void AppendCustomCommandToOutput(cmLocalGenerator& lg,
@@ -4169,7 +4179,8 @@ void AddUtilityCommand(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt,
const cmCustomCommandLines& commandLines,
bool escapeOldStyle, const char* comment,
bool uses_terminal, bool command_expand_lists,
const std::string& job_pool, bool stdPipesUTF8)
const std::string& job_pool, bool stdPipesUTF8,
cmPolicies::PolicyStatus cmp0116)
{
// Use an empty comment to avoid generation of default comment.
if (!comment) {
@@ -4186,7 +4197,7 @@ void AddUtilityCommand(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt,
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);
/*depfile=*/"", job_pool, stdPipesUTF8, cmp0116);
if (rule) {
lg.AddTargetByproducts(target, byproducts, lfbt, origin);
}

View File

@@ -324,7 +324,8 @@ 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, bool escapeOldStyle = true,
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,
@@ -337,7 +338,8 @@ 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, bool replace = false, bool escapeOldStyle = true,
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);
@@ -348,7 +350,8 @@ public:
const std::string& main_dependency,
const cmImplicitDependsList& implicit_depends,
const cmCustomCommandLines& commandLines, const char* comment,
const char* workingDir, bool replace = false, bool escapeOldStyle = true,
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);
@@ -361,10 +364,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, 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, 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);
virtual std::string CreateUtilityOutput(
std::string const& targetName, std::vector<std::string> const& byproducts,
@@ -686,7 +689,8 @@ void AddCustomCommandToTarget(cmLocalGenerator& lg,
const char* workingDir, bool escapeOldStyle,
bool uses_terminal, const std::string& depfile,
const std::string& job_pool,
bool command_expand_lists, bool stdPipesUTF8);
bool command_expand_lists, bool stdPipesUTF8,
cmPolicies::PolicyStatus cmp0116);
cmSourceFile* AddCustomCommandToOutput(
cmLocalGenerator& lg, const cmListFileBacktrace& lfbt,
@@ -697,7 +701,8 @@ cmSourceFile* AddCustomCommandToOutput(
const cmCustomCommandLines& commandLines, const char* comment,
const char* workingDir, 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& job_pool, bool stdPipesUTF8,
cmPolicies::PolicyStatus cmp0116);
void AppendCustomCommandToOutput(cmLocalGenerator& lg,
const cmListFileBacktrace& lfbt,
@@ -714,7 +719,8 @@ void AddUtilityCommand(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt,
const cmCustomCommandLines& commandLines,
bool escapeOldStyle, const char* comment,
bool uses_terminal, bool command_expand_lists,
const std::string& job_pool, bool stdPipesUTF8);
const std::string& job_pool, bool stdPipesUTF8,
cmPolicies::PolicyStatus cmp0116);
std::vector<std::string> ComputeISPCObjectSuffixes(cmGeneratorTarget* target);
std::vector<std::string> ComputeISPCExtraObjects(

View File

@@ -121,7 +121,7 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets()
}
if (cmSourceFile* file = this->AddCustomCommandToOutput(
force, no_depends, no_main_dependency, force_commands, " ",
nullptr, true)) {
nullptr, cmPolicies::NEW, true)) {
l->AddSource(file->ResolveFullPath());
}
}
@@ -245,9 +245,10 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
"--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, true, false, false, false, "", "", stdPipesUTF8);
this->AddCustomCommandToOutput(stampName, listFiles, makefileIn,
commandLines, comment.c_str(),
no_working_directory, cmPolicies::NEW, true,
false, false, false, "", "", stdPipesUTF8);
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.

View File

@@ -1085,8 +1085,9 @@ 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, bool escapeOldStyle,
bool uses_terminal, const std::string& depfile, const std::string& job_pool,
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, bool stdPipesUTF8)
{
cmTarget* t = this->GetCustomCommandTarget(
@@ -1112,7 +1113,7 @@ cmTarget* cmMakefile::AddCustomCommandToTarget(
lg, lfbt, cmCommandOrigin::Project, t, byproducts, depends,
commandLines, type, GetCStrOrNull(commentStr),
GetCStrOrNull(workingStr), escapeOldStyle, uses_terminal, depfile,
job_pool, command_expand_lists, stdPipesUTF8);
job_pool, command_expand_lists, stdPipesUTF8, cmp0116);
});
return t;
@@ -1122,16 +1123,18 @@ 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,
const CommandSourceCallback& callback, bool replace, bool escapeOldStyle,
bool uses_terminal, bool command_expand_lists, const std::string& depfile,
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)
{
std::vector<std::string> no_byproducts;
cmImplicitDependsList no_implicit_depends;
this->AddCustomCommandToOutput(
{ output }, no_byproducts, depends, main_dependency, no_implicit_depends,
commandLines, comment, workingDir, callback, replace, escapeOldStyle,
uses_terminal, command_expand_lists, depfile, job_pool, stdPipesUTF8);
commandLines, comment, workingDir, cmp0116, callback, replace,
escapeOldStyle, uses_terminal, command_expand_lists, depfile, job_pool,
stdPipesUTF8);
}
void cmMakefile::AddCustomCommandToOutput(
@@ -1140,9 +1143,10 @@ 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, 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, 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)
{
// Make sure there is at least one output.
if (outputs.empty()) {
@@ -1172,7 +1176,7 @@ void cmMakefile::AddCustomCommandToOutput(
main_dependency, implicit_depends, commandLines,
GetCStrOrNull(commentStr), GetCStrOrNull(workingStr), replace,
escapeOldStyle, uses_terminal, command_expand_lists, depfile, job_pool,
stdPipesUTF8);
stdPipesUTF8, cmp0116);
if (callback && sf) {
callback(sf);
}
@@ -1182,7 +1186,8 @@ 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)
const cmCustomCommandLines& commandLines, const char* comment,
cmPolicies::PolicyStatus cmp0116)
{
// Translate the old-style signature to one of the new-style
// signatures.
@@ -1193,7 +1198,7 @@ void cmMakefile::AddCustomCommandOldStyle(
std::vector<std::string> no_byproducts;
this->AddCustomCommandToTarget(
target, no_byproducts, depends, commandLines,
cmCustomCommandType::POST_BUILD, comment, nullptr);
cmCustomCommandType::POST_BUILD, comment, nullptr, cmp0116);
return;
}
@@ -1226,7 +1231,8 @@ 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, addRuleFileToTarget);
comment, nullptr, cmp0116,
addRuleFileToTarget);
}
} else {
std::string no_main_dependency;
@@ -1236,7 +1242,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,
commandLines, comment, nullptr, cmp0116,
addRuleFileToTarget);
}
}
@@ -1263,9 +1269,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, bool escapeOldStyle,
const char* comment, bool uses_terminal, bool command_expand_lists,
const std::string& job_pool, bool stdPipesUTF8)
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)
{
cmTarget* target = this->AddNewUtilityTarget(utilityName, excludeFromAll);
@@ -1286,11 +1292,11 @@ cmTarget* cmMakefile::AddUtilityCommand(
this->AddGeneratorAction(
[=](cmLocalGenerator& lg, const cmListFileBacktrace& lfbt) {
BacktraceGuard guard(this->Backtrace, lfbt);
detail::AddUtilityCommand(lg, lfbt, cmCommandOrigin::Project, target,
GetCStrOrNull(workingStr), byproducts, depends,
commandLines, escapeOldStyle,
GetCStrOrNull(commentStr), uses_terminal,
command_expand_lists, job_pool, stdPipesUTF8);
detail::AddUtilityCommand(
lg, lfbt, cmCommandOrigin::Project, target, GetCStrOrNull(workingStr),
byproducts, depends, commandLines, escapeOldStyle,
GetCStrOrNull(commentStr), uses_terminal, command_expand_lists,
job_pool, stdPipesUTF8, cmp0116);
});
return target;

View File

@@ -169,7 +169,8 @@ 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, bool escapeOldStyle = true,
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,
bool stdPipesUTF8 = false);
@@ -186,11 +187,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, 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, 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);
void AddCustomCommandToOutput(
const std::vector<std::string>& outputs,
const std::vector<std::string>& byproducts,
@@ -198,17 +199,18 @@ public:
const std::string& main_dependency,
const cmImplicitDependsList& implicit_depends,
const cmCustomCommandLines& commandLines, const char* comment,
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);
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);
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);
const char* comment,
cmPolicies::PolicyStatus cmp0116);
void AppendCustomCommandToOutput(
const std::string& output, const std::vector<std::string>& depends,
const cmImplicitDependsList& implicit_depends,
@@ -250,10 +252,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, 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, 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);
/**
* Add a subdirectory to the build.

View File

@@ -5,6 +5,7 @@
#include "cmCustomCommandLines.h"
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmPolicies.h"
#include "cmProperty.h"
#include "cmRange.h"
#include "cmSourceFile.h"
@@ -73,9 +74,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.AddCustomCommandToOutput(
newName, depends, no_main_dependency, commandLines, "Qt Wrapped File",
no_working_dir, mf.GetPolicyStatus(cmPolicies::CMP0116));
}
}

View File

@@ -5,6 +5,7 @@
#include "cmCustomCommandLines.h"
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmPolicies.h"
#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmStringAlgorithms.h"
@@ -87,16 +88,19 @@ 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);
hCommandLines, no_comment, no_working_dir,
mf.GetPolicyStatus(cmPolicies::CMP0116));
depends.push_back(hName);
mf.AddCustomCommandToOutput(cxxName, depends, no_main_dependency,
cxxCommandLines, no_comment, no_working_dir);
cxxCommandLines, no_comment, no_working_dir,
mf.GetPolicyStatus(cmPolicies::CMP0116));
depends.clear();
depends.push_back(hName);
mf.AddCustomCommandToOutput(mocName, depends, no_main_dependency,
mocCommandLines, no_comment, no_working_dir);
mocCommandLines, no_comment, no_working_dir,
mf.GetPolicyStatus(cmPolicies::CMP0116));
}
}

View File

@@ -13,6 +13,7 @@
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmProcessOutput.h"
#include "cmProperty.h"
#include "cmQtAutoGen.h"
@@ -167,9 +168,10 @@ void cmQtAutoGenGlobalInitializer::GetOrCreateGlobalTarget(
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, false, comment.c_str());
no_depends, no_commands, cmp0116_new, false, comment.c_str());
localGen->AddGeneratorTarget(
cm::make_unique<cmGeneratorTarget>(target, localGen));

View File

@@ -30,7 +30,6 @@
#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
#include "cmGlobalNinjaGenerator.h"
#include "cmLinkItem.h"
#include "cmListFileCache.h"
#include "cmLocalGenerator.h"
@@ -1226,7 +1225,8 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
cmTarget* timestampTarget = this->LocalGen->AddUtilityCommand(
timestampTargetName, true, this->Dir.Work.c_str(),
/*byproducts=*/timestampTargetProvides,
/*depends=*/dependencies, timestampTargetCommandLines, false, nullptr);
/*depends=*/dependencies, timestampTargetCommandLines, cmPolicies::NEW,
false, nullptr);
this->LocalGen->AddGeneratorTarget(
cm::make_unique<cmGeneratorTarget>(timestampTarget, this->LocalGen));
@@ -1257,27 +1257,8 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
const std::string outputFile =
cmStrCat(this->Dir.Build, "/", timestampFileName);
this->AutogenTarget.DepFile = cmStrCat(this->Dir.Build, "/deps");
std::string relativeBinaryDir;
if (dynamic_cast<cmGlobalNinjaGenerator*>(this->GlobalGen)) {
switch (this->LocalGen->GetPolicyStatus(cmPolicies::CMP0116)) {
case cmPolicies::OLD:
case cmPolicies::WARN:
relativeBinaryDir = cmSystemTools::RelativePath(
this->LocalGen->GetBinaryDirectory(),
this->LocalGen->GetCurrentBinaryDirectory());
if (!relativeBinaryDir.empty()) {
relativeBinaryDir = cmStrCat(relativeBinaryDir, "/");
}
break;
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::NEW:
break;
}
}
this->AutogenTarget.DepFileRuleName =
cmStrCat(relativeBinaryDir, this->GenTarget->GetName(), "_autogen/",
timestampFileName);
cmStrCat(this->GenTarget->GetName(), "_autogen/", timestampFileName);
commandLines.push_back(cmMakeCommandLine(
{ cmSystemTools::GetCMakeCommand(), "-E", "touch", outputFile }));
@@ -1285,7 +1266,8 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
const std::string no_main_dependency;
this->LocalGen->AddCustomCommandToOutput(
outputFile, dependencies, no_main_dependency, commandLines,
autogenComment.c_str(), this->Dir.Work.c_str(), /*replace=*/false,
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, "",
@@ -1303,7 +1285,8 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
cmTarget* autogenTarget = this->LocalGen->AddUtilityCommand(
this->AutogenTarget.Name, true, this->Dir.Work.c_str(),
/*byproducts=*/autogenByproducts,
/*depends=*/dependencies, commandLines, false, autogenComment.c_str());
/*depends=*/dependencies, commandLines, cmPolicies::NEW, false,
autogenComment.c_str());
// Create autogen generator target
this->LocalGen->AddGeneratorTarget(
cm::make_unique<cmGeneratorTarget>(autogenTarget, this->LocalGen));
@@ -1389,8 +1372,8 @@ bool cmQtAutoGenInitializer::InitRccTargets()
cmTarget* autoRccTarget = this->LocalGen->AddUtilityCommand(
ccName, true, this->Dir.Work.c_str(), ccOutput, ccDepends,
commandLines, false, ccComment.c_str(), false, false, "",
stdPipesUTF8);
commandLines, cmPolicies::NEW, false, ccComment.c_str(), false,
false, "", stdPipesUTF8);
// Create autogen generator target
this->LocalGen->AddGeneratorTarget(
@@ -1430,8 +1413,8 @@ bool cmQtAutoGenInitializer::InitRccTargets()
this->LocalGen->AddCustomCommandToOutput(
ccOutput, ccByproducts, ccDepends, no_main_dependency,
no_implicit_depends, commandLines, ccComment.c_str(),
this->Dir.Work.c_str(), false, true, false, false, "", "",
stdPipesUTF8);
this->Dir.Work.c_str(), cmPolicies::NEW, false, true, false, false,
"", "", stdPipesUTF8);
}
// Reconfigure when .qrc file changes
this->Makefile->AddCMakeDependFile(qrc.QrcFile);