Commit f151a577 authored by Daniel Eiband's avatar Daniel Eiband Committed by Brad King
Browse files

cmMakefile: Move enumerations into new header

The enumerations will also be used in cmLocalGenerator.
parent 28a2613d
......@@ -195,6 +195,7 @@ set(SRCS
cmCustomCommandGenerator.h
cmCustomCommandLines.cxx
cmCustomCommandLines.h
cmCustomCommandTypes.h
cmDefinitions.cxx
cmDefinitions.h
cmDepends.cxx
......
......@@ -8,6 +8,7 @@
#include "cmCheckCustomOutputs.h"
#include "cmCustomCommand.h"
#include "cmCustomCommandLines.h"
#include "cmCustomCommandTypes.h"
#include "cmExecutionStatus.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
......@@ -15,7 +16,6 @@
#include "cmPolicies.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
......@@ -55,7 +55,7 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
// Save all command lines.
cmCustomCommandLines commandLines;
cmTarget::CustomCommandType cctype = cmTarget::POST_BUILD;
cmCustomCommandType cctype = cmCustomCommandType::POST_BUILD;
enum tdoing
{
......@@ -139,11 +139,11 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
currentLine.clear();
}
} else if (copy == keyPRE_BUILD) {
cctype = cmTarget::PRE_BUILD;
cctype = cmCustomCommandType::PRE_BUILD;
} else if (copy == keyPRE_LINK) {
cctype = cmTarget::PRE_LINK;
cctype = cmCustomCommandType::PRE_LINK;
} else if (copy == keyPOST_BUILD) {
cctype = cmTarget::POST_BUILD;
cctype = cmCustomCommandType::POST_BUILD;
} else if (copy == keyVERBATIM) {
verbatim = true;
} else if (copy == keyAPPEND) {
......
......@@ -6,6 +6,7 @@
#include "cmCheckCustomOutputs.h"
#include "cmCustomCommandLines.h"
#include "cmCustomCommandTypes.h"
#include "cmExecutionStatus.h"
#include "cmGeneratorExpression.h"
#include "cmGlobalGenerator.h"
......@@ -214,7 +215,7 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args,
// Add the utility target to the makefile.
bool escapeOldStyle = !verbatim;
cmTarget* target = mf.AddUtilityCommand(
targetName, cmMakefile::TargetOrigin::Project, excludeFromAll,
targetName, cmCommandOrigin::Project, excludeFromAll,
working_directory.c_str(), byproducts, depends, commandLines,
escapeOldStyle, comment, uses_terminal, command_expand_lists, job_pool);
......
......@@ -220,7 +220,7 @@ void CCONV cmAddUtilityCommand(void* arg, const char* utilityName,
}
// Pass the call to the makefile instance.
mf->AddUtilityCommand(utilityName, cmMakefile::TargetOrigin::Project,
mf->AddUtilityCommand(utilityName, cmCommandOrigin::Project,
(all ? false : true), nullptr, depends2, commandLines);
}
void CCONV cmAddCustomCommand(void* arg, const char* source,
......@@ -319,16 +319,16 @@ void CCONV cmAddCustomCommandToTarget(void* arg, const char* target,
commandLines.push_back(commandLine);
// Select the command type.
cmTarget::CustomCommandType cctype = cmTarget::POST_BUILD;
cmCustomCommandType cctype = cmCustomCommandType::POST_BUILD;
switch (commandType) {
case CM_PRE_BUILD:
cctype = cmTarget::PRE_BUILD;
cctype = cmCustomCommandType::PRE_BUILD;
break;
case CM_PRE_LINK:
cctype = cmTarget::PRE_LINK;
cctype = cmCustomCommandType::PRE_LINK;
break;
case CM_POST_BUILD:
cctype = cmTarget::POST_BUILD;
cctype = cmCustomCommandType::POST_BUILD;
break;
}
......
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#ifndef cmCustomCommandTypes_h
#define cmCustomCommandTypes_h
#include "cmConfigure.h" // IWYU pragma: keep
/** Target custom command type */
enum class cmCustomCommandType
{
PRE_BUILD,
PRE_LINK,
POST_BUILD
};
/** Where the command originated from. */
enum class cmCommandOrigin
{
Project,
Generator
};
/** How to handle custom commands for object libraries */
enum class cmObjectLibraryCommands
{
Reject,
Accept
};
#endif
......@@ -105,8 +105,8 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
cmCustomCommandLines noCommandLines;
cmTarget* tgt = mf->AddUtilityCommand(
CMAKE_CHECK_BUILD_SYSTEM_TARGET, cmMakefile::TargetOrigin::Generator,
false, no_working_directory, no_depends, noCommandLines);
CMAKE_CHECK_BUILD_SYSTEM_TARGET, cmCommandOrigin::Generator, false,
no_working_directory, no_depends, noCommandLines);
cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg);
lg->AddGeneratorTarget(gt);
......@@ -152,10 +152,10 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
std::vector<std::string> byproducts;
byproducts.push_back(cm->GetGlobVerifyStamp());
mf->AddCustomCommandToTarget(CMAKE_CHECK_BUILD_SYSTEM_TARGET, byproducts,
no_depends, verifyCommandLines,
cmTarget::PRE_BUILD, "Checking File Globs",
no_working_directory, false);
mf->AddCustomCommandToTarget(
CMAKE_CHECK_BUILD_SYSTEM_TARGET, byproducts, no_depends,
verifyCommandLines, cmCustomCommandType::PRE_BUILD,
"Checking File Globs", no_working_directory, false);
// Ensure ZERO_CHECK always runs in Visual Studio using MSBuild,
// otherwise the prebuild command will not be run.
......
......@@ -193,7 +193,7 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets()
// Use no actual command lines so that the target itself is not
// considered always out of date.
cmTarget* allBuild = gen[0]->GetMakefile()->AddUtilityCommand(
"ALL_BUILD", cmMakefile::TargetOrigin::Generator, true, no_working_dir,
"ALL_BUILD", cmCommandOrigin::Generator, true, no_working_dir,
no_depends, no_commands, false, "Build all projects");
cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]);
......
......@@ -501,9 +501,8 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
const char* no_working_directory = nullptr;
std::vector<std::string> no_depends;
cmTarget* allbuild = mf->AddUtilityCommand(
"ALL_BUILD", cmMakefile::TargetOrigin::Generator, true,
no_working_directory, no_depends,
cmMakeSingleCommandLine({ "echo", "Build all projects" }));
"ALL_BUILD", cmCommandOrigin::Generator, true, no_working_directory,
no_depends, cmMakeSingleCommandLine({ "echo", "Build all projects" }));
cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root);
root->AddGeneratorTarget(allBuildGt);
......@@ -526,8 +525,8 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
this->ConvertToRelativeForMake(this->CurrentReRunCMakeMakefile);
cmSystemTools::ReplaceString(file, "\\ ", " ");
cmTarget* check = mf->AddUtilityCommand(
CMAKE_CHECK_BUILD_SYSTEM_TARGET, cmMakefile::TargetOrigin::Generator,
true, no_working_directory, no_depends,
CMAKE_CHECK_BUILD_SYSTEM_TARGET, cmCommandOrigin::Generator, true,
no_working_directory, no_depends,
cmMakeSingleCommandLine({ "make", "-f", file }));
cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root);
......@@ -558,8 +557,9 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
std::vector<std::string> no_byproducts;
gen->GetMakefile()->AddCustomCommandToTarget(
target->GetName(), no_byproducts, no_depends, commandLines,
cmTarget::POST_BUILD, "Depend check for xcode", dir.c_str(), true,
false, "", "", false, cmMakefile::AcceptObjectLibraryCommands);
cmCustomCommandType::POST_BUILD, "Depend check for xcode",
dir.c_str(), true, false, "", "", false,
cmObjectLibraryCommands::Accept);
}
if (!this->IsExcluded(target)) {
......
......@@ -7,6 +7,7 @@
#include "cmCustomCommand.h"
#include "cmCustomCommandGenerator.h"
#include "cmCustomCommandLines.h"
#include "cmCustomCommandTypes.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorExpression.h"
#include "cmGeneratorExpressionEvaluationFile.h"
......@@ -2356,7 +2357,7 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target,
if (this->GetGlobalGenerator()->IsMultiConfig()) {
this->Makefile->AddCustomCommandToTarget(
target->GetName(), outputs, no_deps, commandLines,
cmTarget::PRE_BUILD, no_message, no_current_dir);
cmCustomCommandType::PRE_BUILD, no_message, no_current_dir);
} else {
cmImplicitDependsList no_implicit_depends;
cmSourceFile* copy_rule = this->Makefile->AddCustomCommandToOutput(
......
......@@ -39,6 +39,7 @@
#include "cmStateDirectory.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmTargetLinkLibraryType.h"
#include "cmTest.h"
#include "cmTestGenerator.h" // IWYU pragma: keep
......@@ -840,10 +841,10 @@ bool cmMakefile::ValidateCustomCommand(
cmTarget* cmMakefile::AddCustomCommandToTarget(
const std::string& target, const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type,
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,
bool command_expand_lists, ObjectLibraryCommands objLibraryCommands)
bool command_expand_lists, cmObjectLibraryCommands objLibCommands)
{
// Find the target to which to add the custom command.
auto ti = this->Targets.find(target);
......@@ -884,7 +885,7 @@ cmTarget* cmMakefile::AddCustomCommandToTarget(
}
cmTarget* t = &ti->second;
if (objLibraryCommands == RejectObjectLibraryCommands &&
if (objLibCommands == cmObjectLibraryCommands::Reject &&
t->GetType() == cmStateEnums::OBJECT_LIBRARY) {
std::ostringstream e;
e << "Target \"" << target
......@@ -920,7 +921,7 @@ cmTarget* cmMakefile::AddCustomCommandToTarget(
void cmMakefile::CommitCustomCommandToTarget(
cmTarget* target, const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type,
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,
bool command_expand_lists)
......@@ -936,13 +937,13 @@ void cmMakefile::CommitCustomCommandToTarget(
cc.SetDepfile(depfile);
cc.SetJobPool(job_pool);
switch (type) {
case cmTarget::PRE_BUILD:
case cmCustomCommandType::PRE_BUILD:
target->AddPreBuildCommand(cc);
break;
case cmTarget::PRE_LINK:
case cmCustomCommandType::PRE_LINK:
target->AddPreLinkCommand(cc);
break;
case cmTarget::POST_BUILD:
case cmCustomCommandType::POST_BUILD:
target->AddPostBuildCommand(cc);
break;
}
......@@ -1157,9 +1158,9 @@ void cmMakefile::AddCustomCommandOldStyle(
// same then it added a post-build rule to the target. Preserve
// this behavior.
std::vector<std::string> no_byproducts;
this->AddCustomCommandToTarget(target, no_byproducts, depends,
commandLines, cmTarget::POST_BUILD, comment,
nullptr);
this->AddCustomCommandToTarget(
target, no_byproducts, depends, commandLines,
cmCustomCommandType::POST_BUILD, comment, nullptr);
return;
}
......@@ -1248,7 +1249,7 @@ void cmMakefile::CommitAppendCustomCommandToOutput(
}
cmTarget* cmMakefile::AddUtilityCommand(
const std::string& utilityName, TargetOrigin origin, bool excludeFromAll,
const std::string& utilityName, cmCommandOrigin origin, bool excludeFromAll,
const char* workingDirectory, const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines, bool escapeOldStyle,
const char* comment, bool uses_terminal, bool command_expand_lists,
......@@ -1262,7 +1263,7 @@ cmTarget* cmMakefile::AddUtilityCommand(
}
cmTarget* cmMakefile::AddUtilityCommand(
const std::string& utilityName, TargetOrigin origin, bool excludeFromAll,
const std::string& utilityName, cmCommandOrigin origin, bool excludeFromAll,
const char* workingDirectory, const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines, bool escapeOldStyle,
......@@ -1271,7 +1272,7 @@ cmTarget* cmMakefile::AddUtilityCommand(
{
// Create a target instance for this utility.
cmTarget* target = this->AddNewTarget(cmStateEnums::UTILITY, utilityName);
target->SetIsGeneratorProvided(origin == TargetOrigin::Generator);
target->SetIsGeneratorProvided(origin == cmCommandOrigin::Generator);
if (excludeFromAll || this->GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
}
......
......@@ -20,6 +20,7 @@
#include <cm/string_view>
#include "cmAlgorithms.h"
#include "cmCustomCommandTypes.h"
#include "cmListFileCache.h"
#include "cmMessageType.h"
#include "cmNewLineStyle.h"
......@@ -28,7 +29,10 @@
#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
#include "cmTarget.h"
// IWYU does not see that 'std::unordered_map<std::string, cmTarget>'
// will not compile without the complete type.
#include "cmTarget.h" // IWYU pragma: keep
#if !defined(CMAKE_BOOTSTRAP)
# include "cmSourceGroup.h"
......@@ -164,22 +168,15 @@ public:
*/
void FinalPass();
/** How to handle custom commands for object libraries */
enum ObjectLibraryCommands
{
RejectObjectLibraryCommands,
AcceptObjectLibraryCommands
};
/** Add a custom command to the build. */
cmTarget* AddCustomCommandToTarget(
const std::string& target, const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type,
const cmCustomCommandLines& commandLines, cmCustomCommandType type,
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,
ObjectLibraryCommands objLibraryCommands = RejectObjectLibraryCommands);
cmObjectLibraryCommands objLibCommands = cmObjectLibraryCommands::Reject);
cmSourceFile* AddCustomCommandToOutput(
const std::string& output, const std::vector<std::string>& depends,
const std::string& main_dependency,
......@@ -232,26 +229,21 @@ public:
const std::vector<std::string>& srcs,
bool excludeFromAll = false);
/** Where the target originated from. */
enum class TargetOrigin
{
Project,
Generator
};
/**
* 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, TargetOrigin origin, bool excludeFromAll,
const char* workingDirectory, const std::vector<std::string>& depends,
const std::string& utilityName, cmCommandOrigin origin,
bool excludeFromAll, const char* workingDirectory,
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 = "");
cmTarget* AddUtilityCommand(
const std::string& utilityName, TargetOrigin origin, bool excludeFromAll,
const char* workingDirectory, const std::vector<std::string>& byproducts,
const std::string& utilityName, cmCommandOrigin origin,
bool excludeFromAll, const char* workingDirectory,
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,
......@@ -1064,7 +1056,7 @@ private:
void CommitCustomCommandToTarget(
cmTarget* target, const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type,
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, bool command_expand_lists);
......
......@@ -3,6 +3,7 @@
#include "cmQtAutoGenGlobalInitializer.h"
#include "cmCustomCommandLines.h"
#include "cmCustomCommandTypes.h"
#include "cmDuration.h"
#include "cmGeneratorTarget.h"
#include "cmLocalGenerator.h"
......@@ -154,7 +155,7 @@ void cmQtAutoGenGlobalInitializer::GetOrCreateGlobalTarget(
// Create utility target
cmTarget* target = makefile->AddUtilityCommand(
name, cmMakefile::TargetOrigin::Generator, true,
name, cmCommandOrigin::Generator, true,
makefile->GetHomeOutputDirectory().c_str() /*work dir*/,
std::vector<std::string>() /*output*/,
std::vector<std::string>() /*depends*/, cmCustomCommandLines(), false,
......
......@@ -8,6 +8,7 @@
#include "cmAlgorithms.h"
#include "cmCustomCommand.h"
#include "cmCustomCommandLines.h"
#include "cmCustomCommandTypes.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
......@@ -1117,7 +1118,7 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
// Create autogen target
cmTarget* autogenTarget = this->Makefile->AddUtilityCommand(
this->AutogenTarget.Name, cmMakefile::TargetOrigin::Generator, true,
this->AutogenTarget.Name, cmCommandOrigin::Generator, true,
this->Dir.Work.c_str(), /*byproducts=*/autogenProvides,
std::vector<std::string>(this->AutogenTarget.DependFiles.begin(),
this->AutogenTarget.DependFiles.end()),
......@@ -1199,9 +1200,8 @@ bool cmQtAutoGenInitializer::InitRccTargets()
}
cmTarget* autoRccTarget = this->Makefile->AddUtilityCommand(
ccName, cmMakefile::TargetOrigin::Generator, true,
this->Dir.Work.c_str(), ccOutput, ccDepends, commandLines, false,
ccComment.c_str());
ccName, cmCommandOrigin::Generator, true, this->Dir.Work.c_str(),
ccOutput, ccDepends, commandLines, false, ccComment.c_str());
// Create autogen generator target
this->LocalGen->AddGeneratorTarget(
......
......@@ -43,13 +43,6 @@ public:
VisibilityImportedGlobally
};
enum CustomCommandType
{
PRE_BUILD,
PRE_LINK,
POST_BUILD
};
cmTarget(std::string const& name, cmStateEnums::TargetType type,
Visibility vis, cmMakefile* mf);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment