diff options
author | Pierre Wendling <pierre.wendling.4@gmail.com> | 2023-08-06 15:07:31 -0400 |
---|---|---|
committer | Pierre Wendling <pierre.wendling.4@gmail.com> | 2023-08-19 12:16:15 -0400 |
commit | a89cd65980153ef60b42cb26d3bef949751f87f1 (patch) | |
tree | 15d4693562c401d0bbc0b3812d983ca1ac0391cb /CMakeLists.txt | |
parent | 5432e22b25026fb50b00ab5dcf894e18daa8bcb6 (diff) | |
download | portable-a89cd65980153ef60b42cb26d3bef949751f87f1.tar.gz portable-a89cd65980153ef60b42cb26d3bef949751f87f1.tar.bz2 portable-a89cd65980153ef60b42cb26d3bef949751f87f1.zip |
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.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 991f60c..8e26e47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -39,6 +39,7 @@ option(ENABLE_ASM "Enable assembly" ON) | |||
39 | option(ENABLE_EXTRATESTS "Enable extra tests that may be unreliable on some platforms" OFF) | 39 | option(ENABLE_EXTRATESTS "Enable extra tests that may be unreliable on some platforms" OFF) |
40 | option(ENABLE_NC "Enable installing TLS-enabled nc(1)" OFF) | 40 | option(ENABLE_NC "Enable installing TLS-enabled nc(1)" OFF) |
41 | set(OPENSSLDIR ${OPENSSLDIR} CACHE PATH "Set the default openssl directory" FORCE) | 41 | set(OPENSSLDIR ${OPENSSLDIR} CACHE PATH "Set the default openssl directory" FORCE) |
42 | set(LIBRESSL_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake" CACHE STRING "Installation directory for the CMake targets") | ||
42 | 43 | ||
43 | option(USE_STATIC_MSVC_RUNTIMES "Use /MT instead of /MD in MSVC" OFF) | 44 | option(USE_STATIC_MSVC_RUNTIMES "Use /MT instead of /MD in MSVC" OFF) |
44 | if(USE_STATIC_MSVC_RUNTIMES) | 45 | if(USE_STATIC_MSVC_RUNTIMES) |
@@ -439,6 +440,38 @@ if (BUILD_APPLE_XCFRAMEWORK) | |||
439 | endif(ENABLE_LIBRESSL_INSTALL) | 440 | endif(ENABLE_LIBRESSL_INSTALL) |
440 | endif(BUILD_APPLE_XCFRAMEWORK) | 441 | endif(BUILD_APPLE_XCFRAMEWORK) |
441 | 442 | ||
443 | file(STRINGS "VERSION" VERSION LIMIT_COUNT 1) | ||
444 | include(CMakePackageConfigHelpers) | ||
445 | write_basic_package_version_file( | ||
446 | "LibreSSLConfigVersion.cmake" | ||
447 | VERSION "${VERSION}" | ||
448 | COMPATIBILITY SameMajorVersion | ||
449 | ) | ||
450 | |||
451 | set(INCLUDE_DIRECTORY "${CMAKE_BINARY_DIR}/include") | ||
452 | configure_package_config_file( | ||
453 | "${CMAKE_CURRENT_LIST_DIR}/LibreSSLConfig.cmake.in" | ||
454 | "${CMAKE_CURRENT_BINARY_DIR}/LibreSSLConfig.cmake" | ||
455 | PATH_VARS INCLUDE_DIRECTORY | ||
456 | INSTALL_DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" | ||
457 | INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}" | ||
458 | ) | ||
459 | |||
460 | if(ENABLE_LIBRESSL_INSTALL) | ||
461 | set(INCLUDE_DIRECTORY "${CMAKE_INSTALL_INCLUDEDIR}") | ||
462 | configure_package_config_file( | ||
463 | "${CMAKE_CURRENT_LIST_DIR}/LibreSSLConfig.cmake.in" | ||
464 | "${CMAKE_CURRENT_BINARY_DIR}/install-config/LibreSSLConfig.cmake" | ||
465 | PATH_VARS INCLUDE_DIRECTORY | ||
466 | INSTALL_DESTINATION "${LIBRESSL_INSTALL_CMAKEDIR}/LibreSSL" | ||
467 | ) | ||
468 | install(FILES | ||
469 | "${CMAKE_BINARY_DIR}/install-config/LibreSSLConfig.cmake" | ||
470 | "${CMAKE_BINARY_DIR}/LibreSSLConfigVersion.cmake" | ||
471 | DESTINATION "${LIBRESSL_INSTALL_CMAKEDIR}/LibreSSL" | ||
472 | ) | ||
473 | endif() | ||
474 | |||
442 | if(ENABLE_LIBRESSL_INSTALL) | 475 | if(ENABLE_LIBRESSL_INSTALL) |
443 | if(NOT MSVC) | 476 | if(NOT MSVC) |
444 | # Create pkgconfig files. | 477 | # Create pkgconfig files. |
@@ -449,7 +482,6 @@ if(ENABLE_LIBRESSL_INSTALL) | |||
449 | if(PLATFORM_LIBS) | 482 | if(PLATFORM_LIBS) |
450 | string(REGEX REPLACE ";" " -l" PLATFORM_LDADD ";${PLATFORM_LIBS}") | 483 | string(REGEX REPLACE ";" " -l" PLATFORM_LDADD ";${PLATFORM_LIBS}") |
451 | endif() | 484 | endif() |
452 | file(STRINGS "VERSION" VERSION LIMIT_COUNT 1) | ||
453 | file(GLOB OPENSSL_PKGCONFIGS "*.pc.in") | 485 | file(GLOB OPENSSL_PKGCONFIGS "*.pc.in") |
454 | foreach(file ${OPENSSL_PKGCONFIGS}) | 486 | foreach(file ${OPENSSL_PKGCONFIGS}) |
455 | get_filename_component(filename ${file} NAME) | 487 | get_filename_component(filename ${file} NAME) |