CMAKE_PATH.cmake.in 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. include ("${RunCMake_SOURCE_DIR}/check_errors.cmake")
  2. unset (errors)
  3. cmake_path(SET reference "/x/y/z/../../a/d")
  4. set(output "$<PATH:CMAKE_PATH,/x/y/z/../../a/d>")
  5. if (NOT output STREQUAL reference)
  6. list (APPEND errors "'${output}' instead of '${reference}'")
  7. endif()
  8. cmake_path(SET reference NORMALIZE "/x/y/z/../../a/d")
  9. set(output "$<PATH:CMAKE_PATH,NORMALIZE,/x/y/z/../../a/d>")
  10. if (NOT output STREQUAL reference)
  11. list (APPEND errors "'${output}' instead of '${reference}'")
  12. endif()
  13. if (WIN32)
  14. cmake_path(SET reference "/x\\y/z\\..\\../a/d")
  15. set(output "$<PATH:CMAKE_PATH,/x\y/z\..\../a/d>")
  16. if (NOT output STREQUAL reference)
  17. list (APPEND errors "'${output}' instead of '${reference}'")
  18. endif()
  19. cmake_path(SET reference NORMALIZE "/x\\y/z\\..\\../a/d")
  20. set(output "$<PATH:CMAKE_PATH,NORMALIZE,/x\y/z\..\../a/d>")
  21. if (NOT output STREQUAL reference)
  22. list (APPEND errors "'${output}' instead of '${reference}'")
  23. endif()
  24. cmake_path(SET reference "//?/c:/x\\y/z\\..\\../a/d")
  25. set(output "$<PATH:CMAKE_PATH,//?/c:/x\y/z\..\../a/d>")
  26. if (NOT output STREQUAL reference)
  27. list (APPEND errors "'${output}' instead of '${reference}'")
  28. endif()
  29. cmake_path(SET reference NORMALIZE "//?/c:/x\\y/z\\..\\../a/d")
  30. set(output "$<PATH:CMAKE_PATH,NORMALIZE,//?/c:/x\y/z\..\../a/d>")
  31. if (NOT output STREQUAL reference)
  32. list (APPEND errors "'${output}' instead of '${reference}'")
  33. endif()
  34. cmake_path(SET reference "\\\\?\\UNC/host/x\\y/z\\..\\../a/d")
  35. set(output "$<PATH:CMAKE_PATH,\\?\UNC/host/x\y/z\..\../a/d>")
  36. if (NOT output STREQUAL reference)
  37. list (APPEND errors "'${output}' instead of '${reference}'")
  38. endif()
  39. cmake_path(SET reference NORMALIZE "\\\\?\\UNC\\host/x\\y/z\\..\\../a/d")
  40. set(output "$<PATH:CMAKE_PATH,NORMALIZE,\\?\UNC/host/x\y/z\..\../a/d>")
  41. if (NOT output STREQUAL reference)
  42. list (APPEND errors "'${output}' instead of '${reference}'")
  43. endif()
  44. endif()
  45. ######################################
  46. ## tests with list of paths
  47. ######################################
  48. set(reference "/x/y/z/../../a/d;/x/y/z/../../b/e")
  49. set(output "$<PATH:CMAKE_PATH,/x/y/z/../../a/d;/x/y/z/../../b/e>")
  50. if (NOT output STREQUAL reference)
  51. list (APPEND errors "'${output}' instead of '${reference}'")
  52. endif()
  53. unset(reference)
  54. foreach(path IN ITEMS "/x/y/z/../../a/d" "/x/y/z/../../b/e")
  55. cmake_path(SET result NORMALIZE "${path}")
  56. list(APPEND reference "${result}")
  57. endforeach()
  58. set(output "$<PATH:CMAKE_PATH,NORMALIZE,/x/y/z/../../a/d;/x/y/z/../../b/e>")
  59. if (NOT output STREQUAL reference)
  60. list (APPEND errors "'${output}' instead of '${reference}'")
  61. endif()
  62. if (WIN32)
  63. unset(reference)
  64. foreach(path IN ITEMS "/x\\y/z\\..\\../a/d" "/x\\y/z\\..\\../b/e")
  65. cmake_path(SET result "${path}")
  66. list(APPEND reference "${result}")
  67. endforeach()
  68. set(output "$<PATH:CMAKE_PATH,/x\y/z\..\../a/d;/x\y/z\..\../b/e>")
  69. if (NOT output STREQUAL reference)
  70. list (APPEND errors "'${output}' instead of '${reference}'")
  71. endif()
  72. unset(reference)
  73. foreach(path IN ITEMS "/x\\y/z\\..\\../a/d" "/x\\y/z\\..\\../b/e")
  74. cmake_path(SET result NORMALIZE "${path}")
  75. list(APPEND reference "${result}")
  76. endforeach()
  77. set(output "$<PATH:CMAKE_PATH,NORMALIZE,/x\y/z\..\../a/d;/x\y/z\..\../b/e>")
  78. if (NOT output STREQUAL reference)
  79. list (APPEND errors "'${output}' instead of '${reference}'")
  80. endif()
  81. endif()
  82. check_errors("PATH:CMAKE_PATH" ${errors})