Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2021-12-14 22:52:02 +0300
committerJohn Ericson <John.Ericson@Obsidian.Systems>2021-12-30 09:19:30 +0300
commitbde561c4813952847112600e5efe72d9015556f7 (patch)
treeb6e67b2e1f52ead4e40b2af593f8de97ce45fc7b /cmake/Modules/ExtendPath.cmake
parent458db51c101bc3372e96b71bda7ca0f5ba2ae431 (diff)
[compiler-rt][cmake] Factor out extend_install_path function
It is likely to become used again, if other projects want their own per-project install directory variables. `install` is removed from the name since it is not inherently about installing. Reviewed By: stephenneuendorffer Differential Revision: https://reviews.llvm.org/D115746
Diffstat (limited to 'cmake/Modules/ExtendPath.cmake')
-rw-r--r--cmake/Modules/ExtendPath.cmake19
1 files changed, 19 insertions, 0 deletions
diff --git a/cmake/Modules/ExtendPath.cmake b/cmake/Modules/ExtendPath.cmake
new file mode 100644
index 000000000000..5db393a21e1c
--- /dev/null
+++ b/cmake/Modules/ExtendPath.cmake
@@ -0,0 +1,19 @@
+# Extend the path in `base_path` with the path in `current_segment`, returning
+# the result in `joined_path`. If `current_segment` is an absolute path then
+# just return it, in effect overriding `base_path`, and issue a warning.
+#
+# Note that the code returns a relative path (avoiding introducing leading
+# slashes) if `base_path` is empty.
+function(extend_path joined_path base_path current_segment)
+ if("${current_segment}" STREQUAL "")
+ set(temp_path "${base_path}")
+ elseif("${base_path}" STREQUAL "")
+ set(temp_path "${current_segment}")
+ elseif(IS_ABSOLUTE "${current_segment}")
+ message(WARNING "Since \"${current_segment}\" is absolute, it overrides install path: \"${base_path}\".")
+ set(temp_path "${current_segment}")
+ else()
+ set(temp_path "${base_path}/${current_segment}")
+ endif()
+ set(${joined_path} "${temp_path}" PARENT_SCOPE)
+endfunction()