You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
819B

  1. # This module provides a function for joining paths
  2. # known from most languages
  3. #
  4. # SPDX-License-Identifier: (MIT OR CC0-1.0)
  5. # Copyright 2020 Jan Tojnar
  6. # https://github.com/jtojnar/cmake-snips
  7. #
  8. # Modelled after Python’s os.path.join
  9. # https://docs.python.org/3.7/library/os.path.html#os.path.join
  10. # Windows not supported
  11. function(join_paths joined_path first_path_segment)
  12. set(temp_path "${first_path_segment}")
  13. foreach(current_segment IN LISTS ARGN)
  14. if(NOT ("${current_segment}" STREQUAL ""))
  15. if(IS_ABSOLUTE "${current_segment}")
  16. set(temp_path "${current_segment}")
  17. else()
  18. set(temp_path "${temp_path}/${current_segment}")
  19. endif()
  20. endif()
  21. endforeach()
  22. set(${joined_path} "${temp_path}" PARENT_SCOPE)
  23. endfunction()