summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmIfCommand.cxx17
-rw-r--r--Source/cmIfCommand.h3
-rw-r--r--Tests/Complex/CMakeLists.txt5
-rw-r--r--Tests/ComplexOneConfig/CMakeLists.txt5
-rw-r--r--Tests/ComplexRelativePaths/CMakeLists.txt5
5 files changed, 35 insertions, 0 deletions
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index b39e57c..517348c 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())
{
diff --git a/Source/cmIfCommand.h b/Source/cmIfCommand.h
index 8576274..bdccdf3 100644
--- a/Source/cmIfCommand.h
+++ b/Source/cmIfCommand.h
@@ -139,6 +139,9 @@ public:
" if(COMMAND command-name)\n"
"True if the given name is a command, macro or function that can be "
"invoked.\n"
+ " if(POLICY policy-id)\n"
+ "True if the given name is an existing policy "
+ "(of the form CMP<NNNN>).\n"
" if(EXISTS file-name)\n"
" if(EXISTS directory-name)\n"
"True if the named file or directory exists. "
diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt
index 5c67094..1814528 100644
--- a/Tests/Complex/CMakeLists.txt
+++ b/Tests/Complex/CMakeLists.txt
@@ -4,6 +4,11 @@
SET(CMAKE_BACKWARDS_COMPATIBILITY 1.4)
PROJECT (Complex)
+# Try setting a new policy. The IF test is for coverage.
+IF(POLICY CMP0003)
+ CMAKE_POLICY(SET CMP0003 NEW)
+ENDIF(POLICY CMP0003)
+
# Choose whether to test CMakeLib.
SET(COMPLEX_TEST_CMAKELIB 1)
IF(CMAKE_TEST_DIFFERENT_GENERATOR)
diff --git a/Tests/ComplexOneConfig/CMakeLists.txt b/Tests/ComplexOneConfig/CMakeLists.txt
index 5c67094..1814528 100644
--- a/Tests/ComplexOneConfig/CMakeLists.txt
+++ b/Tests/ComplexOneConfig/CMakeLists.txt
@@ -4,6 +4,11 @@
SET(CMAKE_BACKWARDS_COMPATIBILITY 1.4)
PROJECT (Complex)
+# Try setting a new policy. The IF test is for coverage.
+IF(POLICY CMP0003)
+ CMAKE_POLICY(SET CMP0003 NEW)
+ENDIF(POLICY CMP0003)
+
# Choose whether to test CMakeLib.
SET(COMPLEX_TEST_CMAKELIB 1)
IF(CMAKE_TEST_DIFFERENT_GENERATOR)
diff --git a/Tests/ComplexRelativePaths/CMakeLists.txt b/Tests/ComplexRelativePaths/CMakeLists.txt
index 5c67094..1814528 100644
--- a/Tests/ComplexRelativePaths/CMakeLists.txt
+++ b/Tests/ComplexRelativePaths/CMakeLists.txt
@@ -4,6 +4,11 @@
SET(CMAKE_BACKWARDS_COMPATIBILITY 1.4)
PROJECT (Complex)
+# Try setting a new policy. The IF test is for coverage.
+IF(POLICY CMP0003)
+ CMAKE_POLICY(SET CMP0003 NEW)
+ENDIF(POLICY CMP0003)
+
# Choose whether to test CMakeLib.
SET(COMPLEX_TEST_CMAKELIB 1)
IF(CMAKE_TEST_DIFFERENT_GENERATOR)