Teach LLVM-Config to use logical target names (2/2)
authorNAKAMURA Takumi <geek4civic@gmail.com>
Fri, 21 Feb 2014 14:17:07 +0000 (14:17 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Fri, 21 Feb 2014 14:17:07 +0000 (14:17 +0000)
The module still needs to collect the list of all available libraries
in order to satisfy the 'all' component.  Provide this in the package
configuration file, 'LLVMConfig.cmake', as a LLVM_AVAILABLE_LIBS
variable.  (A variable is scoped better than a global property.)
Since this won't be set for our own build, fall back to looking up the
LLVM_LIBS property to get the value when it is not set.

Contributed by Brad King.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201853 91177308-0d34-0410-b5e6-96231b3b80d8

cmake/modules/CMakeLists.txt
cmake/modules/LLVM-Config.cmake
cmake/modules/LLVMConfig.cmake.in
cmake/modules/Makefile

index 8ab5ca27f5d1e9b461bf7fb77bcd5dc79c6de1ac..08aeeb9a92e915fdfb5abab5f45d719d63dc5443 100644 (file)
@@ -5,9 +5,9 @@ get_property(LLVM_EXPORTS GLOBAL PROPERTY LLVM_EXPORTS)
 export(TARGETS ${LLVM_EXPORTS}
   FILE ${llvm_cmake_builddir}/LLVMExports.cmake)
 
-get_property(llvm_libs GLOBAL PROPERTY LLVM_LIBS)
+get_property(LLVM_AVAILABLE_LIBS GLOBAL PROPERTY LLVM_LIBS)
 
-foreach(lib ${llvm_libs})
+foreach(lib ${LLVM_AVAILABLE_LIBS})
   get_property(llvm_lib_deps GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${lib})
   set(all_llvm_lib_deps
     "${all_llvm_lib_deps}\nset_property(GLOBAL PROPERTY LLVMBUILD_LIB_DEPS_${lib} ${llvm_lib_deps})")
index 62470d0dde2721b3a06256fcc3a5a093773e0957..af720fcb2143c02a48e928f694e68b7041928d41 100644 (file)
@@ -77,8 +77,11 @@ endfunction(llvm_map_components_to_libraries)
 # Map LINK_COMPONENTS to actual libnames.
 function(llvm_map_components_to_libnames out_libs)
   set( link_components ${ARGN} )
-  get_property(llvm_libs GLOBAL PROPERTY LLVM_LIBS)
-  string(TOUPPER "${llvm_libs}" capitalized_libs)
+  if(NOT LLVM_AVAILABLE_LIBS)
+    # Inside LLVM itself available libs are in a global property.
+    get_property(LLVM_AVAILABLE_LIBS GLOBAL PROPERTY LLVM_LIBS)
+  endif()
+  string(TOUPPER "${LLVM_AVAILABLE_LIBS}" capitalized_libs)
 
   # Expand some keywords:
   list(FIND LLVM_TARGETS_TO_BUILD "${LLVM_NATIVE_ARCH}" have_native_backend)
@@ -134,7 +137,7 @@ function(llvm_map_components_to_libnames out_libs)
     elseif( c STREQUAL "engine" )
       # already processed
     elseif( c STREQUAL "all" )
-      list(APPEND expanded_components ${llvm_libs})
+      list(APPEND expanded_components ${LLVM_AVAILABLE_LIBS})
     else( NOT idx LESS 0 )
       # Canonize the component name:
       string(TOUPPER "${c}" capitalized)
@@ -146,7 +149,7 @@ function(llvm_map_components_to_libnames out_libs)
           message(FATAL_ERROR "Library `${c}' not found in list of llvm libraries.")
         endif()
       else( lib_idx LESS 0 )
-        list(GET llvm_libs ${lib_idx} canonical_lib)
+        list(GET LLVM_AVAILABLE_LIBS ${lib_idx} canonical_lib)
         list(APPEND expanded_components ${canonical_lib})
       endif( lib_idx LESS 0 )
     endif( NOT idx LESS 0 )
index c1b6450ad687569427c8c3ab1707cca6283c8e21..11857a5384661e7890012e129f434bd8bf10acc5 100644 (file)
@@ -8,7 +8,7 @@ set(LLVM_PACKAGE_VERSION @PACKAGE_VERSION@)
 
 set(LLVM_COMMON_DEPENDS @LLVM_COMMON_DEPENDS@)
 
-set_property( GLOBAL PROPERTY LLVM_LIBS "@llvm_libs@")
+set(LLVM_AVAILABLE_LIBS @LLVM_AVAILABLE_LIBS@)
 
 set(LLVM_ALL_TARGETS @LLVM_ALL_TARGETS@)
 
index 055e93586018aa3c5d65fa55dbc85fa1226de468..894067d6f5fb789dc4d7973f6cb37d2d1600f1ce 100644 (file)
@@ -30,7 +30,7 @@ $(PROJ_OBJ_DIR)/LLVMConfig.cmake: LLVMConfig.cmake.in $(LLVMBuildCMakeFrag)
          -e 's/@LLVM_VERSION_MINOR@/'"$(LLVM_VERSION_MINOR)"'/' \
          -e 's/@PACKAGE_VERSION@/'"$(LLVMVersion)"'/' \
          -e 's/@LLVM_COMMON_DEPENDS@//' \
-         -e 's/"@llvm_libs@"/'"$(subst -l,,$(LLVMConfigLibs))"'/' \
+         -e 's/@LLVM_AVAILABLE_LIBS@/'"$(subst -l,,$(LLVMConfigLibs))"'/' \
          -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)"'/' \