diff options
author | Petr Hosek <phosek@chromium.org> | 2018-07-24 23:27:51 +0000 |
---|---|---|
committer | Petr Hosek <phosek@chromium.org> | 2018-07-24 23:27:51 +0000 |
commit | 46c02f4de94e93bcf87746794bd2c902a2f5b622 (patch) | |
tree | c16079d07aa28c6c5edde11688aa9048c6a89e90 /libcxxabi | |
parent | 8b2a6d8ca5360f47986b21ed15bb579b8506435f (diff) |
[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
Diffstat (limited to 'libcxxabi')
-rw-r--r-- | libcxxabi/CMakeLists.txt | 7 | ||||
-rw-r--r-- | libcxxabi/src/CMakeLists.txt | 16 |
2 files changed, 17 insertions, 6 deletions
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 ) |