From 81dc23dee8221a5910a6d539b51d0652e73b516d Mon Sep 17 00:00:00 2001 From: Jules Fouchy Date: Mon, 15 Jul 2024 18:34:21 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20[CMake]=20Option=20to=20build=20?= =?UTF-8?q?without=20OpenSSL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 99fce7d9..ac39acc5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,7 @@ target_include_directories(Coollab-Properties INTERFACE lib/range-v3/include) install(FILES "lib/range-v3/LICENSE.txt" DESTINATION "license/range-v3") set(COOLLAB_REQUIRE_ALL_FEATURES OFF CACHE BOOL "Some features are optional, like making HTTPS requests to post images to the Coollab gallery. If you don't have the necessary dependencies these features will be disabled. If you want to make sure you have all the features of Coollab enabled, set this option to ON.") +set(COOLLAB_BUILD_WITH_OPENSSL ON CACHE BOOL "Needed to make HTTPS requests to post images to the Coollab gallery.") # ---------------- # ---OpenSSL--- @@ -62,26 +63,30 @@ set(COOLLAB_REQUIRE_ALL_FEATURES OFF CACHE BOOL "Some features are optional, lik # If OpenSSL is not found this feature will be disabled. # Note: cpp-httplib can only work with OpenSSL versions 3 or 1.1.1 # Set the path to OpenSSL library directory -set(OPENSSL_USE_STATIC_LIBS TRUE) - -if(NOT APPLE) # Disabled on Mac for now, because brew installs versions 3.3 now, which isn't compatible with cpp-httplib - find_package(OpenSSL 3) - - if(NOT OpenSSL_FOUND) - if(COOLLAB_REQUIRE_ALL_FEATURES) - find_package(OpenSSL 1.1.1 REQUIRED) - else() - find_package(OpenSSL 1.1.1) +if(COOLLAB_BUILD_WITH_OPENSSL) + set(OPENSSL_USE_STATIC_LIBS TRUE) + + if(NOT APPLE) # Disabled on Mac for now, because brew installs versions 3.3 now, which isn't compatible with cpp-httplib + find_package(OpenSSL 3) + + if(NOT OpenSSL_FOUND) + if(COOLLAB_REQUIRE_ALL_FEATURES) + find_package(OpenSSL 1.1.1 REQUIRED) + else() + find_package(OpenSSL 1.1.1) + endif() endif() endif() -endif() -if(OpenSSL_FOUND) - message("[Coollab] Found OpenSSL.") - target_link_libraries(Coollab-Properties INTERFACE OpenSSL::SSL OpenSSL::Crypto) - target_compile_definitions(Coollab-Properties INTERFACE "COOLLAB_HAS_OPENSSL") + if(OpenSSL_FOUND) + message("[Coollab] Found OpenSSL.") + target_link_libraries(Coollab-Properties INTERFACE OpenSSL::SSL OpenSSL::Crypto) + target_compile_definitions(Coollab-Properties INTERFACE "COOLLAB_HAS_OPENSSL") + else() + message("[Coollab] Did not find OpenSSL. Posting images to the Coollab gallery will be disabled.") + endif() else() - message("[Coollab] Did not find OpenSSL. Posting images to the Coollab gallery will be disabled.") + message("[Coollab] Disabled building with OpenSSL.") endif() install(FILES "lib/cpp-httplib/LICENSE" DESTINATION "license/cpp-httplib")