Teach LLVM-Config to use logical target names (2/2)

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
This commit is contained in:
NAKAMURA Takumi 2014-02-21 14:17:07 +00:00
parent 83782f2571
commit 6eeedf33d5
4 changed files with 11 additions and 8 deletions

View 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})")

View 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 )

View 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@)

View 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)"'/' \