summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmake/Modules/ExtendPath.cmake19
-rw-r--r--compiler-rt/cmake/base-config-ix.cmake25
2 files changed, 25 insertions, 19 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()
diff --git a/compiler-rt/cmake/base-config-ix.cmake b/compiler-rt/cmake/base-config-ix.cmake
index 447232e02438..1ada0ab30ba0 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.")