diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -590,6 +590,7 @@ if(ARG_COMPONENT_LIB) set_target_properties(${name} PROPERTIES LLVM_COMPONENT TRUE) + set_property(TARGET ${name} APPEND PROPERTY EXPORT_PROPERTIES LLVM_COMPONENT) set_property(GLOBAL APPEND PROPERTY LLVM_COMPONENT_LIBS ${name}) endif() diff --git a/llvm/cmake/modules/CMakeLists.txt b/llvm/cmake/modules/CMakeLists.txt --- a/llvm/cmake/modules/CMakeLists.txt +++ b/llvm/cmake/modules/CMakeLists.txt @@ -82,6 +82,11 @@ "set(LLVM_LINK_LLVM_DYLIB ${LLVM_LINK_LLVM_DYLIB})") endif() +# Some global properties needed to make llvm_map_components_to_libnames() +# work. +get_property(LLVM_CONFIG_COMPONENT_LIBS GLOBAL PROPERTY LLVM_COMPONENT_LIBS) +get_property(LLVM_CONFIG_DYLIB_INCLUDED_LIBNAMES GLOBAL PROPERTY LLVM_DYLIB_INCLUDED_LIBNAMES) + # We need to use the full path to the LLVM Exports file to make sure we get the # one from the build tree. This is due to our cmake files being split between # this source dir and the binary dir in the build tree configuration and the diff --git a/llvm/cmake/modules/LLVMConfig.cmake.in b/llvm/cmake/modules/LLVMConfig.cmake.in --- a/llvm/cmake/modules/LLVMConfig.cmake.in +++ b/llvm/cmake/modules/LLVMConfig.cmake.in @@ -29,6 +29,10 @@ set(LLVM_DYLIB_COMPONENTS @LLVM_DYLIB_COMPONENTS@) +set_property(GLOBAL PROPERTY LLVM_COMPONENT_LIBS @LLVM_CONFIG_COMPONENT_LIBS@) + +set_property(GLOBAL PROPERTY LLVM_DYLIB_INCLUDED_LIBNAMES @LLVM_CONFIG_DYLIB_INCLUDED_LIBNAMES@) + set(LLVM_ALL_TARGETS @LLVM_ALL_TARGETS@) set(LLVM_TARGETS_TO_BUILD @LLVM_TARGETS_TO_BUILD@) diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt b/llvm/tools/llvm-shlib/CMakeLists.txt --- a/llvm/tools/llvm-shlib/CMakeLists.txt +++ b/llvm/tools/llvm-shlib/CMakeLists.txt @@ -33,6 +33,11 @@ add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME ${INSTALL_WITH_TOOLCHAIN} ${SOURCES}) list(REMOVE_DUPLICATES LIB_NAMES) + + # Set a global property for the library names that are included in libLLVM + # so that everyone has a precise list to determine when to redirect. + set_property(GLOBAL PROPERTY LLVM_DYLIB_INCLUDED_LIBNAMES ${LIB_NAMES}) + if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") OR (MINGW) OR (HAIKU) OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD") OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "GNU") @@ -192,5 +197,5 @@ # Make sure we search LLVMSupport first, before the CRT libs set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -INCLUDE:malloc") endif() - + endif()