diff --git a/libcxx/lib/CMakeLists.txt b/libcxx/lib/CMakeLists.txt --- a/libcxx/lib/CMakeLists.txt +++ b/libcxx/lib/CMakeLists.txt @@ -98,7 +98,9 @@ if (NOT LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_shared OR HAVE_LIBUNWIND)) add_interface_library(unwind_shared) elseif (LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_static OR HAVE_LIBUNWIND)) - add_interface_library(unwind_static) + if (NOT LIBCXXABI_ENABLE_STATIC_UNWINDER) + add_interface_library(unwind_static) + endif() else() add_interface_library(unwind) endif() @@ -413,10 +415,11 @@ if (LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY) set(experimental_lib cxx_experimental) endif() - install(TARGETS ${LIBCXX_INSTALL_TARGETS} ${filesystem_lib} ${experimental_lib} + install(TARGETS ${LIBCXX_INSTALL_TARGETS} ${filesystem_lib} ${experimental_lib} EXPORT LLVMRuntimes LIBRARY DESTINATION ${LIBCXX_INSTALL_PREFIX}lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT cxx ARCHIVE DESTINATION ${LIBCXX_INSTALL_PREFIX}lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT cxx ) + set_property(GLOBAL APPEND PROPERTY LLVM_RUNTIMES ${LIBCXX_INSTALL_TARGETS} ${filesystem_lib} ${experimental_lib}) # NOTE: This install command must go after the cxx install command otherwise # it will not be executed after the library symlinks are installed. if (LIBCXX_ENABLE_SHARED AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT) diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt --- a/libcxxabi/src/CMakeLists.txt +++ b/libcxxabi/src/CMakeLists.txt @@ -251,10 +251,11 @@ add_custom_target(cxxabi DEPENDS ${LIBCXXABI_BUILD_TARGETS}) if (LIBCXXABI_INSTALL_LIBRARY) - install(TARGETS ${LIBCXXABI_INSTALL_TARGETS} + install(TARGETS ${LIBCXXABI_INSTALL_TARGETS} EXPORT LLVMRuntimes LIBRARY DESTINATION ${LIBCXXABI_INSTALL_PREFIX}lib${LIBCXXABI_LIBDIR_SUFFIX} COMPONENT cxxabi ARCHIVE DESTINATION ${LIBCXXABI_INSTALL_PREFIX}lib${LIBCXXABI_LIBDIR_SUFFIX} COMPONENT cxxabi ) + set_property(GLOBAL APPEND PROPERTY LLVM_RUNTIMES ${LIBCXXABI_INSTALL_TARGETS}) endif() if (NOT CMAKE_CONFIGURATION_TYPES AND LIBCXXABI_INSTALL_LIBRARY) diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt --- a/libunwind/src/CMakeLists.txt +++ b/libunwind/src/CMakeLists.txt @@ -177,9 +177,10 @@ add_custom_target(unwind DEPENDS ${LIBUNWIND_BUILD_TARGETS}) if (LIBUNWIND_INSTALL_LIBRARY) - install(TARGETS ${LIBUNWIND_INSTALL_TARGETS} + install(TARGETS ${LIBUNWIND_INSTALL_TARGETS} EXPORT LLVMRuntimes LIBRARY DESTINATION ${LIBUNWIND_INSTALL_PREFIX}lib${LIBUNWIND_LIBDIR_SUFFIX} COMPONENT unwind ARCHIVE DESTINATION ${LIBUNWIND_INSTALL_PREFIX}lib${LIBUNWIND_LIBDIR_SUFFIX} COMPONENT unwind) + set_property(GLOBAL APPEND PROPERTY LLVM_RUNTIMES ${LIBUNWIND_INSTALL_TARGETS}) endif() if (NOT CMAKE_CONFIGURATION_TYPES AND LIBUNWIND_INSTALL_LIBRARY) diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt --- a/llvm/runtimes/CMakeLists.txt +++ b/llvm/runtimes/CMakeLists.txt @@ -117,6 +117,9 @@ include(AddLLVM) include(HandleLLVMOptions) + string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION + ${PACKAGE_VERSION}) + set(CMAKE_REQUIRED_FLAGS ${SAFE_CMAKE_REQUIRED_FLAGS}) set(CMAKE_REQUIRED_LIBRARIES ${SAFE_CMAKE_REQUIRED_LIBRARIES}) @@ -208,6 +211,17 @@ endif() endif() + if(LLVM_RUNTIMES_TARGET) + set(LLVM_RUNTIMES_FILE ${LLVM_BINARY_DIR}/runtimes/${LLVM_RUNTIMES_TARGET}/LLVMRuntimes.cmake) + else() + set(LLVM_RUNTIMES_FILE ${LLVM_BINARY_DIR}/runtimes/LLVMRuntimes.cmake) + endif() + get_property(LLVM_RUNTIMES GLOBAL PROPERTY LLVM_RUNTIMES) + export(TARGETS ${LLVM_RUNTIMES} FILE ${LLVM_RUNTIMES_FILE}) + + install(EXPORT LLVMRuntimes + DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/${LLVM_DEFAULT_TARGET_TRIPLE} + COMPONENT cmake-exports) else() # if this is included from LLVM's CMake include(LLVMExternalProjectUtils)