yuzu icon indicating copy to clipboard operation
yuzu copied to clipboard

Link error when system cpp-httplib using

Open svalx opened this issue 2 years ago • 8 comments

Issue

On Linux build with cpp-httplib by package manager installed, I get a linking error - no openssl symbols founded. This patch fixing it. Maybe it should be included in the mainline?

Index: yuzu-0.1339/externals/CMakeLists.txt
===================================================================
--- yuzu-0.1339.orig/externals/CMakeLists.txt
+++ yuzu-0.1339/externals/CMakeLists.txt
@@ -103,7 +103,6 @@ add_subdirectory(sirit EXCLUDE_FROM_ALL)
 # httplib
 if (ENABLE_WEB_SERVICE AND NOT TARGET httplib::httplib)
     if (NOT WIN32)
-        find_package(OpenSSL 1.1)
         if (OPENSSL_FOUND)
             set(OPENSSL_LIBRARIES OpenSSL::SSL OpenSSL::Crypto)
         endif()
Index: yuzu-0.1339/CMakeLists.txt
===================================================================
--- yuzu-0.1339.orig/CMakeLists.txt
+++ yuzu-0.1339/CMakeLists.txt
@@ -214,6 +214,7 @@ find_package(nlohmann_json 3.8 REQUIRED)
 find_package(Opus 1.3 MODULE)
 find_package(ZLIB 1.2 REQUIRED)
 find_package(zstd 1.5 REQUIRED)
+find_package(OpenSSL 1.1)

 if (NOT YUZU_USE_EXTERNAL_VULKAN_HEADERS)
     find_package(Vulkan 1.3.238 REQUIRED)
@@ -242,6 +243,9 @@ endif()
 if (ENABLE_WEB_SERVICE)
     find_package(cpp-jwt 1.4 CONFIG)
     find_package(httplib 0.11 MODULE)
+    if (httplib_FOUND AND OPENSSL_FOUND)
+       set(LINK_OPENSSL ON)
+    endif()
 endif()

 if (YUZU_TESTS)
Index: yuzu-0.1339/src/web_service/CMakeLists.txt
===================================================================
--- yuzu-0.1339.orig/src/web_service/CMakeLists.txt
+++ yuzu-0.1339/src/web_service/CMakeLists.txt
@@ -19,6 +19,10 @@ add_library(web_service STATIC
 create_target_directory_groups(web_service)
 target_link_libraries(web_service PRIVATE common network nlohmann_json::nlohmann_json httplib::httplib cpp-jwt::cpp-jwt)

+if (LINK_OPENSSL)
+    target_link_libraries(web_service PRIVATE OpenSSL::SSL OpenSSL::Crypto)
+endif()
+
 if (YUZU_USE_PRECOMPILED_HEADERS)
     target_precompile_headers(web_service PRIVATE precompiled_headers.h)
 endif()

svalx avatar Feb 21 '23 13:02 svalx