Merge topic 'doc-CMP0054-example'
9535b86d Help: Replace CMP0054 example to show when it makes a difference
This commit is contained in:
commit
e2f72ebdbe
@ -16,29 +16,33 @@ Given the following partial example:
|
|||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
set(MONKEY 1)
|
set(A E)
|
||||||
set(ANIMAL MONKEY)
|
set(E "")
|
||||||
|
|
||||||
if("${ANIMAL}" STREQUAL "MONKEY")
|
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:
|
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:
|
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
|
With the policy set to ``NEW`` the quoted arguments will not be
|
||||||
further dereferenced:
|
further dereferenced:
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
if("MONKEY" STREQUAL "MONKEY")
|
if("E" STREQUAL "")
|
||||||
|
|
||||||
This policy was introduced in CMake version 3.1.
|
This policy was introduced in CMake version 3.1.
|
||||||
CMake version |release| warns when the policy is not set and uses
|
CMake version |release| warns when the policy is not set and uses
|
||||||
|
Loading…
x
Reference in New Issue
Block a user