Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake =================================================================== --- compiler-rt/cmake/Modules/AddCompilerRT.cmake +++ compiler-rt/cmake/Modules/AddCompilerRT.cmake @@ -299,7 +299,7 @@ ) endif() endif() - install(TARGETS ${libname} + install(TARGETS ${libname} EXPORT LLVMRuntimes ARCHIVE DESTINATION ${install_dir_${libname}} ${COMPONENT_OPTION} LIBRARY DESTINATION ${install_dir_${libname}} @@ -336,6 +336,8 @@ if(type STREQUAL "SHARED") rt_externalize_debuginfo(${libname}) endif() + + set_property(GLOBAL APPEND PROPERTY LLVM_RUNTIMES ${libname}) endforeach() if(LIB_PARENT_TARGET) add_dependencies(${LIB_PARENT_TARGET} ${libnames}) Index: libcxx/lib/CMakeLists.txt =================================================================== --- libcxx/lib/CMakeLists.txt +++ libcxx/lib/CMakeLists.txt @@ -362,10 +362,11 @@ if (LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY) set(experimental_lib cxx_experimental) endif() - install(TARGETS ${LIBCXX_TARGETS} ${experimental_lib} + install(TARGETS ${LIBCXX_TARGETS} ${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_TARGETS} ${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) Index: libcxxabi/src/CMakeLists.txt =================================================================== --- libcxxabi/src/CMakeLists.txt +++ libcxxabi/src/CMakeLists.txt @@ -183,10 +183,11 @@ add_custom_target(cxxabi DEPENDS ${LIBCXXABI_TARGETS}) if (LIBCXXABI_INSTALL_LIBRARY) - install(TARGETS ${LIBCXXABI_TARGETS} + install(TARGETS ${LIBCXXABI_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_TARGETS}) endif() if (NOT CMAKE_CONFIGURATION_TYPES AND LIBCXXABI_INSTALL_LIBRARY) Index: libunwind/src/CMakeLists.txt =================================================================== --- libunwind/src/CMakeLists.txt +++ libunwind/src/CMakeLists.txt @@ -136,9 +136,10 @@ add_custom_target(unwind DEPENDS ${LIBUNWIND_TARGETS}) if (LIBUNWIND_INSTALL_LIBRARY) - install(TARGETS ${LIBUNWIND_TARGETS} + install(TARGETS ${LIBUNWIND_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_TARGETS}) endif() if (NOT CMAKE_CONFIGURATION_TYPES AND LIBUNWIND_INSTALL_LIBRARY) Index: llvm/runtimes/CMakeLists.txt =================================================================== --- llvm/runtimes/CMakeLists.txt +++ 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,16 @@ 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)