1*3cc25752SFrank Piva# This module provides function for joining paths 2*3cc25752SFrank Piva# known from from most languages 3*3cc25752SFrank Piva# 4*3cc25752SFrank Piva# Original license: 5*3cc25752SFrank Piva# SPDX-License-Identifier: (MIT OR CC0-1.0) 6*3cc25752SFrank Piva# Explicit permission given to distribute this module under 7*3cc25752SFrank Piva# the terms of the project as described in /LICENSE.rst. 8*3cc25752SFrank Piva# Copyright 2020 Jan Tojnar 9*3cc25752SFrank Piva# https://github.com/jtojnar/cmake-snips 10*3cc25752SFrank Piva# 11*3cc25752SFrank Piva# Modelled after Python’s os.path.join 12*3cc25752SFrank Piva# https://docs.python.org/3.7/library/os.path.html#os.path.join 13*3cc25752SFrank Piva# Windows not supported 14*3cc25752SFrank Pivafunction(join_paths joined_path first_path_segment) 15*3cc25752SFrank Piva set(temp_path "${first_path_segment}") 16*3cc25752SFrank Piva foreach(current_segment IN LISTS ARGN) 17*3cc25752SFrank Piva if(NOT ("${current_segment}" STREQUAL "")) 18*3cc25752SFrank Piva if(IS_ABSOLUTE "${current_segment}") 19*3cc25752SFrank Piva set(temp_path "${current_segment}") 20*3cc25752SFrank Piva else() 21*3cc25752SFrank Piva set(temp_path "${temp_path}/${current_segment}") 22*3cc25752SFrank Piva endif() 23*3cc25752SFrank Piva endif() 24*3cc25752SFrank Piva endforeach() 25*3cc25752SFrank Piva set(${joined_path} "${temp_path}" PARENT_SCOPE) 26*3cc25752SFrank Pivaendfunction() 27