From 3c7c21cea33e371d88848b12df4f60c570963077 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Thu, 28 Jul 2022 11:13:12 +0200 Subject: [PATCH] cmake: add hand made join_paths (because we don't use cmake v3.20+ yet) --- cmake/modules/JoinPaths.cmake | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 cmake/modules/JoinPaths.cmake diff --git a/cmake/modules/JoinPaths.cmake b/cmake/modules/JoinPaths.cmake new file mode 100644 index 000000000..fa0be17f4 --- /dev/null +++ b/cmake/modules/JoinPaths.cmake @@ -0,0 +1,23 @@ +# This module provides function for joining paths +# known from most languages +# +# SPDX-License-Identifier: (MIT OR CC0-1.0) +# Copyright 2020 Jan Tojnar +# https://github.com/jtojnar/cmake-snips +# +# Modelled after Python’s os.path.join +# https://docs.python.org/3.7/library/os.path.html#os.path.join +# Windows not supported +function(join_paths joined_path first_path_segment) + set(temp_path "${first_path_segment}") + foreach(current_segment IN LISTS ARGN) + if(NOT ("${current_segment}" STREQUAL "")) + if(IS_ABSOLUTE "${current_segment}") + set(temp_path "${current_segment}") + else() + set(temp_path "${temp_path}/${current_segment}") + endif() + endif() + endforeach() + set(${joined_path} "${temp_path}" PARENT_SCOPE) +endfunction()