|
|
@@ -4,6 +4,7 @@
|
|
|
|
|
|
#include <sstream>
|
|
|
|
|
|
+#include "cmExecutionStatus.h"
|
|
|
#include "cmMakefile.h"
|
|
|
#include "cmMessageType.h"
|
|
|
#include "cmPolicies.h"
|
|
|
@@ -12,27 +13,26 @@
|
|
|
#include "cmStateTypes.h"
|
|
|
#include "cmStringAlgorithms.h"
|
|
|
|
|
|
-class cmExecutionStatus;
|
|
|
-
|
|
|
// cmOptionCommand
|
|
|
-bool cmOptionCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
- cmExecutionStatus&)
|
|
|
+bool cmOptionCommand(std::vector<std::string> const& args,
|
|
|
+ cmExecutionStatus& status)
|
|
|
{
|
|
|
const bool argError = (args.size() < 2) || (args.size() > 3);
|
|
|
if (argError) {
|
|
|
std::string m = "called with incorrect number of arguments: ";
|
|
|
m += cmJoin(args, " ");
|
|
|
- this->SetError(m);
|
|
|
+ status.SetError(m);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
// Determine the state of the option policy
|
|
|
bool checkAndWarn = false;
|
|
|
{
|
|
|
- auto status = this->Makefile->GetPolicyStatus(cmPolicies::CMP0077);
|
|
|
+ auto policyStatus =
|
|
|
+ status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0077);
|
|
|
const auto* existsBeforeSet =
|
|
|
- this->Makefile->GetStateSnapshot().GetDefinition(args[0]);
|
|
|
- switch (status) {
|
|
|
+ status.GetMakefile().GetStateSnapshot().GetDefinition(args[0]);
|
|
|
+ switch (policyStatus) {
|
|
|
case cmPolicies::WARN:
|
|
|
checkAndWarn = (existsBeforeSet != nullptr);
|
|
|
break;
|
|
|
@@ -53,7 +53,7 @@ bool cmOptionCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
|
|
|
// See if a cache variable with this name already exists
|
|
|
// If so just make sure the doc state is correct
|
|
|
- cmState* state = this->Makefile->GetState();
|
|
|
+ cmState* state = status.GetMakefile().GetState();
|
|
|
const char* existingValue = state->GetCacheEntryValue(args[0]);
|
|
|
if (existingValue &&
|
|
|
(state->GetCacheEntryType(args[0]) != cmStateEnums::UNINITIALIZED)) {
|
|
|
@@ -67,12 +67,12 @@ bool cmOptionCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
initialValue = args[2];
|
|
|
}
|
|
|
bool init = cmIsOn(initialValue);
|
|
|
- this->Makefile->AddCacheDefinition(args[0], init ? "ON" : "OFF",
|
|
|
- args[1].c_str(), cmStateEnums::BOOL);
|
|
|
+ status.GetMakefile().AddCacheDefinition(args[0], init ? "ON" : "OFF",
|
|
|
+ args[1].c_str(), cmStateEnums::BOOL);
|
|
|
|
|
|
if (checkAndWarn) {
|
|
|
const auto* existsAfterSet =
|
|
|
- this->Makefile->GetStateSnapshot().GetDefinition(args[0]);
|
|
|
+ status.GetMakefile().GetStateSnapshot().GetDefinition(args[0]);
|
|
|
if (!existsAfterSet) {
|
|
|
std::ostringstream w;
|
|
|
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0077)
|
|
|
@@ -80,7 +80,7 @@ bool cmOptionCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
"For compatibility with older versions of CMake, option "
|
|
|
"is clearing the normal variable '"
|
|
|
<< args[0] << "'.";
|
|
|
- this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
|
|
|
+ status.GetMakefile().IssueMessage(MessageType::AUTHOR_WARNING, w.str());
|
|
|
}
|
|
|
}
|
|
|
return true;
|