summaryrefslogtreecommitdiff
path: root/Source/cmIfCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-03-20 18:25:59 -0400
committerBrad King <brad.king@kitware.com>2008-03-20 18:25:59 -0400
commita6a673979dded1cc97a76c193e29bab64b00480e (patch)
treebf8c8d7b6260059a997d0f49c8ce07f730a00682 /Source/cmIfCommand.cxx
parent8e2f45c24b98ad97be584c61528a82807ef5cebe (diff)
downloadcmake-a6a673979dded1cc97a76c193e29bab64b00480e.tar.gz
ENH: Add "if(POLICY policy-id)" option for IF command.
- This will help projects support multiple CMake versions. - In order to set a policy when using a newer CMake but still working with an older CMake one may write if(POLICY CMP1234) cmake_policy(SET CMP1234 NEW) endif(POLICY CMP1234) - Note that since CMake 2.4 does not have if(POLICY) supporting it will also require using "if(COMMAND cmake_policy)"
Diffstat (limited to 'Source/cmIfCommand.cxx')
-rw-r--r--Source/cmIfCommand.cxx17
1 files changed, 17 insertions, 0 deletions
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index b39e57c8e6..517348c3f7 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -357,6 +357,23 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
IncrementArguments(newArgs,argP1,argP2);
reducible = 1;
}
+ // does a policy exist
+ if (*arg == "POLICY" && argP1 != newArgs.end())
+ {
+ cmPolicies::PolicyID pid;
+ if(makefile->GetPolicies()->GetPolicyID((argP1)->c_str(), pid))
+ {
+ *arg = "1";
+ }
+ else
+ {
+ *arg = "0";
+ }
+ newArgs.erase(argP1);
+ argP1 = arg;
+ IncrementArguments(newArgs,argP1,argP2);
+ reducible = 1;
+ }
// is a variable defined
if (*arg == "DEFINED" && argP1 != newArgs.end())
{