Export lib and exe build target names from install tree

Use the install(TARGETS) command EXPORT option for every library and
executable that we install with LLVM.  Then use the install(EXPORT)
command to provide a "LLVMExports.cmake" file that exports logical
targets for import into applications from our install tree.

The "LLVMExports.cmake" file is not meant for direct inclusion by
application code but should be included by "LLVMConfig.cmake" in a
future change.

Contributed by Brad King.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201049 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
NAKAMURA Takumi 2014-02-09 16:36:03 +00:00
parent 24ef854ac8
commit 39fcc71463
3 changed files with 10 additions and 2 deletions

View File

@ -195,6 +195,7 @@ macro(add_llvm_library name)
else()
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "LTO")
install(TARGETS ${name}
EXPORT LLVMExports
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
endif()
@ -246,6 +247,7 @@ ${name} ignored.")
else()
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(TARGETS ${name}
EXPORT LLVMExports
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
endif()
@ -294,7 +296,9 @@ macro(add_llvm_tool name)
list(FIND LLVM_TOOLCHAIN_TOOLS ${name} LLVM_IS_${name}_TOOLCHAIN_TOOL)
if (LLVM_IS_${name}_TOOLCHAIN_TOOL GREATER -1 OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
if( LLVM_BUILD_TOOLS )
install(TARGETS ${name} RUNTIME DESTINATION bin)
install(TARGETS ${name}
EXPORT LLVMExports
RUNTIME DESTINATION bin)
endif()
endif()
set_target_properties(${name} PROPERTIES FOLDER "Tools")

View File

@ -67,6 +67,8 @@ configure_file(
${llvm_cmake_builddir}/LLVMConfigVersion.cmake
@ONLY)
install(EXPORT LLVMExports DESTINATION ${LLVM_INSTALL_PACKAGE_DIR})
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLVMConfig.cmake

View File

@ -127,6 +127,8 @@ macro(add_tablegen target project)
endif()
if (${project} STREQUAL LLVM AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(TARGETS ${target} RUNTIME DESTINATION bin)
install(TARGETS ${target}
EXPORT LLVMExports
RUNTIME DESTINATION bin)
endif()
endmacro()