diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2018-10-03 13:36:58 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2018-10-10 14:56:00 (GMT) |
commit | 0d988f98e531333b32d0f1628acf86f8baa22241 (patch) | |
tree | 882f2cb255dc0947d3e199169405c568e021db5e /Source/cmCMakePolicyCommand.cxx | |
parent | f9f96598df3164cf12b6da7764bc74361e3fa414 (diff) | |
download | CMake-0d988f98e531333b32d0f1628acf86f8baa22241.zip CMake-0d988f98e531333b32d0f1628acf86f8baa22241.tar.gz CMake-0d988f98e531333b32d0f1628acf86f8baa22241.tar.bz2 |
cmake_policy: Add undocumented GET_WARNING command
This command is intended for modules that issue policy warnings so
they can get the warning string from CMake in a uniform manner,
rather than duplicating the string. Several modules been updated
to include an example of the usage of this new command.
Diffstat (limited to 'Source/cmCMakePolicyCommand.cxx')
-rw-r--r-- | Source/cmCMakePolicyCommand.cxx | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Source/cmCMakePolicyCommand.cxx b/Source/cmCMakePolicyCommand.cxx index adf9ef8..3209ea5 100644 --- a/Source/cmCMakePolicyCommand.cxx +++ b/Source/cmCMakePolicyCommand.cxx @@ -46,6 +46,9 @@ bool cmCMakePolicyCommand::InitialPass(std::vector<std::string> const& args, if (args[0] == "VERSION") { return this->HandleVersionMode(args); } + if (args[0] == "GET_WARNING") { + return this->HandleGetWarningMode(args); + } std::ostringstream e; e << "given unknown first argument \"" << args[0] << "\""; @@ -181,3 +184,33 @@ bool cmCMakePolicyCommand::HandleVersionMode( this->Makefile->SetPolicyVersion(version_min, version_max); return true; } + +bool cmCMakePolicyCommand::HandleGetWarningMode( + std::vector<std::string> const& args) +{ + if (args.size() != 3) { + this->SetError( + "GET_WARNING must be given exactly 2 additional arguments."); + return false; + } + + // Get arguments. + std::string const& id = args[1]; + std::string const& var = args[2]; + + // Lookup the policy number. + cmPolicies::PolicyID pid; + if (!cmPolicies::GetPolicyID(id.c_str(), pid)) { + std::ostringstream e; + e << "GET_WARNING given policy \"" << id + << "\" which is not known to this version of CMake."; + this->SetError(e.str()); + return false; + } + + // Lookup the policy warning. + this->Makefile->AddDefinition(var, + cmPolicies::GetPolicyWarning(pid).c_str()); + + return true; +} |