|
@@ -10,6 +10,7 @@
|
|
|
#include <limits>
|
|
#include <limits>
|
|
|
#include <utility>
|
|
#include <utility>
|
|
|
|
|
|
|
|
|
|
+#include "cmExecutionStatus.h"
|
|
|
#include "cmMakefile.h"
|
|
#include "cmMakefile.h"
|
|
|
#include "cmMessageType.h"
|
|
#include "cmMessageType.h"
|
|
|
#include "cmPolicies.h"
|
|
#include "cmPolicies.h"
|
|
@@ -17,40 +18,39 @@
|
|
|
#include "cmStringAlgorithms.h"
|
|
#include "cmStringAlgorithms.h"
|
|
|
#include "cmSystemTools.h"
|
|
#include "cmSystemTools.h"
|
|
|
|
|
|
|
|
-class cmExecutionStatus;
|
|
|
|
|
|
|
+static bool IncludeByVariable(cmExecutionStatus& status,
|
|
|
|
|
+ const std::string& variable);
|
|
|
|
|
+static void TopLevelCMakeVarCondSet(cmMakefile& mf, std::string const& name,
|
|
|
|
|
+ std::string const& value);
|
|
|
|
|
|
|
|
-// cmProjectCommand
|
|
|
|
|
-bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
|
|
- cmExecutionStatus&)
|
|
|
|
|
|
|
+bool cmProjectCommand(std::vector<std::string> const& args,
|
|
|
|
|
+ cmExecutionStatus& status)
|
|
|
{
|
|
{
|
|
|
if (args.empty()) {
|
|
if (args.empty()) {
|
|
|
- this->SetError("PROJECT called with incorrect number of arguments");
|
|
|
|
|
|
|
+ status.SetError("PROJECT called with incorrect number of arguments");
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (!this->IncludeByVariable("CMAKE_PROJECT_INCLUDE_BEFORE")) {
|
|
|
|
|
|
|
+ cmMakefile& mf = status.GetMakefile();
|
|
|
|
|
+ if (!IncludeByVariable(status, "CMAKE_PROJECT_INCLUDE_BEFORE")) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
std::string const& projectName = args[0];
|
|
std::string const& projectName = args[0];
|
|
|
|
|
|
|
|
- this->Makefile->SetProjectName(projectName);
|
|
|
|
|
|
|
+ mf.SetProjectName(projectName);
|
|
|
|
|
|
|
|
- this->Makefile->AddCacheDefinition(
|
|
|
|
|
- projectName + "_BINARY_DIR",
|
|
|
|
|
- this->Makefile->GetCurrentBinaryDirectory().c_str(),
|
|
|
|
|
- "Value Computed by CMake", cmStateEnums::STATIC);
|
|
|
|
|
- this->Makefile->AddCacheDefinition(
|
|
|
|
|
- projectName + "_SOURCE_DIR",
|
|
|
|
|
- this->Makefile->GetCurrentSourceDirectory().c_str(),
|
|
|
|
|
- "Value Computed by CMake", cmStateEnums::STATIC);
|
|
|
|
|
|
|
+ mf.AddCacheDefinition(projectName + "_BINARY_DIR",
|
|
|
|
|
+ mf.GetCurrentBinaryDirectory().c_str(),
|
|
|
|
|
+ "Value Computed by CMake", cmStateEnums::STATIC);
|
|
|
|
|
+ mf.AddCacheDefinition(projectName + "_SOURCE_DIR",
|
|
|
|
|
+ mf.GetCurrentSourceDirectory().c_str(),
|
|
|
|
|
+ "Value Computed by CMake", cmStateEnums::STATIC);
|
|
|
|
|
|
|
|
- this->Makefile->AddDefinition("PROJECT_BINARY_DIR",
|
|
|
|
|
- this->Makefile->GetCurrentBinaryDirectory());
|
|
|
|
|
- this->Makefile->AddDefinition("PROJECT_SOURCE_DIR",
|
|
|
|
|
- this->Makefile->GetCurrentSourceDirectory());
|
|
|
|
|
|
|
+ mf.AddDefinition("PROJECT_BINARY_DIR", mf.GetCurrentBinaryDirectory());
|
|
|
|
|
+ mf.AddDefinition("PROJECT_SOURCE_DIR", mf.GetCurrentSourceDirectory());
|
|
|
|
|
|
|
|
- this->Makefile->AddDefinition("PROJECT_NAME", projectName);
|
|
|
|
|
|
|
+ mf.AddDefinition("PROJECT_NAME", projectName);
|
|
|
|
|
|
|
|
// Set the CMAKE_PROJECT_NAME variable to be the highest-level
|
|
// Set the CMAKE_PROJECT_NAME variable to be the highest-level
|
|
|
// project name in the tree. If there are two project commands
|
|
// project name in the tree. If there are two project commands
|
|
@@ -58,12 +58,10 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
// CMakeLists.txt file, then go with the last one, so that
|
|
// CMakeLists.txt file, then go with the last one, so that
|
|
|
// CMAKE_PROJECT_NAME will match PROJECT_NAME, and cmake --build
|
|
// CMAKE_PROJECT_NAME will match PROJECT_NAME, and cmake --build
|
|
|
// will work.
|
|
// will work.
|
|
|
- if (!this->Makefile->GetDefinition("CMAKE_PROJECT_NAME") ||
|
|
|
|
|
- (this->Makefile->IsRootMakefile())) {
|
|
|
|
|
- this->Makefile->AddDefinition("CMAKE_PROJECT_NAME", projectName);
|
|
|
|
|
- this->Makefile->AddCacheDefinition(
|
|
|
|
|
- "CMAKE_PROJECT_NAME", projectName.c_str(), "Value Computed by CMake",
|
|
|
|
|
- cmStateEnums::STATIC);
|
|
|
|
|
|
|
+ if (!mf.GetDefinition("CMAKE_PROJECT_NAME") || mf.IsRootMakefile()) {
|
|
|
|
|
+ mf.AddDefinition("CMAKE_PROJECT_NAME", projectName);
|
|
|
|
|
+ mf.AddCacheDefinition("CMAKE_PROJECT_NAME", projectName.c_str(),
|
|
|
|
|
+ "Value Computed by CMake", cmStateEnums::STATIC);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bool haveVersion = false;
|
|
bool haveVersion = false;
|
|
@@ -90,9 +88,8 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
for (size_t i = 1; i < args.size(); ++i) {
|
|
for (size_t i = 1; i < args.size(); ++i) {
|
|
|
if (args[i] == "LANGUAGES") {
|
|
if (args[i] == "LANGUAGES") {
|
|
|
if (haveLanguages) {
|
|
if (haveLanguages) {
|
|
|
- this->Makefile->IssueMessage(
|
|
|
|
|
- MessageType::FATAL_ERROR,
|
|
|
|
|
- "LANGUAGES may be specified at most once.");
|
|
|
|
|
|
|
+ mf.IssueMessage(MessageType::FATAL_ERROR,
|
|
|
|
|
+ "LANGUAGES may be specified at most once.");
|
|
|
cmSystemTools::SetFatalErrorOccured();
|
|
cmSystemTools::SetFatalErrorOccured();
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
@@ -106,12 +103,12 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
"the following parameters must be specified after LANGUAGES "
|
|
"the following parameters must be specified after LANGUAGES "
|
|
|
"keyword: ",
|
|
"keyword: ",
|
|
|
cmJoin(languages, ", "), '.');
|
|
cmJoin(languages, ", "), '.');
|
|
|
- this->Makefile->IssueMessage(MessageType::WARNING, msg);
|
|
|
|
|
|
|
+ mf.IssueMessage(MessageType::WARNING, msg);
|
|
|
}
|
|
}
|
|
|
} else if (args[i] == "VERSION") {
|
|
} else if (args[i] == "VERSION") {
|
|
|
if (haveVersion) {
|
|
if (haveVersion) {
|
|
|
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR,
|
|
|
|
|
- "VERSION may be specified at most once.");
|
|
|
|
|
|
|
+ mf.IssueMessage(MessageType::FATAL_ERROR,
|
|
|
|
|
+ "VERSION may be specified at most once.");
|
|
|
cmSystemTools::SetFatalErrorOccured();
|
|
cmSystemTools::SetFatalErrorOccured();
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
@@ -120,8 +117,8 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
missedValueReporter();
|
|
missedValueReporter();
|
|
|
}
|
|
}
|
|
|
doing = DoingVersion;
|
|
doing = DoingVersion;
|
|
|
- missedValueReporter = [this, &resetReporter]() {
|
|
|
|
|
- this->Makefile->IssueMessage(
|
|
|
|
|
|
|
+ missedValueReporter = [&mf, &resetReporter]() {
|
|
|
|
|
+ mf.IssueMessage(
|
|
|
MessageType::WARNING,
|
|
MessageType::WARNING,
|
|
|
"VERSION keyword not followed by a value or was followed by a "
|
|
"VERSION keyword not followed by a value or was followed by a "
|
|
|
"value that expanded to nothing.");
|
|
"value that expanded to nothing.");
|
|
@@ -129,9 +126,8 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
};
|
|
};
|
|
|
} else if (args[i] == "DESCRIPTION") {
|
|
} else if (args[i] == "DESCRIPTION") {
|
|
|
if (haveDescription) {
|
|
if (haveDescription) {
|
|
|
- this->Makefile->IssueMessage(
|
|
|
|
|
- MessageType::FATAL_ERROR,
|
|
|
|
|
- "DESCRIPTION may be specified at most once.");
|
|
|
|
|
|
|
+ mf.IssueMessage(MessageType::FATAL_ERROR,
|
|
|
|
|
+ "DESCRIPTION may be specified at most once.");
|
|
|
cmSystemTools::SetFatalErrorOccured();
|
|
cmSystemTools::SetFatalErrorOccured();
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
@@ -140,8 +136,8 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
missedValueReporter();
|
|
missedValueReporter();
|
|
|
}
|
|
}
|
|
|
doing = DoingDescription;
|
|
doing = DoingDescription;
|
|
|
- missedValueReporter = [this, &resetReporter]() {
|
|
|
|
|
- this->Makefile->IssueMessage(
|
|
|
|
|
|
|
+ missedValueReporter = [&mf, &resetReporter]() {
|
|
|
|
|
+ mf.IssueMessage(
|
|
|
MessageType::WARNING,
|
|
MessageType::WARNING,
|
|
|
"DESCRIPTION keyword not followed by a value or was followed "
|
|
"DESCRIPTION keyword not followed by a value or was followed "
|
|
|
"by a value that expanded to nothing.");
|
|
"by a value that expanded to nothing.");
|
|
@@ -149,16 +145,15 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
};
|
|
};
|
|
|
} else if (args[i] == "HOMEPAGE_URL") {
|
|
} else if (args[i] == "HOMEPAGE_URL") {
|
|
|
if (haveHomepage) {
|
|
if (haveHomepage) {
|
|
|
- this->Makefile->IssueMessage(
|
|
|
|
|
- MessageType::FATAL_ERROR,
|
|
|
|
|
- "HOMEPAGE_URL may be specified at most once.");
|
|
|
|
|
|
|
+ mf.IssueMessage(MessageType::FATAL_ERROR,
|
|
|
|
|
+ "HOMEPAGE_URL may be specified at most once.");
|
|
|
cmSystemTools::SetFatalErrorOccured();
|
|
cmSystemTools::SetFatalErrorOccured();
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
haveHomepage = true;
|
|
haveHomepage = true;
|
|
|
doing = DoingHomepage;
|
|
doing = DoingHomepage;
|
|
|
- missedValueReporter = [this, &resetReporter]() {
|
|
|
|
|
- this->Makefile->IssueMessage(
|
|
|
|
|
|
|
+ missedValueReporter = [&mf, &resetReporter]() {
|
|
|
|
|
+ mf.IssueMessage(
|
|
|
MessageType::WARNING,
|
|
MessageType::WARNING,
|
|
|
"HOMEPAGE_URL keyword not followed by a value or was followed "
|
|
"HOMEPAGE_URL keyword not followed by a value or was followed "
|
|
|
"by a value that expanded to nothing.");
|
|
"by a value that expanded to nothing.");
|
|
@@ -190,10 +185,9 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
|
|
|
|
|
if ((haveVersion || haveDescription || haveHomepage) && !haveLanguages &&
|
|
if ((haveVersion || haveDescription || haveHomepage) && !haveLanguages &&
|
|
|
!languages.empty()) {
|
|
!languages.empty()) {
|
|
|
- this->Makefile->IssueMessage(
|
|
|
|
|
- MessageType::FATAL_ERROR,
|
|
|
|
|
- "project with VERSION, DESCRIPTION or HOMEPAGE_URL must "
|
|
|
|
|
- "use LANGUAGES before language names.");
|
|
|
|
|
|
|
+ mf.IssueMessage(MessageType::FATAL_ERROR,
|
|
|
|
|
+ "project with VERSION, DESCRIPTION or HOMEPAGE_URL must "
|
|
|
|
|
+ "use LANGUAGES before language names.");
|
|
|
cmSystemTools::SetFatalErrorOccured();
|
|
cmSystemTools::SetFatalErrorOccured();
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
@@ -202,13 +196,12 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
cmPolicies::PolicyStatus const cmp0048 =
|
|
cmPolicies::PolicyStatus const cmp0048 =
|
|
|
- this->Makefile->GetPolicyStatus(cmPolicies::CMP0048);
|
|
|
|
|
|
|
+ mf.GetPolicyStatus(cmPolicies::CMP0048);
|
|
|
if (haveVersion) {
|
|
if (haveVersion) {
|
|
|
// Set project VERSION variables to given values
|
|
// Set project VERSION variables to given values
|
|
|
if (cmp0048 == cmPolicies::OLD || cmp0048 == cmPolicies::WARN) {
|
|
if (cmp0048 == cmPolicies::OLD || cmp0048 == cmPolicies::WARN) {
|
|
|
- this->Makefile->IssueMessage(
|
|
|
|
|
- MessageType::FATAL_ERROR,
|
|
|
|
|
- "VERSION not allowed unless CMP0048 is set to NEW");
|
|
|
|
|
|
|
+ mf.IssueMessage(MessageType::FATAL_ERROR,
|
|
|
|
|
+ "VERSION not allowed unless CMP0048 is set to NEW");
|
|
|
cmSystemTools::SetFatalErrorOccured();
|
|
cmSystemTools::SetFatalErrorOccured();
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
@@ -217,13 +210,13 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
R"(^([0-9]+(\.[0-9]+(\.[0-9]+(\.[0-9]+)?)?)?)?$)");
|
|
R"(^([0-9]+(\.[0-9]+(\.[0-9]+(\.[0-9]+)?)?)?)?$)");
|
|
|
if (!vx.find(version)) {
|
|
if (!vx.find(version)) {
|
|
|
std::string e = R"(VERSION ")" + version + R"(" format invalid.)";
|
|
std::string e = R"(VERSION ")" + version + R"(" format invalid.)";
|
|
|
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e);
|
|
|
|
|
|
|
+ mf.IssueMessage(MessageType::FATAL_ERROR, e);
|
|
|
cmSystemTools::SetFatalErrorOccured();
|
|
cmSystemTools::SetFatalErrorOccured();
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
cmPolicies::PolicyStatus const cmp0096 =
|
|
cmPolicies::PolicyStatus const cmp0096 =
|
|
|
- this->Makefile->GetPolicyStatus(cmPolicies::CMP0096);
|
|
|
|
|
|
|
+ mf.GetPolicyStatus(cmPolicies::CMP0096);
|
|
|
|
|
|
|
|
constexpr std::size_t MAX_VERSION_COMPONENTS = 4u;
|
|
constexpr std::size_t MAX_VERSION_COMPONENTS = 4u;
|
|
|
std::string version_string;
|
|
std::string version_string;
|
|
@@ -257,34 +250,30 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
|
|
|
|
|
std::string vv;
|
|
std::string vv;
|
|
|
vv = projectName + "_VERSION";
|
|
vv = projectName + "_VERSION";
|
|
|
- this->Makefile->AddDefinition("PROJECT_VERSION", version_string);
|
|
|
|
|
- this->Makefile->AddDefinition(vv, version_string);
|
|
|
|
|
|
|
+ mf.AddDefinition("PROJECT_VERSION", version_string);
|
|
|
|
|
+ mf.AddDefinition(vv, version_string);
|
|
|
vv = projectName + "_VERSION_MAJOR";
|
|
vv = projectName + "_VERSION_MAJOR";
|
|
|
- this->Makefile->AddDefinition("PROJECT_VERSION_MAJOR",
|
|
|
|
|
- version_components[0]);
|
|
|
|
|
- this->Makefile->AddDefinition(vv, version_components[0]);
|
|
|
|
|
|
|
+ mf.AddDefinition("PROJECT_VERSION_MAJOR", version_components[0]);
|
|
|
|
|
+ mf.AddDefinition(vv, version_components[0]);
|
|
|
vv = projectName + "_VERSION_MINOR";
|
|
vv = projectName + "_VERSION_MINOR";
|
|
|
- this->Makefile->AddDefinition("PROJECT_VERSION_MINOR",
|
|
|
|
|
- version_components[1]);
|
|
|
|
|
- this->Makefile->AddDefinition(vv, version_components[1]);
|
|
|
|
|
|
|
+ mf.AddDefinition("PROJECT_VERSION_MINOR", version_components[1]);
|
|
|
|
|
+ mf.AddDefinition(vv, version_components[1]);
|
|
|
vv = projectName + "_VERSION_PATCH";
|
|
vv = projectName + "_VERSION_PATCH";
|
|
|
- this->Makefile->AddDefinition("PROJECT_VERSION_PATCH",
|
|
|
|
|
- version_components[2]);
|
|
|
|
|
- this->Makefile->AddDefinition(vv, version_components[2]);
|
|
|
|
|
|
|
+ mf.AddDefinition("PROJECT_VERSION_PATCH", version_components[2]);
|
|
|
|
|
+ mf.AddDefinition(vv, version_components[2]);
|
|
|
vv = projectName + "_VERSION_TWEAK";
|
|
vv = projectName + "_VERSION_TWEAK";
|
|
|
- this->Makefile->AddDefinition("PROJECT_VERSION_TWEAK",
|
|
|
|
|
- version_components[3]);
|
|
|
|
|
- this->Makefile->AddDefinition(vv, version_components[3]);
|
|
|
|
|
|
|
+ mf.AddDefinition("PROJECT_VERSION_TWEAK", version_components[3]);
|
|
|
|
|
+ mf.AddDefinition(vv, version_components[3]);
|
|
|
// Also, try set top level variables
|
|
// Also, try set top level variables
|
|
|
- TopLevelCMakeVarCondSet("CMAKE_PROJECT_VERSION", version_string.c_str());
|
|
|
|
|
- TopLevelCMakeVarCondSet("CMAKE_PROJECT_VERSION_MAJOR",
|
|
|
|
|
- version_components[0].c_str());
|
|
|
|
|
- TopLevelCMakeVarCondSet("CMAKE_PROJECT_VERSION_MINOR",
|
|
|
|
|
- version_components[1].c_str());
|
|
|
|
|
- TopLevelCMakeVarCondSet("CMAKE_PROJECT_VERSION_PATCH",
|
|
|
|
|
- version_components[2].c_str());
|
|
|
|
|
- TopLevelCMakeVarCondSet("CMAKE_PROJECT_VERSION_TWEAK",
|
|
|
|
|
- version_components[3].c_str());
|
|
|
|
|
|
|
+ TopLevelCMakeVarCondSet(mf, "CMAKE_PROJECT_VERSION", version_string);
|
|
|
|
|
+ TopLevelCMakeVarCondSet(mf, "CMAKE_PROJECT_VERSION_MAJOR",
|
|
|
|
|
+ version_components[0]);
|
|
|
|
|
+ TopLevelCMakeVarCondSet(mf, "CMAKE_PROJECT_VERSION_MINOR",
|
|
|
|
|
+ version_components[1]);
|
|
|
|
|
+ TopLevelCMakeVarCondSet(mf, "CMAKE_PROJECT_VERSION_PATCH",
|
|
|
|
|
+ version_components[2]);
|
|
|
|
|
+ TopLevelCMakeVarCondSet(mf, "CMAKE_PROJECT_VERSION_TWEAK",
|
|
|
|
|
+ version_components[3]);
|
|
|
} else if (cmp0048 != cmPolicies::OLD) {
|
|
} else if (cmp0048 != cmPolicies::OLD) {
|
|
|
// Set project VERSION variables to empty
|
|
// Set project VERSION variables to empty
|
|
|
std::vector<std::string> vv = { "PROJECT_VERSION",
|
|
std::vector<std::string> vv = { "PROJECT_VERSION",
|
|
@@ -297,7 +286,7 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
projectName + "_VERSION_MINOR",
|
|
projectName + "_VERSION_MINOR",
|
|
|
projectName + "_VERSION_PATCH",
|
|
projectName + "_VERSION_PATCH",
|
|
|
projectName + "_VERSION_TWEAK" };
|
|
projectName + "_VERSION_TWEAK" };
|
|
|
- if (this->Makefile->IsRootMakefile()) {
|
|
|
|
|
|
|
+ if (mf.IsRootMakefile()) {
|
|
|
vv.emplace_back("CMAKE_PROJECT_VERSION");
|
|
vv.emplace_back("CMAKE_PROJECT_VERSION");
|
|
|
vv.emplace_back("CMAKE_PROJECT_VERSION_MAJOR");
|
|
vv.emplace_back("CMAKE_PROJECT_VERSION_MAJOR");
|
|
|
vv.emplace_back("CMAKE_PROJECT_VERSION_MINOR");
|
|
vv.emplace_back("CMAKE_PROJECT_VERSION_MINOR");
|
|
@@ -306,7 +295,7 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
}
|
|
}
|
|
|
std::string vw;
|
|
std::string vw;
|
|
|
for (std::string const& i : vv) {
|
|
for (std::string const& i : vv) {
|
|
|
- const char* const v = this->Makefile->GetDefinition(i);
|
|
|
|
|
|
|
+ const char* const v = mf.GetDefinition(i);
|
|
|
if (v && *v) {
|
|
if (v && *v) {
|
|
|
if (cmp0048 == cmPolicies::WARN) {
|
|
if (cmp0048 == cmPolicies::WARN) {
|
|
|
if (!injectedProjectCommand) {
|
|
if (!injectedProjectCommand) {
|
|
@@ -314,51 +303,54 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
vw += i;
|
|
vw += i;
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- this->Makefile->AddDefinition(i, "");
|
|
|
|
|
|
|
+ mf.AddDefinition(i, "");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (!vw.empty()) {
|
|
if (!vw.empty()) {
|
|
|
- this->Makefile->IssueMessage(
|
|
|
|
|
|
|
+ mf.IssueMessage(
|
|
|
MessageType::AUTHOR_WARNING,
|
|
MessageType::AUTHOR_WARNING,
|
|
|
cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0048),
|
|
cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0048),
|
|
|
"\nThe following variable(s) would be set to empty:", vw));
|
|
"\nThe following variable(s) would be set to empty:", vw));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- this->Makefile->AddDefinition("PROJECT_DESCRIPTION", description);
|
|
|
|
|
- this->Makefile->AddDefinition(projectName + "_DESCRIPTION", description);
|
|
|
|
|
- TopLevelCMakeVarCondSet("CMAKE_PROJECT_DESCRIPTION", description.c_str());
|
|
|
|
|
|
|
+ mf.AddDefinition("PROJECT_DESCRIPTION", description);
|
|
|
|
|
+ mf.AddDefinition(projectName + "_DESCRIPTION", description);
|
|
|
|
|
+ TopLevelCMakeVarCondSet(mf, "CMAKE_PROJECT_DESCRIPTION", description);
|
|
|
|
|
|
|
|
- this->Makefile->AddDefinition("PROJECT_HOMEPAGE_URL", homepage);
|
|
|
|
|
- this->Makefile->AddDefinition(projectName + "_HOMEPAGE_URL", homepage);
|
|
|
|
|
- TopLevelCMakeVarCondSet("CMAKE_PROJECT_HOMEPAGE_URL", homepage.c_str());
|
|
|
|
|
|
|
+ mf.AddDefinition("PROJECT_HOMEPAGE_URL", homepage);
|
|
|
|
|
+ mf.AddDefinition(projectName + "_HOMEPAGE_URL", homepage);
|
|
|
|
|
+ TopLevelCMakeVarCondSet(mf, "CMAKE_PROJECT_HOMEPAGE_URL", homepage);
|
|
|
|
|
|
|
|
if (languages.empty()) {
|
|
if (languages.empty()) {
|
|
|
// if no language is specified do c and c++
|
|
// if no language is specified do c and c++
|
|
|
languages = { "C", "CXX" };
|
|
languages = { "C", "CXX" };
|
|
|
}
|
|
}
|
|
|
- this->Makefile->EnableLanguage(languages, false);
|
|
|
|
|
|
|
+ mf.EnableLanguage(languages, false);
|
|
|
|
|
|
|
|
- if (!this->IncludeByVariable("CMAKE_PROJECT_INCLUDE")) {
|
|
|
|
|
|
|
+ if (!IncludeByVariable(status, "CMAKE_PROJECT_INCLUDE")) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (!this->IncludeByVariable("CMAKE_PROJECT_" + projectName + "_INCLUDE")) {
|
|
|
|
|
|
|
+ if (!IncludeByVariable(status,
|
|
|
|
|
+ "CMAKE_PROJECT_" + projectName + "_INCLUDE")) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-bool cmProjectCommand::IncludeByVariable(const std::string& variable)
|
|
|
|
|
|
|
+static bool IncludeByVariable(cmExecutionStatus& status,
|
|
|
|
|
+ const std::string& variable)
|
|
|
{
|
|
{
|
|
|
- const char* const include = this->Makefile->GetDefinition(variable);
|
|
|
|
|
|
|
+ cmMakefile& mf = status.GetMakefile();
|
|
|
|
|
+ const char* const include = mf.GetDefinition(variable);
|
|
|
if (!include) {
|
|
if (!include) {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const bool readit = this->Makefile->ReadDependentFile(include);
|
|
|
|
|
|
|
+ const bool readit = mf.ReadDependentFile(include);
|
|
|
if (readit) {
|
|
if (readit) {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
@@ -367,24 +359,20 @@ bool cmProjectCommand::IncludeByVariable(const std::string& variable)
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- std::string m = cmStrCat("could not find file:\n"
|
|
|
|
|
- " ",
|
|
|
|
|
- include);
|
|
|
|
|
- this->SetError(m);
|
|
|
|
|
|
|
+ status.SetError(cmStrCat("could not find file:\n ", include));
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void cmProjectCommand::TopLevelCMakeVarCondSet(const char* const name,
|
|
|
|
|
- const char* const value)
|
|
|
|
|
|
|
+static void TopLevelCMakeVarCondSet(cmMakefile& mf, std::string const& name,
|
|
|
|
|
+ std::string const& value)
|
|
|
{
|
|
{
|
|
|
// Set the CMAKE_PROJECT_XXX variable to be the highest-level
|
|
// Set the CMAKE_PROJECT_XXX variable to be the highest-level
|
|
|
// project name in the tree. If there are two project commands
|
|
// project name in the tree. If there are two project commands
|
|
|
// in the same CMakeLists.txt file, and it is the top level
|
|
// in the same CMakeLists.txt file, and it is the top level
|
|
|
// CMakeLists.txt file, then go with the last one.
|
|
// CMakeLists.txt file, then go with the last one.
|
|
|
- if (!this->Makefile->GetDefinition(name) ||
|
|
|
|
|
- (this->Makefile->IsRootMakefile())) {
|
|
|
|
|
- this->Makefile->AddDefinition(name, value);
|
|
|
|
|
- this->Makefile->AddCacheDefinition(name, value, "Value Computed by CMake",
|
|
|
|
|
- cmStateEnums::STATIC);
|
|
|
|
|
|
|
+ if (!mf.GetDefinition(name) || mf.IsRootMakefile()) {
|
|
|
|
|
+ mf.AddDefinition(name, value);
|
|
|
|
|
+ mf.AddCacheDefinition(name, value.c_str(), "Value Computed by CMake",
|
|
|
|
|
+ cmStateEnums::STATIC);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|