mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-04-30 04:47:28 -07:00
Switch back to cmake+make, because meson doesn't yet have good way to make the library available to users via cmake find_package(): https://github.com/mesonbuild/meson/issues/7632 Closes: https://bugs.gentoo.org/969945 Signed-off-by: Alexey Sokolov <alexey+gentoo@asokolov.org> Part-of: https://codeberg.org/gentoo/gentoo/pulls/46 Merges: https://codeberg.org/gentoo/gentoo/pulls/46 Signed-off-by: Sam James <sam@gentoo.org>
182 lines
8.0 KiB
Diff
182 lines
8.0 KiB
Diff
https://github.com/yhirose/cpp-httplib/pull/2360
|
|
|
|
From 6f34a08c6e5df97481b926fdbfe650fd6faeb36f Mon Sep 17 00:00:00 2001
|
|
From: Matheus Gabriel Werny <matheusgwdl@protonmail.com>
|
|
Date: Wed, 11 Feb 2026 14:18:24 +0100
|
|
Subject: [PATCH 1/2] [CMake] New component MbedTLS
|
|
|
|
New component MbedTLS.
|
|
---
|
|
CMakeLists.txt | 27 ++++++++++++++++++++++++++-
|
|
cmake/httplibConfig.cmake.in | 7 +++++++
|
|
2 files changed, 33 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index 45a0e16b98..a11d0c66a9 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -2,11 +2,13 @@
|
|
Build options:
|
|
* Standard BUILD_SHARED_LIBS is supported and sets HTTPLIB_SHARED default value.
|
|
* HTTPLIB_USE_OPENSSL_IF_AVAILABLE (default on)
|
|
+ * HTTPLIB_USE_MBEDTLS_IF_AVAILABLE (default off)
|
|
* HTTPLIB_USE_ZLIB_IF_AVAILABLE (default on)
|
|
* HTTPLIB_USE_BROTLI_IF_AVAILABLE (default on)
|
|
* HTTPLIB_USE_ZSTD_IF_AVAILABLE (default on)
|
|
* HTTPLIB_BUILD_MODULES (default off)
|
|
* HTTPLIB_REQUIRE_OPENSSL (default off)
|
|
+ * HTTPLIB_REQUIRE_MBEDTLS (default off)
|
|
* HTTPLIB_REQUIRE_ZLIB (default off)
|
|
* HTTPLIB_REQUIRE_BROTLI (default off)
|
|
* HTTPLIB_REQUIRE_ZSTD (default off)
|
|
@@ -21,7 +23,7 @@
|
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
- After installation with Cmake, a find_package(httplib COMPONENTS OpenSSL ZLIB Brotli zstd) is available.
|
|
+ After installation with Cmake, a find_package(httplib COMPONENTS OpenSSL MbedTLS ZLIB Brotli zstd) is available.
|
|
This creates a httplib::httplib target (if found and if listed components are supported).
|
|
It can be linked like so:
|
|
|
|
@@ -48,6 +50,7 @@
|
|
These variables are available after you run find_package(httplib)
|
|
* HTTPLIB_HEADER_PATH - this is the full path to the installed header (e.g. /usr/include/httplib.h).
|
|
* HTTPLIB_IS_USING_OPENSSL - a bool for if OpenSSL support is enabled.
|
|
+ * HTTPLIB_IS_USING_MBEDTLS - a bool for if MbedTLS support is enabled.
|
|
* HTTPLIB_IS_USING_ZLIB - a bool for if ZLIB support is enabled.
|
|
* HTTPLIB_IS_USING_BROTLI - a bool for if Brotli support is enabled.
|
|
* HTTPLIB_IS_USING_ZSTD - a bool for if ZSTD support is enabled.
|
|
@@ -95,10 +98,12 @@ set(_HTTPLIB_OPENSSL_MIN_VER "3.0.0")
|
|
option(HTTPLIB_NO_EXCEPTIONS "Disable the use of C++ exceptions" OFF)
|
|
# Allow for a build to require OpenSSL to pass, instead of just being optional
|
|
option(HTTPLIB_REQUIRE_OPENSSL "Requires OpenSSL to be found & linked, or fails build." OFF)
|
|
+option(HTTPLIB_REQUIRE_MBEDTLS "Requires MbedTLS to be found & linked, or fails build." OFF)
|
|
option(HTTPLIB_REQUIRE_ZLIB "Requires ZLIB to be found & linked, or fails build." OFF)
|
|
# Allow for a build to casually enable OpenSSL/ZLIB support, but silently continue if not found.
|
|
# Make these options so their automatic use can be specifically disabled (as needed)
|
|
option(HTTPLIB_USE_OPENSSL_IF_AVAILABLE "Uses OpenSSL (if available) to enable HTTPS support." ON)
|
|
+option(HTTPLIB_USE_MBEDTLS_IF_AVAILABLE "Uses MbedTLS (if available) to enable HTTPS support." OFF)
|
|
option(HTTPLIB_USE_ZLIB_IF_AVAILABLE "Uses ZLIB (if available) to enable Zlib compression support." ON)
|
|
# Lets you compile the program as a regular library instead of header-only
|
|
option(HTTPLIB_COMPILE "If ON, uses a Python script to split the header into a compilable header & source file (requires Python v3)." OFF)
|
|
@@ -120,6 +125,15 @@ else()
|
|
message(WARNING "HTTPLIB_BUILD_MODULES requires CMake 3.28 or later. Current version is ${CMAKE_VERSION}. Modules support has been disabled.")
|
|
endif()
|
|
endif()
|
|
+
|
|
+if(HTTPLIB_REQUIRE_OPENSSL AND HTTPLIB_REQUIRE_MBEDTLS)
|
|
+ message(FATAL_ERROR "HTTPLIB_REQUIRE_OPENSSL and HTTPLIB_REQUIRE_MBEDTLS are mutually exclusive.")
|
|
+endif()
|
|
+
|
|
+if(HTTPLIB_USE_OPENSSL_IF_AVAILABLE AND HTTPLIB_USE_MBEDTLS_IF_AVAILABLE)
|
|
+ message(FATAL_ERROR "HTTPLIB_USE_OPENSSL_IF_AVAILABLE and HTTPLIB_USE_MBEDTLS_IF_AVAILABLE are mutually exclusive.")
|
|
+endif()
|
|
+
|
|
# Defaults to static library but respects standard BUILD_SHARED_LIBS if set
|
|
include(CMakeDependentOption)
|
|
cmake_dependent_option(HTTPLIB_SHARED "Build the library as a shared library instead of static. Has no effect if using header-only."
|
|
@@ -173,6 +187,15 @@ elseif(HTTPLIB_USE_OPENSSL_IF_AVAILABLE)
|
|
endif()
|
|
endif()
|
|
|
|
+if(HTTPLIB_REQUIRE_MBEDTLS)
|
|
+ find_package(MbedTLS REQUIRED)
|
|
+ set(HTTPLIB_IS_USING_MBEDTLS TRUE)
|
|
+elseif(HTTPLIB_USE_MBEDTLS_IF_AVAILABLE)
|
|
+ find_package(MbedTLS QUIET)
|
|
+ message(WARNING ${MbedTLS_FOUND}) # TODO
|
|
+ set(HTTPLIB_IS_USING_MBEDTLS ${MbedTLS_FOUND})
|
|
+endif()
|
|
+
|
|
if(HTTPLIB_REQUIRE_ZLIB)
|
|
find_package(ZLIB REQUIRED)
|
|
set(HTTPLIB_IS_USING_ZLIB TRUE)
|
|
@@ -327,6 +350,7 @@ target_link_libraries(${PROJECT_NAME} ${_INTERFACE_OR_PUBLIC}
|
|
$<$<BOOL:${HTTPLIB_IS_USING_ZSTD}>:zstd::libzstd>
|
|
$<$<BOOL:${HTTPLIB_IS_USING_OPENSSL}>:OpenSSL::SSL>
|
|
$<$<BOOL:${HTTPLIB_IS_USING_OPENSSL}>:OpenSSL::Crypto>
|
|
+ $<$<BOOL:${HTTPLIB_IS_USING_MBEDTLS}>:MbedTLS::mbedtls>
|
|
)
|
|
|
|
# Set the definitions to enable optional features
|
|
@@ -336,6 +360,7 @@ target_compile_definitions(${PROJECT_NAME} ${_INTERFACE_OR_PUBLIC}
|
|
$<$<BOOL:${HTTPLIB_IS_USING_ZLIB}>:CPPHTTPLIB_ZLIB_SUPPORT>
|
|
$<$<BOOL:${HTTPLIB_IS_USING_ZSTD}>:CPPHTTPLIB_ZSTD_SUPPORT>
|
|
$<$<BOOL:${HTTPLIB_IS_USING_OPENSSL}>:CPPHTTPLIB_OPENSSL_SUPPORT>
|
|
+ $<$<BOOL:${HTTPLIB_IS_USING_MBEDTLS}>:CPPHTTPLIB_MBEDTLS_SUPPORT>
|
|
$<$<AND:$<PLATFORM_ID:Darwin>,$<BOOL:${HTTPLIB_IS_USING_OPENSSL}>,$<BOOL:${HTTPLIB_IS_USING_CERTS_FROM_MACOSX_KEYCHAIN}>>:CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN>
|
|
$<$<BOOL:${HTTPLIB_USE_NON_BLOCKING_GETADDRINFO}>:CPPHTTPLIB_USE_NON_BLOCKING_GETADDRINFO>
|
|
)
|
|
diff --git a/cmake/httplibConfig.cmake.in b/cmake/httplibConfig.cmake.in
|
|
index 8ca8b991a2..0790f456d8 100644
|
|
--- a/cmake/httplibConfig.cmake.in
|
|
+++ b/cmake/httplibConfig.cmake.in
|
|
@@ -4,6 +4,7 @@
|
|
# Setting these here so they're accessible after install.
|
|
# Might be useful for some users to check which settings were used.
|
|
set(HTTPLIB_IS_USING_OPENSSL @HTTPLIB_IS_USING_OPENSSL@)
|
|
+set(HTTPLIB_IS_USING_MBEDTLS @HTTPLIB_IS_USING_MBEDTLS@)
|
|
set(HTTPLIB_IS_USING_ZLIB @HTTPLIB_IS_USING_ZLIB@)
|
|
set(HTTPLIB_IS_COMPILED @HTTPLIB_COMPILE@)
|
|
set(HTTPLIB_IS_USING_BROTLI @HTTPLIB_IS_USING_BROTLI@)
|
|
@@ -25,11 +26,17 @@ if(@HTTPLIB_IS_USING_OPENSSL@)
|
|
endif()
|
|
set(httplib_OpenSSL_FOUND ${OpenSSL_FOUND})
|
|
endif()
|
|
+
|
|
if(@HTTPLIB_IS_USING_ZLIB@)
|
|
find_dependency(ZLIB)
|
|
set(httplib_ZLIB_FOUND ${ZLIB_FOUND})
|
|
endif()
|
|
|
|
+if(@HTTPLIB_IS_USING_MBEDTLS@)
|
|
+ find_dependency(MbedTLS)
|
|
+ set(httplib_MbedTLS_FOUND ${MbedTLS_FOUND})
|
|
+endif()
|
|
+
|
|
if(@HTTPLIB_IS_USING_BROTLI@)
|
|
# Needed so we can use our own FindBrotli.cmake in this file.
|
|
# Note that the FindBrotli.cmake file is installed in the same dir as this file.
|
|
|
|
From 8682189e5929abecb5e8e41b43180d931995154a Mon Sep 17 00:00:00 2001
|
|
From: Matheus Gabriel Werny <matheusgwdl@protonmail.com>
|
|
Date: Wed, 11 Feb 2026 14:46:36 +0100
|
|
Subject: [PATCH 2/2] Fix case
|
|
|
|
Fix case: HTTPLIB_REQUIRE_OPENSSL=OFF; HTTPLIB_REQUIRE_MBEDTLS=ON
|
|
---
|
|
CMakeLists.txt | 6 +++++-
|
|
1 file changed, 5 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index a11d0c66a9..a2864a6ce1 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -126,6 +126,7 @@ else()
|
|
endif()
|
|
endif()
|
|
|
|
+# Incompatibility between OpenSSL and MbedTLS
|
|
if(HTTPLIB_REQUIRE_OPENSSL AND HTTPLIB_REQUIRE_MBEDTLS)
|
|
message(FATAL_ERROR "HTTPLIB_REQUIRE_OPENSSL and HTTPLIB_REQUIRE_MBEDTLS are mutually exclusive.")
|
|
endif()
|
|
@@ -134,6 +135,10 @@ if(HTTPLIB_USE_OPENSSL_IF_AVAILABLE AND HTTPLIB_USE_MBEDTLS_IF_AVAILABLE)
|
|
message(FATAL_ERROR "HTTPLIB_USE_OPENSSL_IF_AVAILABLE and HTTPLIB_USE_MBEDTLS_IF_AVAILABLE are mutually exclusive.")
|
|
endif()
|
|
|
|
+if(HTTPLIB_REQUIRE_MBEDTLS)
|
|
+ set(HTTPLIB_USE_OPENSSL_IF_AVAILABLE OFF)
|
|
+endif()
|
|
+
|
|
# Defaults to static library but respects standard BUILD_SHARED_LIBS if set
|
|
include(CMakeDependentOption)
|
|
cmake_dependent_option(HTTPLIB_SHARED "Build the library as a shared library instead of static. Has no effect if using header-only."
|
|
@@ -192,7 +197,6 @@ if(HTTPLIB_REQUIRE_MBEDTLS)
|
|
set(HTTPLIB_IS_USING_MBEDTLS TRUE)
|
|
elseif(HTTPLIB_USE_MBEDTLS_IF_AVAILABLE)
|
|
find_package(MbedTLS QUIET)
|
|
- message(WARNING ${MbedTLS_FOUND}) # TODO
|
|
set(HTTPLIB_IS_USING_MBEDTLS ${MbedTLS_FOUND})
|
|
endif()
|
|
|