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