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