[libressl,vcpkg-ci-libressl] Test and fix exported config and wrapper (#41083)

This commit is contained in:
Kai Pastor 2024-10-09 21:42:47 +02:00 committed by GitHub
parent 4014351d50
commit 64578ff08c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 171 additions and 25 deletions

View File

@ -0,0 +1,13 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2172a48..e7458fd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -529,7 +529,7 @@ if(ENABLE_LIBRESSL_INSTALL)
endif()
if(ENABLE_LIBRESSL_INSTALL)
- if(NOT MSVC)
+ if(1)
# Create pkgconfig files.
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix \${prefix})

View File

@ -15,6 +15,7 @@ vcpkg_extract_source_archive(
ARCHIVE "${LIBRESSL_SOURCE_ARCHIVE}"
PATCHES
0002-suppress-msvc-warnings.patch
pkgconfig.diff
)
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
@ -26,35 +27,30 @@ vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
-DLIBRESSL_INSTALL_CMAKEDIR=share/${PORT}
-DLIBRESSL_TESTS=OFF
OPTIONS_DEBUG
-DLIBRESSL_APPS=OFF
)
vcpkg_cmake_install()
vcpkg_copy_pdbs()
vcpkg_fixup_pkgconfig()
vcpkg_cmake_config_fixup()
# libressl as openssl replacement
configure_file("${CURRENT_PORT_DIR}/vcpkg-cmake-wrapper.cmake.in" "${CURRENT_PACKAGES_DIR}/share/openssl/vcpkg-cmake-wrapper.cmake" @ONLY)
if("tools" IN_LIST FEATURES)
vcpkg_copy_tools(TOOL_NAMES ocspcheck openssl DESTINATION "${CURRENT_PACKAGES_DIR}/tools/openssl" AUTO_CLEAN)
endif()
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/bin"
"${CURRENT_PACKAGES_DIR}/debug/bin"
)
endif()
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/etc/ssl/certs"
"${CURRENT_PACKAGES_DIR}/debug/etc/ssl/certs"
"${CURRENT_PACKAGES_DIR}/share/man"
"${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/debug/share"
"${CURRENT_PACKAGES_DIR}/share/man"
)
vcpkg_copy_pdbs()
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING")
vcpkg_fixup_pkgconfig()
vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/LibreSSL")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")

View File

@ -0,0 +1,75 @@
cmake_policy(PUSH)
cmake_policy(SET CMP0012 NEW)
cmake_policy(SET CMP0054 NEW)
cmake_policy(SET CMP0057 NEW)
# opensslv.h: OPENSSL_VERSION_NUMBER 0x20000000L, "These will never change"
set(OPENSSL_VERSION_MAJOR 2)
set(OPENSSL_VERSION_MINOR 0)
set(OPENSSL_VERSION_FIX 0)
if(OPENSSL_USE_STATIC_LIBS)
if("@VCPKG_LIBRARY_LINKAGE@" STREQUAL "dynamic")
message(WARNING "OPENSSL_USE_STATIC_LIBS is set, but vcpkg port openssl was built with dynamic linkage")
endif()
set(OPENSSL_USE_STATIC_LIBS_BAK "${OPENSSL_USE_STATIC_LIBS}")
set(OPENSSL_USE_STATIC_LIBS FALSE)
endif()
if(DEFINED OPENSSL_ROOT_DIR)
set(OPENSSL_ROOT_DIR_BAK "${OPENSSL_ROOT_DIR}")
endif()
get_filename_component(OPENSSL_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}" DIRECTORY)
get_filename_component(OPENSSL_ROOT_DIR "${OPENSSL_ROOT_DIR}" DIRECTORY)
find_path(OPENSSL_INCLUDE_DIR NAMES openssl/ssl.h PATH "${OPENSSL_ROOT_DIR}/include" NO_DEFAULT_PATH)
if(MSVC)
find_library(LIB_EAY_DEBUG NAMES crypto PATHS "${OPENSSL_ROOT_DIR}/debug/lib" NO_DEFAULT_PATH)
find_library(LIB_EAY_RELEASE NAMES crypto PATHS "${OPENSSL_ROOT_DIR}/lib" NO_DEFAULT_PATH)
find_library(SSL_EAY_DEBUG NAMES ssl PATHS "${OPENSSL_ROOT_DIR}/debug/lib" NO_DEFAULT_PATH)
find_library(SSL_EAY_RELEASE NAMES ssl PATHS "${OPENSSL_ROOT_DIR}/lib" NO_DEFAULT_PATH)
elseif(WIN32)
find_library(LIB_EAY NAMES libcrypto crypto NAMES_PER_DIR)
find_library(SSL_EAY NAMES libssl ssl NAMES_PER_DIR)
else()
find_library(OPENSSL_CRYPTO_LIBRARY NAMES crypto)
find_library(OPENSSL_SSL_LIBRARY NAMES ssl)
endif()
_find_package(${ARGS})
unset(OPENSSL_ROOT_DIR)
if(DEFINED OPENSSL_ROOT_DIR_BAK)
set(OPENSSL_ROOT_DIR "${OPENSSL_ROOT_DIR_BAK}")
unset(OPENSSL_ROOT_DIR_BAK)
endif()
if(DEFINED OPENSSL_USE_STATIC_LIBS_BAK)
set(OPENSSL_USE_STATIC_LIBS "${OPENSSL_USE_STATIC_LIBS_BAK}")
unset(OPENSSL_USE_STATIC_LIBS_BAK)
endif()
if(OPENSSL_FOUND AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static")
if(WIN32)
list(APPEND OPENSSL_LIBRARIES ws2_32 ntdll bcrypt)
if(TARGET OpenSSL::Crypto)
set_property(TARGET OpenSSL::Crypto APPEND PROPERTY INTERFACE_LINK_LIBRARIES "ws2_32;ntdll;bcrypt")
endif()
if(TARGET OpenSSL::SSL)
set_property(TARGET OpenSSL::SSL APPEND PROPERTY INTERFACE_LINK_LIBRARIES "ws2_32;ntdll;bcrypt")
endif()
else()
if("REQUIRED" IN_LIST ARGS)
find_package(Threads REQUIRED)
else()
find_package(Threads)
endif()
list(APPEND OPENSSL_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
if(TARGET OpenSSL::Crypto)
set_property(TARGET OpenSSL::Crypto APPEND PROPERTY INTERFACE_LINK_LIBRARIES "Threads::Threads")
endif()
if(TARGET OpenSSL::SSL)
set_property(TARGET OpenSSL::SSL APPEND PROPERTY INTERFACE_LINK_LIBRARIES "Threads::Threads")
endif()
endif()
endif()
cmake_policy(POP)

View File

@ -1,8 +1,13 @@
{
"name": "libressl",
"version": "3.9.2",
"port-version": 1,
"description": "LibreSSL is a version of the TLS/crypto stack forked from OpenSSL in 2014, with goals of modernizing the codebase, improving security, and applying best practice development processes.",
"port-version": 2,
"description": [
"LibreSSL is a TLS/crypto stack.",
"It was forked from OpenSSL in 2014 by the OpenBSD project, with goals of modernizing the codebase, improving security, and applying best practice development processes.",
"LibreSSL provides much of the OpenSSL 1.1 API. Incompatibilities between the projects exist and are unavoidable since both evolve with different goals and priorities."
],
"homepage": "https://www.libressl.org",
"license": "ISC",
"dependencies": [
{

View File

@ -1,4 +1,10 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
vcpkg_cmake_configure(SOURCE_PATH "${CURRENT_PORT_DIR}/project")
vcpkg_find_acquire_program(PKGCONFIG)
vcpkg_cmake_configure(
SOURCE_PATH "${CURRENT_PORT_DIR}/project"
OPTIONS
"-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}"
)
vcpkg_cmake_build()

View File

@ -1,5 +1,20 @@
cmake_minimum_required(VERSION 3.7)
project(libressl-test CXX)
project(libressl-test C)
find_package(PkgConfig REQUIRED)
# libressl provides cmake config
find_package(LibreSSL CONFIG REQUIRED)
message(STATUS "LibreSSL CONFIG: ${LibreSSL_DIR}")
string(FIND "${LibreSSL_DIR}" "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" index)
if(NOT index STREQUAL "0")
message(SEND_ERROR "LibreSSL CONFIG is not from vcpkg.")
endif()
pkg_check_modules(libtls IMPORTED_TARGET REQUIRED libtls)
if(NOT libtls_VERSION STREQUAL LibreSSL_VERSION)
message(SEND_ERROR "Unexpected libtls_VERSION '${libtls_VERSION}' (expected: '${LibreSSL_VERSION}')")
endif()
# libressl promises openssl compatibility
# NB: The port doesn't provide a wrapper, so there is no support
@ -23,11 +38,26 @@ foreach(target IN ITEMS OpenSSL::SSL OpenSSL::Crypto)
message(SEND_ERROR "No location for ${target} binary")
endif()
endforeach()
# libressl provides cmake config
find_package(LibreSSL CONFIG REQUIRED)
message(STATUS "LibreSSL CONFIG: ${LibreSSL_DIR}")
string(FIND "${LibreSSL_DIR}" "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" index)
if(NOT index STREQUAL "0")
message(SEND_ERROR "LibreSSL CONFIG is not from vcpkg.")
if(NOT OPENSSL_VERSION STREQUAL "2.0.0")
message(SEND_ERROR "Unexpected OPENSSL_VERSION '${OPENSSL_VERSION}' (expected: '2.0.0')")
endif()
pkg_check_modules(openssl IMPORTED_TARGET REQUIRED openssl)
# NB: openssl.pc carries libressl version (3.x), but doesn't provide 3.x OpenSSL API.
if(NOT openssl_VERSION STREQUAL LibreSSL_VERSION)
message(SEND_ERROR "Unexpected openssl_VERSION '${openssl_VERSION}' (expected: '${LibreSSL_VERSION}')")
endif()
# compile and link tests
add_executable(openssl_cmake openssl.c)
target_link_libraries(openssl_cmake OpenSSL::SSL)
add_executable(openssl_pkgconfig openssl.c)
target_link_libraries(openssl_pkgconfig PkgConfig::openssl)
add_executable(libressl_cmake libressl.c)
target_link_libraries(libressl_cmake LibreSSL::TLS)
add_executable(libressl_pkgconfig libressl.c)
target_link_libraries(libressl_pkgconfig PkgConfig::libtls)

View File

@ -0,0 +1,6 @@
#include <tls.h>
int main()
{
return tls_init();
}

View File

@ -0,0 +1,10 @@
#include <openssl/ssl.h>
#if OPENSSL_VERSION_NUMBER != 0x20000000L
# error Unexpected version
#endif
int main()
{
return SSL_library_init();
}

View File

@ -4998,7 +4998,7 @@
},
"libressl": {
"baseline": "3.9.2",
"port-version": 1
"port-version": 2
},
"librsvg": {
"baseline": "2.40.20",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "a4db7a421fd0fe40d7c56014e8b6cf4e5a9c2525",
"version": "3.9.2",
"port-version": 2
},
{
"git-tree": "f9e56b0af8f93ed5c5adc5e2ba1696e5c16420be",
"version": "3.9.2",