The example for CMP0054 does not show how critical the policy is since
the result is the same in both cases (NEW and OLD policies).
I think it would be more educational to show an example when the
policy does make a difference.

Tamas

>From 03a6d915a5058d06a3f2cf8b4eac07cf42e81b53 Mon Sep 17 00:00:00 2001
From: Tamas Kenez <[email protected]>
Date: Wed, 29 Apr 2015 15:37:46 +0200
Subject: [PATCH] Help: new example for CMP0054 to show when it makes a
 difference

---
 Help/policy/CMP0054.rst | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/Help/policy/CMP0054.rst b/Help/policy/CMP0054.rst
index 39f0c40..6aaaf76 100644
--- a/Help/policy/CMP0054.rst
+++ b/Help/policy/CMP0054.rst
@@ -16,29 +16,33 @@ Given the following partial example:

 ::

-  set(MONKEY 1)
-  set(ANIMAL MONKEY)
-
-  if("${ANIMAL}" STREQUAL "MONKEY")
+  set(A E)
+  set(E "")
+
+  if("${A}" STREQUAL "")
+    message("Result is TRUE before CMake 3.1 or when CMP0054 is OLD")
+  else()
+    message("Result is FALSE in CMake 3.1 and above if CMP0054 is NEW")
+  endif()

 After explicit expansion of variables this gives:

 ::

-  if("MONKEY" STREQUAL "MONKEY")
+  if("E" STREQUAL "")

 With the policy set to ``OLD`` implicit expansion reduces this semantically to:

 ::

-  if("1" STREQUAL "1")
+  if("" STREQUAL "")

 With the policy set to ``NEW`` the quoted arguments will not be
 further dereferenced:

 ::

-  if("MONKEY" STREQUAL "MONKEY")
+  if("E" STREQUAL "")

 This policy was introduced in CMake version 3.1.
 CMake version |release| warns when the policy is not set and uses
-- 
1.9.4.msysgit.2
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to