diff options
author | Brad King <brad.king@kitware.com> | 2018-10-08 15:21:48 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-10-08 15:21:48 (GMT) |
commit | c2356d60d8b3bc709ed5e95f98864ff504685010 (patch) | |
tree | 536401c72a423a65ef24d84861ae2e99a7c77e05 | |
parent | 981cdceca20bd6ca84dd7118cb038fb54c81197d (diff) | |
parent | f8a086a86bd3f9301f04e5ad64b75fe960eee99a (diff) | |
download | CMake-c2356d60d8b3bc709ed5e95f98864ff504685010.zip CMake-c2356d60d8b3bc709ed5e95f98864ff504685010.tar.gz CMake-c2356d60d8b3bc709ed5e95f98864ff504685010.tar.bz2 |
Merge branch 'project-always-set-desc-url' into release-3.13
Merge-request: !2457
-rw-r--r-- | Help/command/project.rst | 2 | ||||
-rw-r--r-- | Source/cmProjectCommand.cxx | 20 | ||||
-rw-r--r-- | Tests/RunCMake/project/ProjectTwice.cmake | 26 | ||||
-rw-r--r-- | Tests/RunCMake/project/RunCMakeTest.cmake | 1 |
4 files changed, 37 insertions, 12 deletions
diff --git a/Help/command/project.rst b/Help/command/project.rst index c1de057..bd8b4ef 100644 --- a/Help/command/project.rst +++ b/Help/command/project.rst @@ -44,6 +44,7 @@ Variables corresponding to unspecified versions are set to the empty string If the optional ``DESCRIPTION`` is given, then :variable:`PROJECT_DESCRIPTION` and :variable:`<PROJECT-NAME>_DESCRIPTION` will be set to its argument. +These variables will be cleared if ``DESCRIPTION`` is not given. The description is expected to be a relatively short string, usually no more than a few words. @@ -51,6 +52,7 @@ The optional ``HOMEPAGE_URL`` sets the analogous variables :variable:`PROJECT_HOMEPAGE_URL` and :variable:`<PROJECT-NAME>_HOMEPAGE_URL`. When this option is given, the URL provided should be the canonical home for the project. +These variables will be cleared if ``HOMEPAGE_URL`` is not given. Note that the description and homepage URL may be used as defaults for things like packaging meta-data, documentation, etc. diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 305c7a6..8f565c8 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -300,19 +300,15 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args, } } - if (haveDescription) { - this->Makefile->AddDefinition("PROJECT_DESCRIPTION", description.c_str()); - this->Makefile->AddDefinition(projectName + "_DESCRIPTION", - description.c_str()); - TopLevelCMakeVarCondSet("CMAKE_PROJECT_DESCRIPTION", description.c_str()); - } + this->Makefile->AddDefinition("PROJECT_DESCRIPTION", description.c_str()); + this->Makefile->AddDefinition(projectName + "_DESCRIPTION", + description.c_str()); + 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()); - TopLevelCMakeVarCondSet("CMAKE_PROJECT_HOMEPAGE_URL", homepage.c_str()); - } + this->Makefile->AddDefinition("PROJECT_HOMEPAGE_URL", homepage.c_str()); + this->Makefile->AddDefinition(projectName + "_HOMEPAGE_URL", + homepage.c_str()); + TopLevelCMakeVarCondSet("CMAKE_PROJECT_HOMEPAGE_URL", homepage.c_str()); if (languages.empty()) { // if no language is specified do c and c++ diff --git a/Tests/RunCMake/project/ProjectTwice.cmake b/Tests/RunCMake/project/ProjectTwice.cmake new file mode 100644 index 0000000..d053834 --- /dev/null +++ b/Tests/RunCMake/project/ProjectTwice.cmake @@ -0,0 +1,26 @@ +cmake_policy(SET CMP0048 NEW) +project(ProjectTwiceTestFirst + VERSION 1.2.3.4 + DESCRIPTION "Test Project" + HOMEPAGE_URL "http://example.com" + LANGUAGES NONE +) + +project(ProjectTwiceTestSecond LANGUAGES NONE) + +foreach(var + PROJECT_VERSION + PROJECT_VERSION_MAJOR + PROJECT_VERSION_MINOR + PROJECT_VERSION_PATCH + PROJECT_VERSION_TWEAK + PROJECT_DESCRIPTION + PROJECT_HOMEPAGE_URL +) + if(${var}) + message(SEND_ERROR "${var} set but should be empty") + endif() + if(CMAKE_${var}) + message(SEND_ERROR "CMAKE_${var} set but should be empty") + endif() +endforeach() diff --git a/Tests/RunCMake/project/RunCMakeTest.cmake b/Tests/RunCMake/project/RunCMakeTest.cmake index e9fb929..3a8ad4b 100644 --- a/Tests/RunCMake/project/RunCMakeTest.cmake +++ b/Tests/RunCMake/project/RunCMakeTest.cmake @@ -15,6 +15,7 @@ run_cmake(ProjectDescriptionNoArg2) run_cmake(ProjectHomepage) run_cmake(ProjectHomepage2) run_cmake(ProjectHomepageNoArg) +run_cmake(ProjectTwice) run_cmake(VersionAndLanguagesEmpty) run_cmake(VersionEmpty) run_cmake(VersionInvalid) |