From 7d616f7548e5ae1326cbb9b6d3ee378ef45beb13 Mon Sep 17 00:00:00 2001
From: Alexander Golubev <fatzer2@gmail.com>
Date: Mon, 11 Aug 2025 07:42:25 +0300
Subject: Add an option to build without SSL

Required in case tdelibs were build without SSL support

Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
---
 CMakeLists.txt                 |  3 +++
 ConfigureChecks.cmake          | 14 ++++++++++++++
 tdefile-plugins/CMakeLists.txt |  2 +-
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c56d2e8..b8ce5bb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -51,6 +51,7 @@ option( WITH_ALL_OPTIONS    "Enable all sane optional stuff" OFF )
 option( WITH_GCC_VISIBILITY "Enable fvisibility and fvisibility-inlines-hidden" ${WITH_ALL_OPTIONS} )
 option( WITH_ARTS           "Enable aRts support" ${WITH_ALL_OPTIONS} )
 option( WITH_SDL            "Enable SDL support" ${WITH_ALL_OPTIONS} )
+option( WITH_SSL            "Enable SSL support (build cert tdefile-plugin)" ON )
 option( WITH_BERKELEY_DB    "Enable Berkeley DB support" ${WITH_ALL_OPTIONS} )
 option( WITH_XMMS           "Enable xmms support" OFF )
 
@@ -62,6 +63,8 @@ option( WITH_XMMS           "Enable xmms support" OFF )
 #                              with xmms
 # WITH_ARTS        affects     konq-plugins/sidebar/mediaplayer, noatun plugins
 # WITH_SDL         affects     noatun plugins
+# WITH_SSL         affects     tdefile-plugins
+# WITH_SSL         requires    tdelibs build WITH_SSL=ON
 # WITH_BERKELEY_DB affects     noatun plugins
 
 # NOTE: WITH_XMMS supports only obsolte xmms version 1
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 3f7d582..025bcf8 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -13,6 +13,7 @@
 
 tde_setup_architecture_flags( )
 
+include(CheckCXXSymbolExists)
 include(TestBigEndian)
 test_big_endian(WORDS_BIGENDIAN)
 
@@ -85,3 +86,16 @@ if( BUILD_NOATUN_PLUGINS )
     endif( )
   endif( WITH_BERKELEY_DB )
 endif( BUILD_NOATUN_PLUGINS )
+
+
+if( BUILD_TDEFILE_PLUGINS AND WITH_SSL )
+  # FIXME: There should be a better way to check for SSL support in tdelibs, but at the time of
+  #        writing tdelibs doesn't seam to provide one. <2025-08-11 Fat-Zer>
+  tde_save_and_set( CMAKE_REQUIRED_INCLUDES ${TDE_INCLUDE_DIR} )
+  check_cxx_symbol_exists( "KSSL_HAVE_SSL" "ksslconfig.h" KSSL_HAVE_SSL )
+  tde_restore( CMAKE_REQUIRED_INCLUDES )
+
+  if( NOT KSSL_HAVE_SSL )
+    tde_message_fatal( "SSL is requested, but tdelibs on your system was build without SSL support" )
+  endif( )
+endif( )
diff --git a/tdefile-plugins/CMakeLists.txt b/tdefile-plugins/CMakeLists.txt
index 28a1363..945018e 100644
--- a/tdefile-plugins/CMakeLists.txt
+++ b/tdefile-plugins/CMakeLists.txt
@@ -6,4 +6,4 @@ add_subdirectory( desktop )
 add_subdirectory( folder )
 add_subdirectory( lnk )
 add_subdirectory( mhtml )
-add_subdirectory( cert )
+tde_conditional_add_subdirectory( WITH_SSL cert )
-- 
cgit v1.2.3

