This is an automated email from the ASF dual-hosted git repository.

rmiddleton pushed a commit to branch opt-in-odbc-smtp
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git

commit efc2ec8e91fe4f0fc28c044e57593194b776bf52
Author: Robert Middleton <[email protected]>
AuthorDate: Sat Feb 4 17:59:26 2023 -0500

    Make ODBC and SMTP opt-in
    
    See #189
---
 src/main/include/CMakeLists.txt | 38 +++++++++++++++++++++++++++++---------
 1 file changed, 29 insertions(+), 9 deletions(-)

diff --git a/src/main/include/CMakeLists.txt b/src/main/include/CMakeLists.txt
index 205041da..4b142fdc 100644
--- a/src/main/include/CMakeLists.txt
+++ b/src/main/include/CMakeLists.txt
@@ -106,22 +106,42 @@ include(CheckIncludeFiles)
 include(CheckIncludeFileCXX)
 include(CheckLibraryExists)
 
-if(WIN32)
-       CHECK_INCLUDE_FILES(sqlext.h HAS_ODBC)
+option(LOG4CXX_ENABLE_ODBC "Support logging via ODBC" OFF)
+if(LOG4CXX_ENABLE_ODBC)
+    if(WIN32)
+            CHECK_INCLUDE_FILES(sqlext.h HAS_ODBC)
+    else()
+            include(FindPkgConfig)
+
+            pkg_check_modules( odbc odbc )
+            if(${odbc_FOUND})
+                    set(HAS_ODBC 1)
+            else()
+                    set(HAS_ODBC 0)
+            endif(${odbc_FOUND})
+    endif(WIN32)
+
+    if(NOT ${HAS_ODBC})
+        message(SEND_ERROR "ODBC not found but requested")
+    endif()
 else()
-       include(FindPkgConfig)
+    set(HAS_ODBC 0)
+endif(LOG4CXX_ENABLE_ODBC)
 
-       pkg_check_modules( odbc QUIET odbc )
-       if(${odbc_FOUND})
-               set(HAS_ODBC 1)
-       endif(${odbc_FOUND})
-endif(WIN32)
+option(LOG4CXX_ENABLE_ESMTP "Support logging via libesmtp" OFF)
+if(LOG4CXX_ENABLE_ESMTP)
+    CHECK_LIBRARY_EXISTS(esmtp smtp_create_session "" HAS_LIBESMTP)
+    if(NOT HAS_LIBESMTP)
+        message(SEND_ERROR "SMTP support with libesmtp not found but 
requested")
+    endif()
+else()
+    set(HAS_LIBESMTP 0)
+endif(LOG4CXX_ENABLE_ESMTP)
 
 CHECK_INCLUDE_FILE_CXX(locale HAS_STD_LOCALE)
 CHECK_FUNCTION_EXISTS(mbsrtowcs HAS_MBSRTOWCS)
 CHECK_FUNCTION_EXISTS(wcstombs HAS_WCSTOMBS)
 CHECK_FUNCTION_EXISTS(fwide HAS_FWIDE)
-CHECK_LIBRARY_EXISTS(esmtp smtp_create_session "" HAS_LIBESMTP)
 CHECK_FUNCTION_EXISTS(syslog HAS_SYSLOG)
 if(UNIX)
     set(CMAKE_REQUIRED_LIBRARIES "pthread")

Reply via email to