summaryrefslogtreecommitdiffstats
path: root/Source/cmProjectCommand.cxx
diff options
context:
space:
mode:
authorAlex Turbov <i.zaufi@gmail.com>2017-04-08 17:39:06 (GMT)
committerBrad King <brad.king@kitware.com>2017-04-11 14:17:00 (GMT)
commit3b4848717aa23d0238e97fb7d381829e6e47f722 (patch)
treee9a1bfeae99263a9335e2e8dffd04349b97b675a /Source/cmProjectCommand.cxx
parentc791fb12544926bc5870a61735dc2ec62940a6f6 (diff)
downloadCMake-3b4848717aa23d0238e97fb7d381829e6e47f722.zip
CMake-3b4848717aa23d0238e97fb7d381829e6e47f722.tar.gz
CMake-3b4848717aa23d0238e97fb7d381829e6e47f722.tar.bz2
project: Add `DESCRIPTION` parameter
It is quite often the project description has used in a real world software. Examples include: * part of a help screen of the application * builtin resources (`*.rc` files, data for "About" dialog of a GUI app, & etc) * most generators for CPack can use it * it could be used by documentary software (Doxygen, Sphinx) which is usually integrated to CMake based projects via `add_custom_target()` Now `project()` call learned an optional `DESCRIPTION` parameter with a short string describing a project. Being specified, it would set the `PROJECT_DESCRIPTION` variable which could be used in `configure_file()` or whatever user wants. Also `PROJECT_DESCRIPTION` is a default value for `CPACK_PACKAGE_DESCRIPTION_SUMMARY`.
Diffstat (limited to 'Source/cmProjectCommand.cxx')
-rw-r--r--Source/cmProjectCommand.cxx31
1 files changed, 31 insertions, 0 deletions
diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx
index 4e0fa57..66f324a 100644
--- a/Source/cmProjectCommand.cxx
+++ b/Source/cmProjectCommand.cxx
@@ -62,10 +62,13 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
bool haveVersion = false;
bool haveLanguages = false;
+ bool haveDescription = false;
std::string version;
+ std::string description;
std::vector<std::string> languages;
enum Doing
{
+ DoingDescription,
DoingLanguages,
DoingVersion
};
@@ -89,9 +92,21 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
}
haveVersion = true;
doing = DoingVersion;
+ } else if (args[i] == "DESCRIPTION") {
+ if (haveDescription) {
+ this->Makefile->IssueMessage(
+ cmake::FATAL_ERROR, "DESCRITPION may be specified at most once.");
+ cmSystemTools::SetFatalErrorOccured();
+ return true;
+ }
+ haveDescription = true;
+ doing = DoingDescription;
} else if (doing == DoingVersion) {
doing = DoingLanguages;
version = args[i];
+ } else if (doing == DoingDescription) {
+ doing = DoingLanguages;
+ description = args[i];
} else // doing == DoingLanguages
{
languages.push_back(args[i]);
@@ -197,6 +212,22 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
}
}
+ if (haveDescription) {
+ this->Makefile->AddDefinition("PROJECT_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);
+ }
+ }
+
if (languages.empty()) {
// if no language is specified do c and c++
languages.push_back("C");