KnownComponents.cmake 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. macro(check desc actual expect)
  2. if(NOT "x${actual}" STREQUAL "x${expect}")
  3. message(SEND_ERROR "${desc}: got \"${actual}\", not \"${expect}\"")
  4. endif()
  5. endmacro()
  6. set(filename "/path/to/filename.ext.in")
  7. set(expect_DIRECTORY "/path/to")
  8. set(expect_NAME "filename.ext.in")
  9. set(expect_EXT ".ext.in")
  10. set(expect_NAME_WE "filename")
  11. set(expect_PATH "/path/to")
  12. foreach(c DIRECTORY NAME EXT NAME_WE PATH)
  13. get_filename_component(actual_${c} "${filename}" ${c})
  14. check("${c}" "${actual_${c}}" "${expect_${c}}")
  15. endforeach()
  16. get_filename_component(test_slashes "c:\\path\\to\\filename.ext.in" DIRECTORY)
  17. check("DIRECTORY from backslashes" "${test_slashes}" "c:/path/to")
  18. get_filename_component(test_winroot "c:\\filename.ext.in" DIRECTORY)
  19. check("DIRECTORY in windows root" "${test_winroot}" "c:/")
  20. get_filename_component(test_absolute "/path/to/a/../filename.ext.in" ABSOLUTE)
  21. check("ABSOLUTE" "${test_absolute}" "/path/to/filename.ext.in")
  22. get_filename_component(test_absolute "/../path/to/filename.ext.in" ABSOLUTE)
  23. check("ABSOLUTE .. in root" "${test_absolute}" "/path/to/filename.ext.in")
  24. get_filename_component(test_absolute "c:/../path/to/filename.ext.in" ABSOLUTE)
  25. check("ABSOLUTE .. in windows root" "${test_absolute}" "c:/path/to/filename.ext.in")
  26. get_filename_component(test_cache "/path/to/filename.ext.in" DIRECTORY CACHE)
  27. check("CACHE 1" "${test_cache}" "/path/to")
  28. get_filename_component(test_cache "/path/to/other/filename.ext.in" DIRECTORY CACHE)
  29. check("CACHE 2" "${test_cache}" "/path/to")
  30. unset(test_cache CACHE)
  31. get_filename_component(test_cache "/path/to/other/filename.ext.in" DIRECTORY CACHE)
  32. check("CACHE 3" "${test_cache}" "/path/to/other")