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 /libunwind | |
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 'libunwind')
-rw-r--r-- | libunwind/CMakeLists.txt | 6 | ||||
-rw-r--r-- | libunwind/src/CMakeLists.txt | 16 |
2 files changed, 16 insertions, 6 deletions
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() |