From 1b5899aa9ed7f7fea1c002855083df6dddd2befe Mon Sep 17 00:00:00 2001 From: crueter Date: Sat, 25 Oct 2025 03:01:29 -0700 Subject: [PATCH] fix msvc httplib Signed-off-by: crueter --- CMakeLists.txt | 57 +++++++++++++++++---------------- src/web_service/CMakeLists.txt | 1 + src/web_service/web_backend.cpp | 7 ++++ 3 files changed, 37 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c0c117fcf1..3e525bfc95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -579,6 +579,35 @@ function(create_target_directory_groups target_name) endforeach() endfunction() +# Platform-specific library requirements +# Put these BEFORE EXTERNALS or Boost WILL die +# ============================================= + +if (APPLE) + # Umbrella framework for everything GUI-related + find_library(COCOA_LIBRARY Cocoa) + set(PLATFORM_LIBRARIES ${COCOA_LIBRARY} ${IOKIT_LIBRARY} ${COREVIDEO_LIBRARY}) + find_library(ICONV_LIBRARY iconv REQUIRED) + list(APPEND PLATFORM_LIBRARIES ${ICONV_LIBRARY}) +elseif (WIN32) + # Target Windows 10 + add_compile_definitions(_WIN32_WINNT=0x0A00 WINVER=0x0A00) + set(PLATFORM_LIBRARIES winmm ws2_32 iphlpapi) + if (MINGW) + # PSAPI is the Process Status API + set(PLATFORM_LIBRARIES ${PLATFORM_LIBRARIES} psapi imm32 version) + endif() +elseif (PLATFORM_HAIKU) + # Haiku is so special :) + # Some fucking genius decided to name an entire module "network" in 2019 + # this caused great disaster amongst the Haiku community who had came first with + # their "libnetwork.so"; since CMake doesn't do magic, we have to use an ABSOLUTE PATH + # to the library itself, otherwise it will think we are linking to... our network thing + set(PLATFORM_LIBRARIES bsd /boot/system/lib/libnetwork.so) +elseif (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU|SunOS)$") + set(PLATFORM_LIBRARIES rt) +endif() + add_subdirectory(externals) # pass targets from externals @@ -732,34 +761,6 @@ endif() set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) -# Platform-specific library requirements -# ====================================== - -if (APPLE) - # Umbrella framework for everything GUI-related - find_library(COCOA_LIBRARY Cocoa) - set(PLATFORM_LIBRARIES ${COCOA_LIBRARY} ${IOKIT_LIBRARY} ${COREVIDEO_LIBRARY}) - find_library(ICONV_LIBRARY iconv REQUIRED) - list(APPEND PLATFORM_LIBRARIES ${ICONV_LIBRARY}) -elseif (WIN32) - # Target Windows 10 - add_compile_definitions(_WIN32_WINNT=0x0A00 WINVER=0x0A00) - set(PLATFORM_LIBRARIES winmm ws2_32 iphlpapi) - if (MINGW) - # PSAPI is the Process Status API - set(PLATFORM_LIBRARIES ${PLATFORM_LIBRARIES} psapi imm32 version) - endif() -elseif (PLATFORM_HAIKU) - # Haiku is so special :) - # Some fucking genius decided to name an entire module "network" in 2019 - # this caused great disaster amongst the Haiku community who had came first with - # their "libnetwork.so"; since CMake doesn't do magic, we have to use an ABSOLUTE PATH - # to the library itself, otherwise it will think we are linking to... our network thing - set(PLATFORM_LIBRARIES bsd /boot/system/lib/libnetwork.so) -elseif (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU|SunOS)$") - set(PLATFORM_LIBRARIES rt) -endif() - # Setup a custom clang-format target (if clang-format can be found) that will run # against all the src files. This should be used before making a pull request. # ======================================================================= diff --git a/src/web_service/CMakeLists.txt b/src/web_service/CMakeLists.txt index c1aaac9881..af56502827 100644 --- a/src/web_service/CMakeLists.txt +++ b/src/web_service/CMakeLists.txt @@ -20,6 +20,7 @@ target_link_libraries(web_service PRIVATE common network nlohmann_json::nlohmann find_package(OpenSSL REQUIRED) target_link_libraries(web_service PRIVATE OpenSSL::SSL OpenSSL::Crypto) +target_compile_definitions(web_service PRIVATE CPPHTTPLIB_OPENSSL_SUPPORT) if (YUZU_USE_PRECOMPILED_HEADERS) target_precompile_headers(web_service PRIVATE precompiled_headers.h) diff --git a/src/web_service/web_backend.cpp b/src/web_service/web_backend.cpp index c04cdd9707..1a7d37dc5c 100644 --- a/src/web_service/web_backend.cpp +++ b/src/web_service/web_backend.cpp @@ -18,6 +18,10 @@ #pragma GCC diagnostic pop #endif +#ifdef YUZU_BUNDLED_OPENSSL +#include +#endif + #include "common/logging/log.h" #include "web_service/web_backend.h" #include "web_service/web_result.h" @@ -80,6 +84,9 @@ struct Client::Impl { cli->set_connection_timeout(TIMEOUT_SECONDS); cli->set_read_timeout(TIMEOUT_SECONDS); cli->set_write_timeout(TIMEOUT_SECONDS); +#ifdef YUZU_BUNDLED_OPENSSL + cli->load_ca_cert_store(kCert, sizeof(kCert)); +#endif } if (!cli->is_valid()) { LOG_ERROR(WebService, "Invalid URL {}", host + path);