diff options
author | David Benjamin <davidben@google.com> | 2023-01-29 18:59:45 -0500 |
---|---|---|
committer | Boringssl LUCI CQ <boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-02-14 20:42:03 +0000 |
commit | e5f7266884922dd66fb07a92570102ff2f5d912f (patch) | |
tree | 73ba6d4b3b325e4ef0e5584826cd86f7f0193c40 /CMakeLists.txt | |
parent | 0e68520eb27b1f37038e9d0772cfee1d015b50c3 (diff) | |
download | boringssl-e5f7266884922dd66fb07a92570102ff2f5d912f.zip boringssl-e5f7266884922dd66fb07a92570102ff2f5d912f.tar.gz boringssl-e5f7266884922dd66fb07a92570102ff2f5d912f.tar.bz2 |
Don't include custom builds of libc++ in CMake installs
Also stick the very verbose default install directory in a variable so
we don't have to repeat it everywhere.
Change-Id: I1a6a85c4d42d3a6e766e52b2d0ecd8e81c6ed4e3
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/56607
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fa818c..ced650d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,24 @@ enable_language(CXX) include(GNUInstallDirs) +# CMake versions before 3.14 do not have default destination values. Executable +# and library targets that use a default destination should include this +# variable. +if(CMAKE_VERSION VERSION_LESS "3.14") + set(INSTALL_DESTINATION_DEFAULT + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() + +# Wrap the CMake install function so we can disable it. +set(INSTALL_ENABLED 1) +function(install_if_enabled) + if(INSTALL_ENABLED) + install(${ARGV}) + endif() +endfunction() + # This is a dummy target which all other targets depend on (manually - see other # CMakeLists.txt files). This gives us a hook to add any targets which need to # run before all other targets. @@ -400,6 +418,12 @@ if(USE_CUSTOM_LIBCXX) message(FATAL_ERROR "USE_CUSTOM_LIBCXX only supported with Clang") endif() + # CMake does not allow installing a library without installing dependencies. + # If we installed libcrypto, we'd have to install our custom libc++, which + # does not make sense. As this is a test-only configuration, disable + # installing. + set(INSTALL_ENABLED 0) + # CMAKE_CXX_FLAGS ends up in the linker flags as well, so use # add_compile_options. There does not appear to be a way to set # language-specific compile-only flags. @@ -433,7 +457,6 @@ if(USE_CUSTOM_LIBCXX) libcxxabi PRIVATE -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS ) - install(TARGETS libcxxabi EXPORT OpenSSLTargets) add_library(libcxx ${LIBCXX_SOURCES}) if(ASAN OR MSAN OR TSAN) @@ -458,7 +481,6 @@ if(USE_CUSTOM_LIBCXX) # libc++abi depends on libc++ internal headers. set_property(TARGET libcxx libcxxabi APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/util/bot/libcxx/src") target_link_libraries(libcxx libcxxabi) - install(TARGETS libcxx EXPORT OpenSSLTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() # Add minimal googletest targets. The provided one has many side-effects, and @@ -562,11 +584,11 @@ add_custom_target( DEPENDS all_tests bssl_shim handshaker fips_specific_tests_if_any USES_TERMINAL) -install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install_if_enabled(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -install(EXPORT OpenSSLTargets +install_if_enabled(EXPORT OpenSSLTargets FILE OpenSSLTargets.cmake NAMESPACE OpenSSL:: DESTINATION lib/cmake/OpenSSL ) -install(FILES cmake/OpenSSLConfig.cmake DESTINATION lib/cmake/OpenSSL) +install_if_enabled(FILES cmake/OpenSSLConfig.cmake DESTINATION lib/cmake/OpenSSL) |