Merge topic 'cmCommand_refactor_disallowed'

54872b73b9 cmCommand refactor: remove cmDisallowedCommand class
11f35d340e cmCommand refactor: remove unused AddDisallowedCommand overload
ae51aa32f0 cmCommand refactor: cmVariableRequiresCommand
185fa2c4f3 cmCommand refactor: cmUtilitySourceCommand
c8deeac68f cmCommand refactor: cmSubdirDependsCommand
c2c222eba1 cmCommand refactor: cmOutputRequiredFilesCommand
7533e47ccc cmCommand refactor: cmLoadCommandCommand
9d6fc3f5ed cmCommand refactor: cmExportLibraryDependenciesCommand
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3736
This commit is contained in:
Brad King
2019-08-28 15:49:23 +00:00
committed by Kitware Robot
21 changed files with 116 additions and 300 deletions

View File

@@ -493,8 +493,6 @@ set(SRCS
cmCreateTestSourceList.h
cmDefinePropertyCommand.cxx
cmDefinePropertyCommand.h
cmDisallowedCommand.cxx
cmDisallowedCommand.h
cmEnableLanguageCommand.cxx
cmEnableLanguageCommand.h
cmEnableTestingCommand.cxx

View File

@@ -208,8 +208,7 @@ void GetScriptingCommands(cmState* state)
"build_name", cmBuildNameCommand, cmPolicies::CMP0036,
"The build_name command should not be called; see CMP0036.");
state->AddDisallowedCommand(
"use_mangled_mesa", cm::make_unique<cmUseMangledMesaCommand>(),
cmPolicies::CMP0030,
"use_mangled_mesa", cmUseMangledMesaCommand, cmPolicies::CMP0030,
"The use_mangled_mesa command should not be called; see CMP0030.");
#endif
@@ -310,29 +309,24 @@ void GetProjectCommands(cmState* state)
cm::make_unique<cmSourceGroupCommand>());
state->AddDisallowedCommand(
"export_library_dependencies",
cm::make_unique<cmExportLibraryDependenciesCommand>(), cmPolicies::CMP0033,
"export_library_dependencies", cmExportLibraryDependenciesCommand,
cmPolicies::CMP0033,
"The export_library_dependencies command should not be called; "
"see CMP0033.");
state->AddDisallowedCommand(
"load_command", cm::make_unique<cmLoadCommandCommand>(),
cmPolicies::CMP0031,
"load_command", cmLoadCommandCommand, cmPolicies::CMP0031,
"The load_command command should not be called; see CMP0031.");
state->AddDisallowedCommand(
"output_required_files", cm::make_unique<cmOutputRequiredFilesCommand>(),
cmPolicies::CMP0032,
"output_required_files", cmOutputRequiredFilesCommand, cmPolicies::CMP0032,
"The output_required_files command should not be called; see CMP0032.");
state->AddDisallowedCommand(
"subdir_depends", cm::make_unique<cmSubdirDependsCommand>(),
cmPolicies::CMP0029,
"subdir_depends", cmSubdirDependsCommand, cmPolicies::CMP0029,
"The subdir_depends command should not be called; see CMP0029.");
state->AddDisallowedCommand(
"utility_source", cm::make_unique<cmUtilitySourceCommand>(),
cmPolicies::CMP0034,
"utility_source", cmUtilitySourceCommand, cmPolicies::CMP0034,
"The utility_source command should not be called; see CMP0034.");
state->AddDisallowedCommand(
"variable_requires", cm::make_unique<cmVariableRequiresCommand>(),
cmPolicies::CMP0035,
"variable_requires", cmVariableRequiresCommand, cmPolicies::CMP0035,
"The variable_requires command should not be called; see CMP0035.");
#endif
}

View File

@@ -1,29 +0,0 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmDisallowedCommand.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
class cmExecutionStatus;
bool cmDisallowedCommand::InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
switch (this->Makefile->GetPolicyStatus(this->Policy)) {
case cmPolicies::WARN:
this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING,
cmPolicies::GetPolicyWarning(this->Policy));
break;
case cmPolicies::OLD:
break;
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::NEW:
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, this->Message);
return true;
}
this->Command->SetExecutionStatus(this->GetExecutionStatus());
return this->Command->InitialPass(args, status);
}

View File

@@ -1,47 +0,0 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#ifndef cmDisallowedCommand_h
#define cmDisallowedCommand_h
#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <utility>
#include <vector>
#include "cm_memory.hxx"
#include "cmCommand.h"
#include "cmPolicies.h"
class cmExecutionStatus;
class cmDisallowedCommand : public cmCommand
{
public:
cmDisallowedCommand(std::unique_ptr<cmCommand> command,
cmPolicies::PolicyID policy, const char* message)
: Command(std::move(command))
, Policy(policy)
, Message(message)
{
}
~cmDisallowedCommand() override = default;
std::unique_ptr<cmCommand> Clone() override
{
return cm::make_unique<cmDisallowedCommand>(this->Command->Clone(),
this->Policy, this->Message);
}
bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status) override;
private:
std::unique_ptr<cmCommand> Command;
cmPolicies::PolicyID Policy;
const char* Message;
};
#endif

View File

@@ -8,6 +8,7 @@
#include "cm_memory.hxx"
#include "cmExecutionStatus.h"
#include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
@@ -18,8 +19,6 @@
#include "cmTargetLinkLibraryType.h"
#include "cmake.h"
class cmExecutionStatus;
static void FinalAction(cmMakefile& makefile, std::string const& filename,
bool append)
{
@@ -140,19 +139,20 @@ static void FinalAction(cmMakefile& makefile, std::string const& filename,
fout << "endif()\n";
}
bool cmExportLibraryDependenciesCommand::InitialPass(
std::vector<std::string> const& args, cmExecutionStatus&)
bool cmExportLibraryDependenciesCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
if (args.empty()) {
this->SetError("called with incorrect number of arguments");
status.SetError("called with incorrect number of arguments");
return false;
}
std::string const& filename = args[0];
bool const append = args.size() > 1 && args[1] == "APPEND";
this->Makefile->AddFinalAction([filename, append](cmMakefile& makefile) {
FinalAction(makefile, filename, append);
});
status.GetMakefile().AddFinalAction(
[filename, append](cmMakefile& makefile) {
FinalAction(makefile, filename, append);
});
return true;
}

View File

@@ -8,21 +8,9 @@
#include <string>
#include <vector>
#include "cm_memory.hxx"
#include "cmCommand.h"
class cmExecutionStatus;
class cmExportLibraryDependenciesCommand : public cmCommand
{
public:
std::unique_ptr<cmCommand> Clone() override
{
return cm::make_unique<cmExportLibraryDependenciesCommand>();
}
bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status) override;
};
bool cmExportLibraryDependenciesCommand(std::vector<std::string> const& args,
cmExecutionStatus& status);
#endif

View File

@@ -14,14 +14,14 @@
#include "cmCPluginAPI.cxx"
#include "cmCPluginAPI.h"
#include "cmCommand.h"
#include "cmDynamicLoader.h"
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmState.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
class cmExecutionStatus;
#ifdef __QNX__
# include <malloc.h> /* for malloc/free on QNX */
#endif
@@ -175,8 +175,8 @@ bool cmLoadedCommand::InitialPass(std::vector<std::string> const& args,
} // namespace
// cmLoadCommandCommand
bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args,
cmExecutionStatus&)
bool cmLoadCommandCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
if (args.empty()) {
return true;
@@ -185,13 +185,13 @@ bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args,
// Construct a variable to report what file was loaded, if any.
// Start by removing the definition in case of failure.
std::string reportVar = cmStrCat("CMAKE_LOADED_COMMAND_", args[0]);
this->Makefile->RemoveDefinition(reportVar);
status.GetMakefile().RemoveDefinition(reportVar);
// the file must exist
std::string moduleName = cmStrCat(
this->Makefile->GetRequiredDefinition("CMAKE_SHARED_MODULE_PREFIX"), "cm",
args[0],
this->Makefile->GetRequiredDefinition("CMAKE_SHARED_MODULE_SUFFIX"));
status.GetMakefile().GetRequiredDefinition("CMAKE_SHARED_MODULE_PREFIX"),
"cm", args[0],
status.GetMakefile().GetRequiredDefinition("CMAKE_SHARED_MODULE_SUFFIX"));
// search for the file
std::vector<std::string> path;
@@ -209,7 +209,7 @@ bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args,
if (fullPath.empty()) {
std::ostringstream e;
e << "Attempt to load command failed from file \"" << moduleName << "\"";
this->SetError(e.str());
status.SetError(e.str());
return false;
}
@@ -224,12 +224,12 @@ bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args,
err += " Additional error info is:\n";
err += error;
}
this->SetError(err);
status.SetError(err);
return false;
}
// Report what file was loaded for this command.
this->Makefile->AddDefinition(reportVar, fullPath);
status.GetMakefile().AddDefinition(reportVar, fullPath);
// find the init function
std::string initFuncName = args[0] + "Init";
@@ -243,12 +243,12 @@ bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args,
// if the symbol is found call it to set the name on the
// function blocker
if (initFunction) {
this->Makefile->GetState()->AddScriptedCommand(
status.GetMakefile().GetState()->AddScriptedCommand(
args[0],
cmLegacyCommandWrapper(cm::make_unique<cmLoadedCommand>(initFunction)));
return true;
}
this->SetError("Attempt to load command failed. "
"No init function found.");
status.SetError("Attempt to load command failed. "
"No init function found.");
return false;
}

View File

@@ -8,21 +8,9 @@
#include <string>
#include <vector>
#include "cm_memory.hxx"
#include "cmCommand.h"
class cmExecutionStatus;
class cmLoadCommandCommand : public cmCommand
{
public:
std::unique_ptr<cmCommand> Clone() override
{
return cm::make_unique<cmLoadCommandCommand>();
}
bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status) override;
};
bool cmLoadCommandCommand(std::vector<std::string> const& args,
cmExecutionStatus& status);
#endif

View File

@@ -5,9 +5,12 @@
#include "cmsys/FStream.hxx"
#include "cmsys/RegularExpression.hxx"
#include <map>
#include <set>
#include <stdio.h>
#include <utility>
#include "cmAlgorithms.h"
#include "cmExecutionStatus.h"
#include "cmGeneratorExpression.h"
#include "cmMakefile.h"
#include "cmSourceFile.h"
@@ -15,8 +18,7 @@
#include "cmSystemTools.h"
#include "cmTarget.h"
class cmExecutionStatus;
namespace {
/** \class cmDependInformation
* \brief Store dependency information for a single source file.
*
@@ -452,43 +454,47 @@ protected:
DirectoryToFileToPathMapType DirectoryToFileToPathMap;
};
void ListDependencies(cmDependInformation const* info, FILE* fout,
std::set<cmDependInformation const*>* visited);
}
// cmOutputRequiredFilesCommand
bool cmOutputRequiredFilesCommand::InitialPass(
std::vector<std::string> const& args, cmExecutionStatus&)
bool cmOutputRequiredFilesCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
if (args.size() != 2) {
this->SetError("called with incorrect number of arguments");
status.SetError("called with incorrect number of arguments");
return false;
}
// store the arg for final pass
this->File = args[0];
this->OutputFile = args[1];
const std::string& file = args[0];
const std::string& outputFile = args[1];
// compute the list of files
cmLBDepend md;
md.SetMakefile(this->Makefile);
md.AddSearchPath(this->Makefile->GetCurrentSourceDirectory());
md.SetMakefile(&status.GetMakefile());
md.AddSearchPath(status.GetMakefile().GetCurrentSourceDirectory());
// find the depends for a file
const cmDependInformation* info = md.FindDependencies(this->File.c_str());
const cmDependInformation* info = md.FindDependencies(file.c_str());
if (info) {
// write them out
FILE* fout = cmsys::SystemTools::Fopen(this->OutputFile, "w");
FILE* fout = cmsys::SystemTools::Fopen(outputFile, "w");
if (!fout) {
this->SetError(cmStrCat("Can not open output file: ", this->OutputFile));
status.SetError(cmStrCat("Can not open output file: ", outputFile));
return false;
}
std::set<cmDependInformation const*> visited;
this->ListDependencies(info, fout, &visited);
ListDependencies(info, fout, &visited);
fclose(fout);
}
return true;
}
void cmOutputRequiredFilesCommand::ListDependencies(
cmDependInformation const* info, FILE* fout,
std::set<cmDependInformation const*>* visited)
namespace {
void ListDependencies(cmDependInformation const* info, FILE* fout,
std::set<cmDependInformation const*>* visited)
{
// add info to the visited set
visited->insert(info);
@@ -503,7 +509,8 @@ void cmOutputRequiredFilesCommand::ListDependencies(
fprintf(fout, "%s\n", d->FullPath.c_str());
}
}
this->ListDependencies(d, fout, visited);
ListDependencies(d, fout, visited);
}
}
}
}

View File

@@ -5,34 +5,12 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <set>
#include <stdio.h>
#include <string>
#include <vector>
#include "cm_memory.hxx"
#include "cmCommand.h"
class cmDependInformation;
class cmExecutionStatus;
class cmOutputRequiredFilesCommand : public cmCommand
{
public:
std::unique_ptr<cmCommand> Clone() override
{
return cm::make_unique<cmOutputRequiredFilesCommand>();
}
bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status) override;
void ListDependencies(cmDependInformation const* info, FILE* fout,
std::set<cmDependInformation const*>* visited);
private:
std::string File;
std::string OutputFile;
};
bool cmOutputRequiredFilesCommand(std::vector<std::string> const& args,
cmExecutionStatus& status);
#endif

View File

@@ -14,7 +14,6 @@
#include "cmCacheManager.h"
#include "cmCommand.h"
#include "cmDefinitions.h"
#include "cmDisallowedCommand.h"
#include "cmExecutionStatus.h"
#include "cmGlobVerificationManager.h"
#include "cmListFileCache.h"
@@ -485,16 +484,6 @@ void cmState::AddDisallowedCommand(std::string const& name,
});
}
void cmState::AddDisallowedCommand(std::string const& name,
std::unique_ptr<cmCommand> command,
cmPolicies::PolicyID policy,
const char* message)
{
this->AddBuiltinCommand(
name,
cm::make_unique<cmDisallowedCommand>(std::move(command), policy, message));
}
void cmState::AddUnexpectedCommand(std::string const& name, const char* error)
{
this->AddBuiltinCommand(

View File

@@ -159,9 +159,6 @@ public:
void AddBuiltinCommand(std::string const& name, BuiltinCommand command);
void AddDisallowedCommand(std::string const& name, BuiltinCommand command,
cmPolicies::PolicyID policy, const char* message);
void AddDisallowedCommand(std::string const& name,
std::unique_ptr<cmCommand> command,
cmPolicies::PolicyID policy, const char* message);
void AddUnexpectedCommand(std::string const& name, const char* error);
void AddScriptedCommand(std::string const& name, Command command);
void RemoveBuiltinCommand(std::string const& name);

View File

@@ -4,8 +4,8 @@
class cmExecutionStatus;
bool cmSubdirDependsCommand::InitialPass(std::vector<std::string> const&,
cmExecutionStatus&)
bool cmSubdirDependsCommand(std::vector<std::string> const&,
cmExecutionStatus&)
{
return true;
}

View File

@@ -8,21 +8,9 @@
#include <string>
#include <vector>
#include "cm_memory.hxx"
#include "cmCommand.h"
class cmExecutionStatus;
class cmSubdirDependsCommand : public cmCommand
{
public:
std::unique_ptr<cmCommand> Clone() override
{
return cm::make_unique<cmSubdirDependsCommand>();
}
bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status) override;
};
bool cmSubdirDependsCommand(std::vector<std::string> const& args,
cmExecutionStatus& status);
#endif

View File

@@ -5,26 +5,30 @@
#include "cmsys/FStream.hxx"
#include "cmsys/RegularExpression.hxx"
#include "cmExecutionStatus.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
class cmExecutionStatus;
namespace {
void CopyAndFullPathMesaHeader(const std::string& source,
const std::string& outdir);
}
bool cmUseMangledMesaCommand::InitialPass(std::vector<std::string> const& args,
cmExecutionStatus&)
bool cmUseMangledMesaCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
// expected two arguments:
// argument one: the full path to gl_mangle.h
// argument two : directory for output of edited headers
if (args.size() != 2) {
this->SetError("called with incorrect number of arguments");
status.SetError("called with incorrect number of arguments");
return false;
}
const std::string& inputDir = args[0];
std::string glh = cmStrCat(inputDir, "/gl.h");
if (!cmSystemTools::FileExists(glh)) {
std::string e = cmStrCat("Bad path to Mesa, could not find: ", glh, ' ');
this->SetError(e);
status.SetError(e);
return false;
}
const std::string& destDir = args[1];
@@ -37,14 +41,15 @@ bool cmUseMangledMesaCommand::InitialPass(std::vector<std::string> const& args,
cmSystemTools::MakeDirectory(destDir);
for (std::string const& f : files) {
std::string path = cmStrCat(inputDir, '/', f);
this->CopyAndFullPathMesaHeader(path, destDir);
CopyAndFullPathMesaHeader(path, destDir);
}
return true;
}
void cmUseMangledMesaCommand::CopyAndFullPathMesaHeader(
const std::string& source, const std::string& outdir)
namespace {
void CopyAndFullPathMesaHeader(const std::string& source,
const std::string& outdir)
{
std::string dir;
std::string file;
@@ -96,3 +101,4 @@ void cmUseMangledMesaCommand::CopyAndFullPathMesaHeader(
cmSystemTools::CopyFileIfDifferent(tempOutputFile, outFile);
cmSystemTools::RemoveFile(tempOutputFile);
}
}

View File

@@ -8,25 +8,9 @@
#include <string>
#include <vector>
#include "cm_memory.hxx"
#include "cmCommand.h"
class cmExecutionStatus;
class cmUseMangledMesaCommand : public cmCommand
{
public:
std::unique_ptr<cmCommand> Clone() override
{
return cm::make_unique<cmUseMangledMesaCommand>();
}
bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status) override;
protected:
void CopyAndFullPathMesaHeader(const std::string& source,
const std::string& outdir);
};
bool cmUseMangledMesaCommand(std::vector<std::string> const& args,
cmExecutionStatus& status);
#endif

View File

@@ -4,20 +4,19 @@
#include <string.h>
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmState.h"
#include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
class cmExecutionStatus;
// cmUtilitySourceCommand
bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args,
cmExecutionStatus&)
bool cmUtilitySourceCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
if (args.size() < 3) {
this->SetError("called with incorrect number of arguments");
status.SetError("called with incorrect number of arguments");
return false;
}
@@ -25,15 +24,15 @@ bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args,
// The first argument is the cache entry name.
std::string const& cacheEntry = *arg++;
const char* cacheValue = this->Makefile->GetDefinition(cacheEntry);
const char* cacheValue = status.GetMakefile().GetDefinition(cacheEntry);
// If it exists already and appears up to date then we are done. If
// the string contains "(IntDir)" but that is not the
// CMAKE_CFG_INTDIR setting then the value is out of date.
std::string const& intDir =
this->Makefile->GetRequiredDefinition("CMAKE_CFG_INTDIR");
status.GetMakefile().GetRequiredDefinition("CMAKE_CFG_INTDIR");
bool haveCacheValue = false;
if (this->Makefile->IsOn("CMAKE_CROSSCOMPILING")) {
if (status.GetMakefile().IsOn("CMAKE_CROSSCOMPILING")) {
haveCacheValue = (cacheValue != nullptr);
if (!haveCacheValue) {
std::string msg = cmStrCat(
@@ -44,7 +43,7 @@ bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args,
cmSystemTools::Message(msg, "Warning");
}
} else {
cmState* state = this->Makefile->GetState();
cmState* state = status.GetMakefile().GetState();
haveCacheValue = (cacheValue &&
(strstr(cacheValue, "(IntDir)") == nullptr ||
(intDir == "$(IntDir)")) &&
@@ -63,7 +62,7 @@ bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args,
// The third argument specifies the relative directory of the source
// of the utility.
std::string const& relativeSource = *arg++;
std::string utilitySource = this->Makefile->GetCurrentSourceDirectory();
std::string utilitySource = status.GetMakefile().GetCurrentSourceDirectory();
utilitySource = utilitySource + "/" + relativeSource;
// If the directory doesn't exist, the source has not been included.
@@ -81,11 +80,12 @@ bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args,
// The source exists.
const std::string& cmakeCFGout =
this->Makefile->GetRequiredDefinition("CMAKE_CFG_INTDIR");
std::string utilityDirectory = this->Makefile->GetCurrentBinaryDirectory();
status.GetMakefile().GetRequiredDefinition("CMAKE_CFG_INTDIR");
std::string utilityDirectory =
status.GetMakefile().GetCurrentBinaryDirectory();
std::string exePath;
if (this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH")) {
exePath = this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
if (status.GetMakefile().GetDefinition("EXECUTABLE_OUTPUT_PATH")) {
exePath = status.GetMakefile().GetDefinition("EXECUTABLE_OUTPUT_PATH");
}
if (!exePath.empty()) {
utilityDirectory = exePath;
@@ -95,21 +95,22 @@ bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args,
// Construct the cache entry for the executable's location.
std::string utilityExecutable = utilityDirectory + "/" + cmakeCFGout + "/" +
utilityName + this->Makefile->GetDefinition("CMAKE_EXECUTABLE_SUFFIX");
utilityName +
status.GetMakefile().GetDefinition("CMAKE_EXECUTABLE_SUFFIX");
// make sure we remove any /./ in the name
cmSystemTools::ReplaceString(utilityExecutable, "/./", "/");
// Enter the value into the cache.
this->Makefile->AddCacheDefinition(cacheEntry, utilityExecutable.c_str(),
"Path to an internal program.",
cmStateEnums::FILEPATH);
status.GetMakefile().AddCacheDefinition(
cacheEntry, utilityExecutable.c_str(), "Path to an internal program.",
cmStateEnums::FILEPATH);
// add a value into the cache that maps from the
// full path to the name of the project
cmSystemTools::ConvertToUnixSlashes(utilityExecutable);
this->Makefile->AddCacheDefinition(utilityExecutable, utilityName.c_str(),
"Executable to project name.",
cmStateEnums::INTERNAL);
status.GetMakefile().AddCacheDefinition(
utilityExecutable, utilityName.c_str(), "Executable to project name.",
cmStateEnums::INTERNAL);
return true;
}

View File

@@ -8,21 +8,9 @@
#include <string>
#include <vector>
#include "cm_memory.hxx"
#include "cmCommand.h"
class cmExecutionStatus;
class cmUtilitySourceCommand : public cmCommand
{
public:
std::unique_ptr<cmCommand> Clone() override
{
return cm::make_unique<cmUtilitySourceCommand>();
}
bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status) override;
};
bool cmUtilitySourceCommand(std::vector<std::string> const& args,
cmExecutionStatus& status);
#endif

View File

@@ -2,33 +2,32 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmVariableRequiresCommand.h"
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmState.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
class cmExecutionStatus;
// cmLibraryCommand
bool cmVariableRequiresCommand::InitialPass(
std::vector<std::string> const& args, cmExecutionStatus&)
bool cmVariableRequiresCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
if (args.size() < 3) {
this->SetError("called with incorrect number of arguments");
status.SetError("called with incorrect number of arguments");
return false;
}
std::string const& testVariable = args[0];
if (!this->Makefile->IsOn(testVariable)) {
if (!status.GetMakefile().IsOn(testVariable)) {
return true;
}
std::string const& resultVariable = args[1];
bool requirementsMet = true;
std::string notSet;
bool hasAdvanced = false;
cmState* state = this->Makefile->GetState();
cmState* state = status.GetMakefile().GetState();
for (unsigned int i = 2; i < args.size(); ++i) {
if (!this->Makefile->IsOn(args[i])) {
if (!status.GetMakefile().IsOn(args[i])) {
requirementsMet = false;
notSet += args[i];
notSet += "\n";
@@ -38,12 +37,12 @@ bool cmVariableRequiresCommand::InitialPass(
}
}
}
const char* reqVar = this->Makefile->GetDefinition(resultVariable);
const char* reqVar = status.GetMakefile().GetDefinition(resultVariable);
// if reqVar is unset, then set it to requirementsMet
// if reqVar is set to true, but requirementsMet is false , then
// set reqVar to false.
if (!reqVar || (!requirementsMet && this->Makefile->IsOn(reqVar))) {
this->Makefile->AddDefinitionBool(resultVariable, requirementsMet);
if (!reqVar || (!requirementsMet && status.GetMakefile().IsOn(reqVar))) {
status.GetMakefile().AddDefinitionBool(resultVariable, requirementsMet);
}
if (!requirementsMet) {

View File

@@ -8,21 +8,9 @@
#include <string>
#include <vector>
#include "cm_memory.hxx"
#include "cmCommand.h"
class cmExecutionStatus;
class cmVariableRequiresCommand : public cmCommand
{
public:
std::unique_ptr<cmCommand> Clone() override
{
return cm::make_unique<cmVariableRequiresCommand>();
}
bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status) override;
};
bool cmVariableRequiresCommand(std::vector<std::string> const& args,
cmExecutionStatus& status);
#endif

View File

@@ -297,7 +297,6 @@ CMAKE_CXX_SOURCES="\
cmDefinitions \
cmDepends \
cmDependsC \
cmDisallowedCommand \
cmDocumentationFormatter \
cmEnableLanguageCommand \
cmEnableTestingCommand \