CMP0186.cmake 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. set(mylist 0000 1001 0002)
  2. # OLD
  3. cmake_policy(SET CMP0186 OLD)
  4. unset(output)
  5. list(TRANSFORM mylist REPLACE "^0" "" OUTPUT_VARIABLE output)
  6. if (NOT output STREQUAL ";1001;2")
  7. message(FATAL_ERROR "TRANSFORM(REPLACE) is \"${output}\", expected is \";1001;2\"")
  8. endif()
  9. unset(output)
  10. list(TRANSFORM mylist REPLACE "^(a|0)" "x" OUTPUT_VARIABLE output)
  11. if (NOT output STREQUAL "xxxx;1001;xxx2")
  12. message(FATAL_ERROR "TRANSFORM(REPLACE) is \"${output}\", expected is \"xxxx;1001;xxx2\"")
  13. endif()
  14. unset(output)
  15. list(TRANSFORM mylist REPLACE "(1|^)0" "x" OUTPUT_VARIABLE output)
  16. if (NOT output STREQUAL "xxxx;xx1;xxx2")
  17. message(FATAL_ERROR "TRANSFORM(REPLACE) is \"${output}\", expected is \"xxxx;xx1;xxx2\"")
  18. endif()
  19. # NEW, same cases as above
  20. cmake_policy(SET CMP0186 NEW)
  21. unset(output)
  22. list(TRANSFORM mylist REPLACE "^0" "" OUTPUT_VARIABLE output)
  23. if (NOT output STREQUAL "000;1001;002")
  24. message(FATAL_ERROR "TRANSFORM(REPLACE) is \"${output}\", expected is \"000;1001;002\"")
  25. endif()
  26. unset(output)
  27. list(TRANSFORM mylist REPLACE "^(a|0)" "x" OUTPUT_VARIABLE output)
  28. if (NOT output STREQUAL "x000;1001;x002")
  29. message(FATAL_ERROR "TRANSFORM(REPLACE) is \"${output}\", expected is \"x000;1001;x002\"")
  30. endif()
  31. unset(output)
  32. list(TRANSFORM mylist REPLACE "(1|^)0" "x" OUTPUT_VARIABLE output)
  33. if (NOT output STREQUAL "x000;x01;x002")
  34. message(FATAL_ERROR "TRANSFORM(REPLACE) is \"${output}\", expected is \"x000;xx1;x002\"")
  35. endif()