From 39fcc71463b2ff97bab8bb284405ad27fdca06f8 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Sun, 9 Feb 2014 16:36:03 +0000 Subject: [PATCH] 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 --- cmake/modules/AddLLVM.cmake | 6 +++++- cmake/modules/CMakeLists.txt | 2 ++ cmake/modules/TableGen.cmake | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake index e925632aa9f..63e04619dc3 100644 --- a/cmake/modules/AddLLVM.cmake +++ b/cmake/modules/AddLLVM.cmake @@ -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") diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt index 4992be0e2f6..0620ae87c14 100644 --- a/cmake/modules/CMakeLists.txt +++ b/cmake/modules/CMakeLists.txt @@ -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 diff --git a/cmake/modules/TableGen.cmake b/cmake/modules/TableGen.cmake index b1e15492471..35f1422cc53 100644 --- a/cmake/modules/TableGen.cmake +++ b/cmake/modules/TableGen.cmake @@ -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() -- 2.34.1