CMP0054.rst 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. CMP0054
  2. -------
  3. .. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
  4. .. include:: include/REMOVED_PROLOGUE.rst
  5. .. versionadded:: 3.1
  6. Only interpret :command:`if` arguments as variables or keywords when unquoted.
  7. CMake 3.1 and above no longer implicitly dereference variables or
  8. interpret keywords in an :command:`if` command argument when
  9. it is a :ref:`Quoted Argument` or a :ref:`Bracket Argument`.
  10. The ``OLD`` behavior for this policy is to dereference variables and
  11. interpret keywords even if they are quoted or bracketed.
  12. The ``NEW`` behavior is to not dereference variables or interpret keywords
  13. that have been quoted or bracketed.
  14. Given the following partial example:
  15. .. code-block:: cmake
  16. set(A E)
  17. set(E "")
  18. if("${A}" STREQUAL "")
  19. message("Result is TRUE before CMake 3.1 or when CMP0054 is OLD")
  20. else()
  21. message("Result is FALSE in CMake 3.1 and above if CMP0054 is NEW")
  22. endif()
  23. After explicit expansion of variables this gives:
  24. .. code-block:: cmake
  25. if("E" STREQUAL "")
  26. With the policy set to ``OLD`` implicit expansion reduces this semantically to:
  27. .. code-block:: cmake
  28. if("" STREQUAL "")
  29. With the policy set to ``NEW`` the quoted arguments will not be
  30. further dereferenced:
  31. .. code-block:: cmake
  32. if("E" STREQUAL "")
  33. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.1
  34. .. |WARNED_OR_DID_NOT_WARN| replace:: warned
  35. .. include:: include/REMOVED_EPILOGUE.rst