Skip to content

Commit

Permalink
🔧 [CMake] Option to build without OpenSSL
Browse files Browse the repository at this point in the history
  • Loading branch information
JulesFouchy committed Jul 15, 2024
1 parent 9f5d2f3 commit 81dc23d
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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---
Expand All @@ -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")
Expand Down

0 comments on commit 81dc23d

Please sign in to comment.