summaryrefslogtreecommitdiffstats
path: root/Source/cmProjectCommand.cxx
diff options
context:
space:
mode:
authorAlex Turbov <i.zaufi@gmail.com>2018-04-29 14:09:40 (GMT)
committerCraig Scott <craig.scott@crascit.com>2018-05-02 22:26:03 (GMT)
commitaf1c48871cedc29eb0dc773556c606c670df55ee (patch)
treeb63e5a9cbfe70122491e277978cbe50f6ec254fc /Source/cmProjectCommand.cxx
parent1925fe9fed9ef4007e344fdf1fa598e9ad523c4c (diff)
downloadCMake-af1c48871cedc29eb0dc773556c606c670df55ee.zip
CMake-af1c48871cedc29eb0dc773556c606c670df55ee.tar.gz
CMake-af1c48871cedc29eb0dc773556c606c670df55ee.tar.bz2
CPack: Use project version as default for `CPACK_PACKAGE_VERSION`
* Introduce `CMAKE_PROJECT_VERSION` and the corresponsing components: `CMAKE_PROJECT_VERSION_MAJOR`, `CMAKE_PROJECT_VERSION_MINOR`, `CMAKE_PROJECT_VERSION_PATCH` and `CMAKE_PROJECT_VERSION_TWEAK`. * `CPack` module use `CMAKE_PROJECT_VERSION_MAJOR`, `CMAKE_PROJECT_VERSION_MINOR` and `CMAKE_PROJECT_VERSION_PATCH` to initialize corresponsing CPack variables.
Diffstat (limited to 'Source/cmProjectCommand.cxx')
-rw-r--r--Source/cmProjectCommand.cxx54
1 files changed, 30 insertions, 24 deletions
diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx
index 6ddb0b8..a25bd6b 100644
--- a/Source/cmProjectCommand.cxx
+++ b/Source/cmProjectCommand.cxx
@@ -249,6 +249,12 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
vv = projectName + "_VERSION_TWEAK";
this->Makefile->AddDefinition("PROJECT_VERSION_TWEAK", vb[3]);
this->Makefile->AddDefinition(vv, vb[3]);
+ // Also, try set top level variables
+ TopLevelCMakeVarCondSet("CMAKE_PROJECT_VERSION", vs.c_str());
+ TopLevelCMakeVarCondSet("CMAKE_PROJECT_VERSION_MAJOR", vb[0]);
+ TopLevelCMakeVarCondSet("CMAKE_PROJECT_VERSION_MINOR", vb[1]);
+ TopLevelCMakeVarCondSet("CMAKE_PROJECT_VERSION_PATCH", vb[2]);
+ TopLevelCMakeVarCondSet("CMAKE_PROJECT_VERSION_TWEAK", vb[3]);
} else if (cmp0048 != cmPolicies::OLD) {
// Set project VERSION variables to empty
std::vector<std::string> vv;
@@ -262,6 +268,13 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
vv.push_back(projectName + "_VERSION_MINOR");
vv.push_back(projectName + "_VERSION_PATCH");
vv.push_back(projectName + "_VERSION_TWEAK");
+ if (this->Makefile->IsRootMakefile()) {
+ vv.push_back("CMAKE_PROJECT_VERSION");
+ vv.push_back("CMAKE_PROJECT_VERSION_MAJOR");
+ vv.push_back("CMAKE_PROJECT_VERSION_MINOR");
+ vv.push_back("CMAKE_PROJECT_VERSION_PATCH");
+ vv.push_back("CMAKE_PROJECT_VERSION_TWEAK");
+ }
std::string vw;
for (std::string const& i : vv) {
const char* v = this->Makefile->GetDefinition(i);
@@ -286,36 +299,14 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
this->Makefile->AddDefinition("PROJECT_DESCRIPTION", description.c_str());
this->Makefile->AddDefinition(projectName + "_DESCRIPTION",
description.c_str());
- // Set the CMAKE_PROJECT_DESCRIPTION variable to be the highest-level
- // project name in the tree. If there are two project commands
- // in the same CMakeLists.txt file, and it is the top level
- // CMakeLists.txt file, then go with the last one.
- if (!this->Makefile->GetDefinition("CMAKE_PROJECT_DESCRIPTION") ||
- (this->Makefile->IsRootMakefile())) {
- this->Makefile->AddDefinition("CMAKE_PROJECT_DESCRIPTION",
- description.c_str());
- this->Makefile->AddCacheDefinition(
- "CMAKE_PROJECT_DESCRIPTION", description.c_str(),
- "Value Computed by CMake", cmStateEnums::STATIC);
- }
+ TopLevelCMakeVarCondSet("CMAKE_PROJECT_DESCRIPTION", description.c_str());
}
if (haveHomepage) {
this->Makefile->AddDefinition("PROJECT_HOMEPAGE_URL", homepage.c_str());
this->Makefile->AddDefinition(projectName + "_HOMEPAGE_URL",
homepage.c_str());
- // Set the CMAKE_PROJECT_HOMEPAGE_URL variable to be the highest-level
- // project name in the tree. If there are two project commands
- // in the same CMakeLists.txt file, and it is the top level
- // CMakeLists.txt file, then go with the last one.
- if (!this->Makefile->GetDefinition("CMAKE_PROJECT_HOMEPAGE_URL") ||
- (this->Makefile->IsRootMakefile())) {
- this->Makefile->AddDefinition("CMAKE_PROJECT_HOMEPAGE_URL",
- homepage.c_str());
- this->Makefile->AddCacheDefinition(
- "CMAKE_PROJECT_HOMEPAGE_URL", homepage.c_str(),
- "Value Computed by CMake", cmStateEnums::STATIC);
- }
+ TopLevelCMakeVarCondSet("CMAKE_PROJECT_HOMEPAGE_URL", homepage.c_str());
}
if (languages.empty()) {
@@ -338,3 +329,18 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
}
return true;
}
+
+void cmProjectCommand::TopLevelCMakeVarCondSet(const char* const name,
+ const char* const value)
+{
+ // Set the CMAKE_PROJECT_XXX variable to be the highest-level
+ // project name in the tree. If there are two project commands
+ // in the same CMakeLists.txt file, and it is the top level
+ // 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);
+ }
+}