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