blob: 193caed76a1d9b289314fee983f849e55ea08137 [file] [log] [blame]
Bill Roberts202a1632024-01-09 13:10:05 -06001# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
2# This module provides function for joining paths
3# known from most languages
4#
5# Copyright The Mbed TLS Contributors
6#
7# This script originates from:
8# - https://github.com/jtojnar/cmake-snips
9# Jan has provided re-licensing under Apache 2.0 and GPL 2.0+ and
10# allowed for the change of Copyright.
11#
12# Modelled after Python’s os.path.join
13# https://docs.python.org/3.7/library/os.path.html#os.path.join
14# Windows not supported
15function(join_paths joined_path first_path_segment)
16 set(temp_path "${first_path_segment}")
17 foreach(current_segment IN LISTS ARGN)
18 if(NOT ("${current_segment}" STREQUAL ""))
19 if(IS_ABSOLUTE "${current_segment}")
20 set(temp_path "${current_segment}")
21 else()
22 set(temp_path "${temp_path}/${current_segment}")
23 endif()
24 endif()
25 endforeach()
26 set(${joined_path} "${temp_path}" PARENT_SCOPE)
27endfunction()