CMP0054-policy-command-scope.cmake 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. set(FOO BAR)
  2. cmake_policy(SET CMP0054 NEW)
  3. function(function_defined_new_called_old)
  4. if(NOT FOO STREQUAL BAR)
  5. message(FATAL_ERROR "The variable should match the string")
  6. endif()
  7. if("FOO" STREQUAL BAR)
  8. message(FATAL_ERROR "The strings should not match")
  9. endif()
  10. endfunction()
  11. macro(macro_defined_new_called_old)
  12. if(NOT FOO STREQUAL BAR)
  13. message(FATAL_ERROR "The variable should match the string")
  14. endif()
  15. if("FOO" STREQUAL BAR)
  16. message(FATAL_ERROR "The strings should not match")
  17. endif()
  18. endmacro()
  19. cmake_policy(SET CMP0054 OLD)
  20. function_defined_new_called_old()
  21. macro_defined_new_called_old()
  22. function(function_defined_old_called_new)
  23. if(NOT FOO STREQUAL BAR)
  24. message(FATAL_ERROR "The variable should match the string")
  25. endif()
  26. if(NOT "FOO" STREQUAL BAR)
  27. message(FATAL_ERROR "The quoted variable should match the string")
  28. endif()
  29. endfunction()
  30. macro(macro_defined_old_called_new)
  31. if(NOT FOO STREQUAL BAR)
  32. message(FATAL_ERROR "The variable should match the string")
  33. endif()
  34. if(NOT "FOO" STREQUAL BAR)
  35. message(FATAL_ERROR "The quoted variable should match the string")
  36. endif()
  37. endmacro()
  38. cmake_policy(SET CMP0054 NEW)
  39. function_defined_old_called_new()
  40. macro_defined_old_called_new()