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