Load exported lib and exe targets from LLVMConfig
authorNAKAMURA Takumi <geek4civic@gmail.com>
Sun, 9 Feb 2014 16:36:28 +0000 (16:36 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Sun, 9 Feb 2014 16:36:28 +0000 (16:36 +0000)
Teach each package configuration file to load the LLVMExports file for
its corresponding tree.  This will allow application CMake code to use
logical library and executable target names from LLVM as if they were in
our own build process (e.g. LLVMSupport).  CMake will have enough
information to propagate LLVM library link dependencies automatically
while configuring applications.

Contributed by Brad King.

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

cmake/modules/CMakeLists.txt
cmake/modules/LLVMConfig.cmake.in

index 8a42548..6038cf3 100644 (file)
@@ -31,6 +31,7 @@ set(LLVM_CONFIG_LIBRARY_DIRS
   "${LLVM_LIBRARY_DIR}"
   )
 set(LLVM_CONFIG_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+set(LLVM_CONFIG_EXPORTS_FILE "${llvm_cmake_builddir}/LLVMExports.cmake")
 configure_file(
   LLVMConfig.cmake.in
   ${llvm_cmake_builddir}/LLVMConfig.cmake
@@ -60,6 +61,7 @@ endforeach(p)
 set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/include")
 set(LLVM_CONFIG_LIBRARY_DIRS "\${LLVM_INSTALL_PREFIX}/lib")
 set(LLVM_CONFIG_CMAKE_DIR "\${LLVM_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
+set(LLVM_CONFIG_EXPORTS_FILE "\${LLVM_CMAKE_DIR}/LLVMExports.cmake")
 configure_file(
   LLVMConfig.cmake.in
   ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLVMConfig.cmake
index 4687838..c1b6450 100644 (file)
@@ -43,4 +43,8 @@ set(LLVM_LIBRARY_DIRS "@LLVM_CONFIG_LIBRARY_DIRS@")
 set(LLVM_DEFINITIONS "-D__STDC_LIMIT_MACROS" "-D__STDC_CONSTANT_MACROS")
 set(LLVM_CMAKE_DIR "@LLVM_CONFIG_CMAKE_DIR@")
 
+if(NOT TARGET LLVMSupport)
+  include("@LLVM_CONFIG_EXPORTS_FILE@")
+endif()
+
 include(${LLVM_CMAKE_DIR}/LLVM-Config.cmake)