summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Hosek <phosek@chromium.org>2018-07-24 23:27:51 +0000
committerPetr Hosek <phosek@chromium.org>2018-07-24 23:27:51 +0000
commit4a1e14ea78e6f3179b9442b714ec6e79e6b661b1 (patch)
tree34400b847af5d79c45c928bbd36dfb0f05ecb55e
parent5c0a822177e7ca779d2d69f19154bbf055fdbe89 (diff)
downloadbcm5719-llvm-4a1e14ea78e6f3179b9442b714ec6e79e6b661b1.tar.gz
bcm5719-llvm-4a1e14ea78e6f3179b9442b714ec6e79e6b661b1.zip
[CMake] Option to control whether shared/static library is installed
Currently it's only possible to control whether shared or static library build of libc++, libc++abi and libunwind is enabled or disabled and whether to install everything we've built or not. However, it'd be useful to have more fine grained control, e.g. when static libraries are merged together into libc++.a we don't need to install libc++abi.a and libunwind.a. This change adds this option. Differential Revision: https://reviews.llvm.org/D49573 llvm-svn: 337867
-rw-r--r--libcxx/CMakeLists.txt6
-rw-r--r--libcxx/lib/CMakeLists.txt17
-rw-r--r--libcxxabi/CMakeLists.txt7
-rw-r--r--libcxxabi/src/CMakeLists.txt16
-rw-r--r--libunwind/CMakeLists.txt6
-rw-r--r--libunwind/src/CMakeLists.txt16
6 files changed, 49 insertions, 19 deletions
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 549be42e2cb..29357b08843 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -93,6 +93,12 @@ set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
"Define suffix of library directory name (32/64)")
option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON)
option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON)
+cmake_dependent_option(LIBCXX_INSTALL_STATIC_LIBRARY
+ "Install the static libc++ library." ON
+ "LIBCXX_ENABLE_STATIC;LIBCXX_INSTALL_LIBRARY" OFF)
+cmake_dependent_option(LIBCXX_INSTALL_SHARED_LIBRARY
+ "Install the shared libc++ library." ON
+ "LIBCXX_ENABLE_SHARED;LIBCXX_INSTALL_LIBRARY" OFF)
option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
cmake_dependent_option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY
"Install libc++experimental.a" ON
diff --git a/libcxx/lib/CMakeLists.txt b/libcxx/lib/CMakeLists.txt
index 5ac691a75ed..5cdf1b868f7 100644
--- a/libcxx/lib/CMakeLists.txt
+++ b/libcxx/lib/CMakeLists.txt
@@ -220,8 +220,6 @@ set_target_properties(cxx_objects
COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
)
-set(LIBCXX_TARGETS)
-
# Build the shared library.
if (LIBCXX_ENABLE_SHARED)
add_library(cxx_shared SHARED $<TARGET_OBJECTS:cxx_objects>)
@@ -236,7 +234,10 @@ if (LIBCXX_ENABLE_SHARED)
VERSION "${LIBCXX_ABI_VERSION}.0"
SOVERSION "${LIBCXX_ABI_VERSION}"
)
- list(APPEND LIBCXX_TARGETS "cxx_shared")
+ list(APPEND LIBCXX_BUILD_TARGETS "cxx_shared")
+ if (LIBCXX_INSTALL_SHARED_LIBRARY)
+ list(APPEND LIBCXX_INSTALL_TARGETS "cxx_shared")
+ endif()
if(WIN32 AND NOT MINGW AND NOT "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
# Since we most likely do not have a mt.exe replacement, disable the
# manifest bundling. This allows a normal cmake invocation to pass which
@@ -256,8 +257,10 @@ if (LIBCXX_ENABLE_STATIC)
LINK_FLAGS "${LIBCXX_LINK_FLAGS}"
OUTPUT_NAME "c++"
)
-
- list(APPEND LIBCXX_TARGETS "cxx_static")
+ list(APPEND LIBCXX_BUILD_TARGETS "cxx_static")
+ if (LIBCXX_INSTALL_STATIC_LIBRARY)
+ list(APPEND LIBCXX_INSTALL_TARGETS "cxx_static")
+ endif()
# Attempt to merge the libc++.a archive and the ABI library archive into one.
if (LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY)
set(MERGE_ARCHIVES_SEARCH_PATHS "")
@@ -286,7 +289,7 @@ if (LIBCXX_ENABLE_STATIC)
endif()
# Add a meta-target for both libraries.
-add_custom_target(cxx DEPENDS cxx-headers ${LIBCXX_TARGETS})
+add_custom_target(cxx DEPENDS cxx-headers ${LIBCXX_BUILD_TARGETS})
if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
file(GLOB LIBCXX_EXPERIMENTAL_SOURCES ../src/experimental/*.cpp)
@@ -362,7 +365,7 @@ if (LIBCXX_INSTALL_LIBRARY)
if (LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY)
set(experimental_lib cxx_experimental)
endif()
- install(TARGETS ${LIBCXX_TARGETS} ${experimental_lib}
+ install(TARGETS ${LIBCXX_INSTALL_TARGETS} ${experimental_lib}
LIBRARY DESTINATION ${LIBCXX_INSTALL_PREFIX}lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT cxx
ARCHIVE DESTINATION ${LIBCXX_INSTALL_PREFIX}lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT cxx
)
diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index adfe8c6f762..764627a87dc 100644
--- a/libcxxabi/CMakeLists.txt
+++ b/libcxxabi/CMakeLists.txt
@@ -75,6 +75,13 @@ set(LIBCXXABI_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.")
set(LIBCXXABI_SYSROOT "" CACHE PATH "Sysroot for cross compiling.")
set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE PATH "The path to libc++ library.")
+cmake_dependent_option(LIBCXXABI_INSTALL_STATIC_LIBRARY
+ "Install the static libc++abi library." ON
+ "LIBCXXABI_ENABLE_STATIC;LIBCXXABI_INSTALL_LIBRARY" OFF)
+cmake_dependent_option(LIBCXXABI_INSTALL_SHARED_LIBRARY
+ "Install the shared libc++abi library." ON
+ "LIBCXXABI_ENABLE_SHARED;LIBCXXABI_INSTALL_LIBRARY" OFF)
+
# Default to building a shared library so that the default options still test
# the libc++abi that is being built. There are two problems with testing a
# static libc++abi. In the case of a standalone build, the tests will link the
diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index 98278795d70..776c5129433 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -129,8 +129,6 @@ set_target_properties(cxxabi_objects
POSITION_INDEPENDENT_CODE
ON)
-set(LIBCXXABI_TARGETS)
-
# Build the shared library.
if (LIBCXXABI_ENABLE_SHARED)
add_library(cxxabi_shared SHARED $<TARGET_OBJECTS:cxxabi_objects>)
@@ -156,7 +154,10 @@ if (LIBCXXABI_ENABLE_SHARED)
"1"
VERSION
"1.0")
- list(APPEND LIBCXXABI_TARGETS "cxxabi_shared")
+ list(APPEND LIBCXXABI_BUILD_TARGETS "cxxabi_shared")
+ if (LIBCXXABI_INSTALL_SHARED_LIBRARY)
+ list(APPEND LIBCXXABI_INSTALL_TARGETS "cxxabi_shared")
+ endif()
endif()
# Build the static library.
@@ -183,14 +184,17 @@ if (LIBCXXABI_ENABLE_STATIC)
"c++abi"
POSITION_INDEPENDENT_CODE
ON)
- list(APPEND LIBCXXABI_TARGETS "cxxabi_static")
+ list(APPEND LIBCXXABI_BUILD_TARGETS "cxxabi_static")
+ if (LIBCXXABI_INSTALL_STATIC_LIBRARY)
+ list(APPEND LIBCXXABI_INSTALL_TARGETS "cxxabi_static")
+ endif()
endif()
# Add a meta-target for both libraries.
-add_custom_target(cxxabi DEPENDS ${LIBCXXABI_TARGETS})
+add_custom_target(cxxabi DEPENDS ${LIBCXXABI_BUILD_TARGETS})
if (LIBCXXABI_INSTALL_LIBRARY)
- install(TARGETS ${LIBCXXABI_TARGETS}
+ install(TARGETS ${LIBCXXABI_INSTALL_TARGETS}
LIBRARY DESTINATION ${LIBCXXABI_INSTALL_PREFIX}lib${LIBCXXABI_LIBDIR_SUFFIX} COMPONENT cxxabi
ARCHIVE DESTINATION ${LIBCXXABI_INSTALL_PREFIX}lib${LIBCXXABI_LIBDIR_SUFFIX} COMPONENT cxxabi
)
diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index 704402decac..44265b089b1 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -137,6 +137,12 @@ option(LIBUNWIND_INCLUDE_DOCS "Build the libunwind documentation." ${LLVM_INCLUD
set(LIBUNWIND_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
"Define suffix of library directory name (32/64)")
option(LIBUNWIND_INSTALL_LIBRARY "Install the libunwind library." ON)
+cmake_dependent_option(LIBUNWIND_INSTALL_STATIC_LIBRARY
+ "Install the static libunwind library." ON
+ "LIBUNWIND_ENABLE_STATIC;LIBUNWIND_INSTALL_LIBRARY" OFF)
+cmake_dependent_option(LIBUNWIND_INSTALL_SHARED_LIBRARY
+ "Install the shared libunwind library." ON
+ "LIBUNWIND_ENABLE_SHARED;LIBUNWIND_INSTALL_LIBRARY" OFF)
set(LIBUNWIND_TARGET_TRIPLE "" CACHE STRING "Target triple for cross compiling.")
set(LIBUNWIND_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.")
set(LIBUNWIND_SYSROOT "" CACHE PATH "Sysroot for cross compiling.")
diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index 5c7a4c7309f..937159e2cb8 100644
--- a/libunwind/src/CMakeLists.txt
+++ b/libunwind/src/CMakeLists.txt
@@ -103,8 +103,6 @@ set_target_properties(unwind_objects
COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}"
POSITION_INDEPENDENT_CODE ON)
-set(LIBUNWIND_TARGETS)
-
# Build the shared library.
if (LIBUNWIND_ENABLE_SHARED)
add_library(unwind_shared SHARED $<TARGET_OBJECTS:unwind_objects>)
@@ -118,7 +116,10 @@ if (LIBUNWIND_ENABLE_SHARED)
OUTPUT_NAME "unwind"
VERSION "1.0"
SOVERSION "1")
- list(APPEND LIBUNWIND_TARGETS "unwind_shared")
+ list(APPEND LIBUNWIND_BUILD_TARGETS "unwind_shared")
+ if (LIBUNWIND_INSTALL_SHARED_LIBRARY)
+ list(APPEND LIBUNWIND_INSTALL_TARGETS "unwind_shared")
+ endif()
endif()
# Build the static library.
@@ -129,14 +130,17 @@ if (LIBUNWIND_ENABLE_STATIC)
PROPERTIES
LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}"
OUTPUT_NAME "unwind")
- list(APPEND LIBUNWIND_TARGETS "unwind_static")
+ list(APPEND LIBUNWIND_BUILD_TARGETS "unwind_static")
+ if (LIBUNWIND_INSTALL_STATIC_LIBRARY)
+ list(APPEND LIBUNWIND_INSTALL_TARGETS "unwind_static")
+ endif()
endif()
# Add a meta-target for both libraries.
-add_custom_target(unwind DEPENDS ${LIBUNWIND_TARGETS})
+add_custom_target(unwind DEPENDS ${LIBUNWIND_BUILD_TARGETS})
if (LIBUNWIND_INSTALL_LIBRARY)
- install(TARGETS ${LIBUNWIND_TARGETS}
+ install(TARGETS ${LIBUNWIND_INSTALL_TARGETS}
LIBRARY DESTINATION ${LIBUNWIND_INSTALL_PREFIX}lib${LIBUNWIND_LIBDIR_SUFFIX} COMPONENT unwind
ARCHIVE DESTINATION ${LIBUNWIND_INSTALL_PREFIX}lib${LIBUNWIND_LIBDIR_SUFFIX} COMPONENT unwind)
endif()
OpenPOWER on IntegriCloud