diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2021-12-14 14:52:02 -0500 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2021-12-30 06:19:30 +0000 |
commit | bde561c4813952847112600e5efe72d9015556f7 (patch) | |
tree | b6e67b2e1f52ead4e40b2af593f8de97ce45fc7b | |
parent | 458db51c101bc3372e96b71bda7ca0f5ba2ae431 (diff) | |
download | llvm-bde561c4813952847112600e5efe72d9015556f7.zip llvm-bde561c4813952847112600e5efe72d9015556f7.tar.gz llvm-bde561c4813952847112600e5efe72d9015556f7.tar.bz2 |
[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
-rw-r--r-- | cmake/Modules/ExtendPath.cmake | 19 | ||||
-rw-r--r-- | compiler-rt/cmake/base-config-ix.cmake | 25 |
2 files changed, 25 insertions, 19 deletions
diff --git a/cmake/Modules/ExtendPath.cmake b/cmake/Modules/ExtendPath.cmake new file mode 100644 index 0000000..5db393a --- /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() diff --git a/compiler-rt/cmake/base-config-ix.cmake b/compiler-rt/cmake/base-config-ix.cmake index 447232e..1ada0ab 100644 --- a/compiler-rt/cmake/base-config-ix.cmake +++ b/compiler-rt/cmake/base-config-ix.cmake @@ -5,6 +5,7 @@ include(CheckIncludeFile) include(CheckCXXSourceCompiles) +include(ExtendPath) check_include_file(unwind.h HAVE_UNWIND_H) @@ -85,20 +86,6 @@ else() set(COMPILER_RT_TEST_COMPILER_ID GNU) endif() -function(extend_install_path joined_path current_segment) - if("${current_segment}" STREQUAL "") - set(temp_path "${COMPILER_RT_INSTALL_PATH}") - elseif("${COMPILER_RT_INSTALL_PATH}" STREQUAL "") - set(temp_path "${current_segment}") - elseif(IS_ABSOLUTE "${current_segment}") - message(WARNING "Since \"${current_segment}\" is absolute, it overrides COMPILER_RT_INSTALL_PATH: \"${COMPILER_RT_INSTALL_PATH}\".") - set(temp_path "${current_segment}") - else() - set(temp_path "${COMPILER_RT_INSTALL_PATH}/${current_segment}") - endif() - set(${joined_path} "${temp_path}" PARENT_SCOPE) -endfunction() - if(NOT DEFINED COMPILER_RT_OS_DIR) if(ANDROID) # The CMAKE_SYSTEM_NAME for Android is Android, but the OS is Linux and the @@ -111,23 +98,23 @@ endif() if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) set(COMPILER_RT_OUTPUT_LIBRARY_DIR ${COMPILER_RT_OUTPUT_DIR}/lib) - extend_install_path(default_install_path lib) + extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" lib) set(COMPILER_RT_INSTALL_LIBRARY_DIR "${default_install_path}" CACHE PATH "Path where built compiler-rt libraries should be installed.") else(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) set(COMPILER_RT_OUTPUT_LIBRARY_DIR ${COMPILER_RT_OUTPUT_DIR}/lib/${COMPILER_RT_OS_DIR}) - extend_install_path(default_install_path "lib/${COMPILER_RT_OS_DIR}") + extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "lib/${COMPILER_RT_OS_DIR}") set(COMPILER_RT_INSTALL_LIBRARY_DIR "${default_install_path}" CACHE PATH "Path where built compiler-rt libraries should be installed.") endif() -extend_install_path(default_install_path bin) +extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" bin) set(COMPILER_RT_INSTALL_BINARY_DIR "${default_install_path}" CACHE PATH "Path where built compiler-rt executables should be installed.") -extend_install_path(default_install_path include) +extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" include) set(COMPILER_RT_INSTALL_INCLUDE_DIR "${default_install_path}" CACHE PATH "Path where compiler-rt headers should be installed.") -extend_install_path(default_install_path share) +extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" share) set(COMPILER_RT_INSTALL_DATA_DIR "${default_install_path}" CACHE PATH "Path where compiler-rt data files should be installed.") |