1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #include "cmOptionCommand.h"
- #include "cmAlgorithms.h"
- #include "cmMakefile.h"
- #include "cmState.h"
- #include "cmStateTypes.h"
- #include "cmSystemTools.h"
- class cmExecutionStatus;
- bool cmOptionCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
- {
- bool argError = false;
- if (args.size() < 2) {
- argError = true;
- }
-
-
-
-
- if (this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION")) {
- if (args.size() > 3) {
- argError = true;
- }
- }
- if (argError) {
- std::string m = "called with incorrect number of arguments: ";
- m += cmJoin(args, " ");
- this->SetError(m);
- return false;
- }
- std::string initialValue = "Off";
-
-
- cmState* state = this->Makefile->GetState();
- const char* existingValue = state->GetCacheEntryValue(args[0]);
- if (existingValue) {
- if (state->GetCacheEntryType(args[0]) != cmStateEnums::UNINITIALIZED) {
- state->SetCacheEntryProperty(args[0], "HELPSTRING", args[1]);
- return true;
- }
- initialValue = existingValue;
- }
- if (args.size() == 3) {
- initialValue = args[2];
- }
- bool init = cmSystemTools::IsOn(initialValue.c_str());
- this->Makefile->AddCacheDefinition(args[0], init ? "ON" : "OFF",
- args[1].c_str(), cmStateEnums::BOOL);
- return true;
- }
|