From 9f3db56ec8a12def7f2cc5a90f1a54f47eea6c5f Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Thu, 11 Sep 2014 22:56:28 +0000 Subject: [PATCH] Merging r217484: ------------------------------------------------------------------------ r217484 | delcypher | 2014-09-10 11:18:59 +0100 (Wed, 10 Sep 2014) | 13 lines Attempt to fix PR20884 This fixes the generation of broken LLVMExports.cmake file by the Autoconf/Makefile build system when --enable-shared is passed to configure. When --enable_shared is passed the Makefile.rules does not set the LLVMConfigLibs variable which cmake/modules/Makefile previously relied on. Now it runs the llvm-config command itself to get the library names. This still isn't perfect because the generated LLVM targets refer to the static libraries and not the shared library but that is much larger problem to fix. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_35@217638 91177308-0d34-0410-b5e6-96231b3b80d8 --- cmake/modules/Makefile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cmake/modules/Makefile b/cmake/modules/Makefile index ba45f1737b1..1ec5b190b35 100644 --- a/cmake/modules/Makefile +++ b/cmake/modules/Makefile @@ -33,6 +33,16 @@ else LLVM_ENABLE_RTTI := 0 endif +LLVM_LIBS_TO_EXPORT := $(subst -l,,$(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS) || echo Error)) + +ifeq ($(LLVM_LIBS_TO_EXPORT),Error) +$(error llvm-config --libs failed) +endif + +ifndef LLVM_LIBS_TO_EXPORT +$(error LLVM_LIBS_TO_EXPORT cannot be empty) +endif + OBJMODS := LLVMConfig.cmake LLVMConfigVersion.cmake LLVMExports.cmake $(PROJ_OBJ_DIR)/LLVMConfig.cmake: LLVMConfig.cmake.in $(LLVMBuildCMakeFrag) @@ -45,7 +55,7 @@ $(PROJ_OBJ_DIR)/LLVMConfig.cmake: LLVMConfig.cmake.in $(LLVMBuildCMakeFrag) -e 's/@LLVM_VERSION_PATCH@/'"$(LLVM_VERSION_PATCH)"'/' \ -e 's/@PACKAGE_VERSION@/'"$(LLVMVersion)"'/' \ -e 's/@LLVM_COMMON_DEPENDS@//' \ - -e 's/@LLVM_AVAILABLE_LIBS@/'"$(subst -l,,$(LLVMConfigLibs))"'/' \ + -e 's/@LLVM_AVAILABLE_LIBS@/'"$(LLVM_LIBS_TO_EXPORT)"'/' \ -e 's/@LLVM_ALL_TARGETS@/'"$(ALL_TARGETS)"'/' \ -e 's/@LLVM_TARGETS_TO_BUILD@/'"$(TARGETS_TO_BUILD)"'/' \ -e 's/@LLVM_TARGETS_WITH_JIT@/'"$(TARGETS_WITH_JIT)"'/' \ @@ -83,7 +93,7 @@ $(PROJ_OBJ_DIR)/LLVMExports.cmake: $(LLVMBuildCMakeExportsFrag) $(Echo) 'Generating LLVM CMake target exports file' $(Verb) ( \ echo '# LLVM CMake target exports. Do not include directly.' && \ - for lib in $(subst -l,,$(LLVMConfigLibs)); do \ + for lib in $(LLVM_LIBS_TO_EXPORT); do \ echo 'add_library('"$$lib"' STATIC IMPORTED)' && \ echo 'set_property(TARGET '"$$lib"' PROPERTY IMPORTED_LOCATION "'"$(PROJ_libdir)/lib$$lib.a"'")' ; \ done && \