[PATCH] D32668: CMake: Split static library exports into their own export file

Tom Stellard via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 28 19:18:07 PDT 2017


tstellar created this revision.

This is to better support distros which split the static libraries into
their own package.

The current problem is that any project the includes LLVMConfig.cmake
will fail to configure unless the static libraries are installed.  This
is because LLVMConfig.cmake includes LLVMExports.cmake, which throws an
error if it can't find files linked to one of the exported targets.

This patch resolves the problem by putting the static library targets
into their own export file, LLVMStaticExports.cmake.  This file
is optionally included by LLVMConfig.cmake, so distros can put this
new file in their static library package to make  LLVMConfig.cmake
no longer depend on these libraries when they are not installed.


https://reviews.llvm.org/D32668

Files:
  cmake/modules/AddLLVM.cmake
  cmake/modules/CMakeLists.txt
  cmake/modules/LLVMConfig.cmake.in


Index: cmake/modules/LLVMConfig.cmake.in
===================================================================
--- cmake/modules/LLVMConfig.cmake.in
+++ cmake/modules/LLVMConfig.cmake.in
@@ -77,6 +77,8 @@
   set(LLVM_EXPORTED_TARGETS "@LLVM_CONFIG_EXPORTS@")
   include("@LLVM_CONFIG_EXPORTS_FILE@")
   @llvm_config_include_buildtree_only_exports@
+
+  include("@LLVM_CONFIG_STATIC_EXPORTS_FILE@" OPTIONAL)
 endif()
 
 set_property(GLOBAL PROPERTY LLVM_TARGETS_CONFIGURED On)
Index: cmake/modules/CMakeLists.txt
===================================================================
--- cmake/modules/CMakeLists.txt
+++ cmake/modules/CMakeLists.txt
@@ -91,6 +91,7 @@
 set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/bin")
 set(LLVM_CONFIG_EXPORTS_FILE "\${LLVM_CMAKE_DIR}/LLVMExports.cmake")
 set(LLVM_CONFIG_EXPORTS "${LLVM_EXPORTS}")
+set(LLVM_CONFIG_STATIC_EXPORTS_FILE "\${LLVM_CMAKE_DIR}/LLVMStaticExports.cmake")
 configure_file(
   LLVMConfig.cmake.in
   ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLVMConfig.cmake
@@ -107,6 +108,8 @@
   if(llvm_has_exports)
     install(EXPORT LLVMExports DESTINATION ${LLVM_INSTALL_PACKAGE_DIR}
             COMPONENT cmake-exports)
+    install(EXPORT LLVMStaticExports DESTINATION ${LLVM_INSTALL_PACKAGE_DIR}
+            COMPONENT cmake-exports)
   endif()
 
   install(FILES
Index: cmake/modules/AddLLVM.cmake
===================================================================
--- cmake/modules/AddLLVM.cmake
+++ cmake/modules/AddLLVM.cmake
@@ -588,7 +588,11 @@
 
       if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
           NOT LLVM_DISTRIBUTION_COMPONENTS)
-        set(export_to_llvmexports EXPORT LLVMExports)
+        if (ARG_SHARED)
+          set(export_to_llvmexports EXPORT LLVMExports)
+        else()
+          set(export_to_llvmexports EXPORT LLVMStaticExports)
+        endif()
         set_property(GLOBAL PROPERTY LLVM_HAS_EXPORTS True)
       endif()
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32668.97181.patch
Type: text/x-patch
Size: 1927 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170429/4e249916/attachment.bin>


More information about the llvm-commits mailing list