87 lines
3.3 KiB
Diff
87 lines
3.3 KiB
Diff
From 80d3393d3e324dd8bef7de1b9c6db3010585f3e8 Mon Sep 17 00:00:00 2001
|
|
From: Tom Stellard <tstellar@redhat.com>
|
|
Date: Sat, 29 Apr 2017 02:03:23 +0000
|
|
Subject: [PATCH] CMake: Split static library exports into their own export
|
|
file
|
|
|
|
Summary:
|
|
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.
|
|
|
|
Reviewers: beanz, mgorny, chapuni
|
|
|
|
Subscribers: llvm-commits
|
|
|
|
Differential Revision: https://reviews.llvm.org/D32668
|
|
---
|
|
cmake/modules/AddLLVM.cmake | 6 +++++-
|
|
cmake/modules/CMakeLists.txt | 3 +++
|
|
cmake/modules/LLVMConfig.cmake.in | 2 ++
|
|
3 files changed, 10 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
|
|
index 1c92265..e1ad9b9 100644
|
|
--- a/cmake/modules/AddLLVM.cmake
|
|
+++ b/cmake/modules/AddLLVM.cmake
|
|
@@ -603,7 +603,11 @@ macro(add_llvm_library name)
|
|
|
|
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()
|
|
|
|
diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt
|
|
index ac4b0b7..f77c905 100644
|
|
--- a/cmake/modules/CMakeLists.txt
|
|
+++ b/cmake/modules/CMakeLists.txt
|
|
@@ -91,6 +91,7 @@ set(LLVM_CONFIG_BINARY_DIR "\${LLVM_INSTALL_PREFIX}")
|
|
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 (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
|
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
|
|
diff --git a/cmake/modules/LLVMConfig.cmake.in b/cmake/modules/LLVMConfig.cmake.in
|
|
index 7a8eb36..1fa0028 100644
|
|
--- a/cmake/modules/LLVMConfig.cmake.in
|
|
+++ b/cmake/modules/LLVMConfig.cmake.in
|
|
@@ -77,6 +77,8 @@ if(NOT TARGET LLVMSupport)
|
|
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)
|
|
--
|
|
1.8.3.1
|
|
|