git repos / blockattack-game

blame: source/misc/embedded_libs/fmt-8.1.1/support/cmake/JoinPaths.cmake

normal view · raw

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