CMP0054-policy-foreach-scope.cmake 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. set(FOO BAR)
  2. cmake_policy(SET CMP0054 NEW)
  3. foreach(loop_var arg1 arg2)
  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. cmake_policy(SET CMP0054 OLD)
  11. if(NOT FOO STREQUAL BAR)
  12. message(FATAL_ERROR "The variable should match the string")
  13. endif()
  14. if(NOT "FOO" STREQUAL BAR)
  15. message(FATAL_ERROR "The quoted variable should match the string")
  16. endif()
  17. cmake_policy(SET CMP0054 NEW)
  18. endforeach()
  19. cmake_policy(SET CMP0054 OLD)
  20. foreach(loop_var arg1 arg2)
  21. if(NOT FOO STREQUAL BAR)
  22. message(FATAL_ERROR "The variable should match the string")
  23. endif()
  24. if(NOT "FOO" STREQUAL BAR)
  25. message(FATAL_ERROR "The quoted variable should match the string")
  26. endif()
  27. cmake_policy(SET CMP0054 NEW)
  28. if(NOT FOO STREQUAL BAR)
  29. message(FATAL_ERROR "The variable should match the string")
  30. endif()
  31. if("FOO" STREQUAL BAR)
  32. message(FATAL_ERROR "The strings should not match")
  33. endif()
  34. cmake_policy(SET CMP0054 OLD)
  35. endforeach()