Fix build for older CMake versions. CMake versions newer than ~3.1x automatically determine the subdirectory under CMAKE_INSTALL_PREFIX using the type of the installed target. Older versions need this to be manually computed using the GNUInstallDirs library. Since we override the CMAKE_INSTALL_PREFIX default, this just controls the internal layout of the install/ directory generated underneath the boringssl checkout. Bug: 488 Change-Id: I97b02006301e463bb0cfd54acb2b27656484cc85 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/52345 Reviewed-by: Adam Langley <agl@google.com> Reviewed-by: David Benjamin <davidben@google.com> Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt index dad27f8..202681d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -20,6 +20,8 @@ enable_language(C) enable_language(CXX) +include(GNUInstallDirs) + # 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. @@ -563,7 +565,7 @@ -DLIBCXX_BUILDING_LIBCXXABI ) target_link_libraries(libcxx libcxxabi) - install(TARGETS libcxx EXPORT OpenSSLTargets) + install(TARGETS libcxx EXPORT OpenSSLTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() # Add minimal googletest targets. The provided one has many side-effects, and @@ -665,7 +667,7 @@ DEPENDS all_tests bssl_shim handshaker fips_specific_tests_if_any USES_TERMINAL) -install(DIRECTORY include/ TYPE INCLUDE) +install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(EXPORT OpenSSLTargets FILE OpenSSLTargets.cmake
diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt index 91ecb3e..6701158 100644 --- a/crypto/CMakeLists.txt +++ b/crypto/CMakeLists.txt
@@ -441,7 +441,7 @@ $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include> ) -install(TARGETS crypto EXPORT OpenSSLTargets) +install(TARGETS crypto EXPORT OpenSSLTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}) set_property(TARGET crypto PROPERTY EXPORT_NAME Crypto) if(FIPS_SHARED)
diff --git a/ssl/CMakeLists.txt b/ssl/CMakeLists.txt index ed02bb5..67a72ae 100644 --- a/ssl/CMakeLists.txt +++ b/ssl/CMakeLists.txt
@@ -45,7 +45,7 @@ $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include> ) -install(TARGETS ssl EXPORT OpenSSLTargets) +install(TARGETS ssl EXPORT OpenSSLTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}) set_property(TARGET ssl PROPERTY EXPORT_NAME SSL) add_dependencies(ssl global_target)
diff --git a/tool/CMakeLists.txt b/tool/CMakeLists.txt index e695f56..f98e96e 100644 --- a/tool/CMakeLists.txt +++ b/tool/CMakeLists.txt
@@ -21,7 +21,7 @@ tool.cc transport_common.cc ) -install(TARGETS bssl) +install(TARGETS bssl DESTINATION ${CMAKE_INSTALL_BINDIR}) add_dependencies(bssl global_target)