diff options
author | Brad King <brad.king@kitware.com> | 2017-04-13 12:14:17 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2017-04-13 12:14:23 (GMT) |
commit | 2cb98329f1e1175fb24d7ea3daf969f1de8a2a21 (patch) | |
tree | 51fb2d104c764ef4a3b871188151c4833ea105ec /Source/cmProjectCommand.cxx | |
parent | 26b5f7defe10edeaac763487a26ab9a101f2ed8f (diff) | |
parent | 3b4848717aa23d0238e97fb7d381829e6e47f722 (diff) | |
download | CMake-2cb98329f1e1175fb24d7ea3daf969f1de8a2a21.zip CMake-2cb98329f1e1175fb24d7ea3daf969f1de8a2a21.tar.gz CMake-2cb98329f1e1175fb24d7ea3daf969f1de8a2a21.tar.bz2 |
Merge topic 'project-description'
3b484871 project: Add `DESCRIPTION` parameter
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !679
Diffstat (limited to 'Source/cmProjectCommand.cxx')
-rw-r--r-- | Source/cmProjectCommand.cxx | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index a6ab88e..d47a047 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"); |