CMake: Export and install library targets.

The configs can be consumed by setting LibreSSL_DIR to the build
directory, or after installation using CMAKE_PREFIX_PATH/LibreSSL_DIR.

For compatibility, the EXPORT_NAME of targets and the LIBRESSL_*
variables are set to match the names used in FindLibreSSL.
This commit is contained in:
Pierre Wendling
2023-08-06 15:07:31 -04:00
parent 5432e22b25
commit a89cd65980
6 changed files with 154 additions and 11 deletions

View File

@@ -91,9 +91,29 @@ if (WIN32)
endif()
set_target_properties(ssl PROPERTIES
OUTPUT_NAME ssl${SSL_POSTFIX}
ARCHIVE_OUTPUT_NAME ssl${SSL_POSTFIX})
set_target_properties(ssl PROPERTIES VERSION ${SSL_VERSION}
SOVERSION ${SSL_MAJOR_VERSION})
ARCHIVE_OUTPUT_NAME ssl${SSL_POSTFIX}
EXPORT_NAME SSL
VERSION ${SSL_VERSION}
SOVERSION ${SSL_MAJOR_VERSION}
)
target_include_directories(
ssl
PUBLIC
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
install(
TARGETS ssl
EXPORT SSL-target
)
export(
EXPORT SSL-target
FILE "${LibreSSL_BINARY_DIR}/LibreSSL-SSL.cmake"
NAMESPACE LibreSSL::
)
if(ENABLE_LIBRESSL_INSTALL)
install(
@@ -102,6 +122,12 @@ if(ENABLE_LIBRESSL_INSTALL)
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(
EXPORT SSL-target
FILE "LibreSSL-SSL.cmake"
NAMESPACE LibreSSL::
DESTINATION "${LIBRESSL_INSTALL_CMAKEDIR}/LibreSSL"
)
endif(ENABLE_LIBRESSL_INSTALL)
# build static library for regression test