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

@@ -58,9 +58,29 @@ if (WIN32)
endif()
set_target_properties(tls PROPERTIES
OUTPUT_NAME tls${TLS_POSTFIX}
ARCHIVE_OUTPUT_NAME tls${TLS_POSTFIX})
set_target_properties(tls PROPERTIES VERSION ${TLS_VERSION}
SOVERSION ${TLS_MAJOR_VERSION})
ARCHIVE_OUTPUT_NAME tls${TLS_POSTFIX}
EXPORT_NAME TLS
VERSION ${TLS_VERSION}
SOVERSION ${TLS_MAJOR_VERSION}
)
target_include_directories(
tls
PUBLIC
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
install(
TARGETS tls
EXPORT TLS-target
)
export(
EXPORT TLS-target
FILE "${LibreSSL_BINARY_DIR}/LibreSSL-TLS.cmake"
NAMESPACE LibreSSL::
)
if(ENABLE_LIBRESSL_INSTALL)
install(
@@ -69,6 +89,12 @@ if(ENABLE_LIBRESSL_INSTALL)
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(
EXPORT TLS-target
FILE "LibreSSL-TLS.cmake"
NAMESPACE LibreSSL::
DESTINATION "${LIBRESSL_INSTALL_CMAKEDIR}/LibreSSL"
)
endif(ENABLE_LIBRESSL_INSTALL)
# build static library for regression test