diff --git a/cmake/Modules/ExtendInstallPath.cmake b/cmake/Modules/ExtendInstallPath.cmake new file mode 100644 --- /dev/null +++ b/cmake/Modules/ExtendInstallPath.cmake @@ -0,0 +1,16 @@ +# Extend path with relative of absolute path, warning in the absolute path +# case, and being careful to not introduce leading slashes if the original path +# is empty +function(extend_install_path prefix_var joined_path current_segment) + if("${current_segment}" STREQUAL "") + set(temp_path "${${prefix_var}}") + elseif("${${prefix_var}}" STREQUAL "") + set(temp_path "${current_segment}") + elseif(IS_ABSOLUTE "${current_segment}") + message(WARNING "Since \"${current_segment}\" is absolute, it overrides ${prefix_var}: \"${${prefix_var}}\".") + set(temp_path "${current_segment}") + else() + set(temp_path "${${prefix_var}}/${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 --- 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(ExtendInstallPath) check_include_file(unwind.h HAVE_UNWIND_H) @@ -85,20 +86,6 @@ 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 @@ 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_install_path(COMPILER_RT_INSTALL_PATH default_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_install_path(COMPILER_RT_INSTALL_PATH default_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_install_path(COMPILER_RT_INSTALL_PATH default_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_install_path(COMPILER_RT_INSTALL_PATH default_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_install_path(COMPILER_RT_INSTALL_PATH default_install_path share) set(COMPILER_RT_INSTALL_DATA_DIR "${default_install_path}" CACHE PATH "Path where compiler-rt data files should be installed.")