[evolution] I#934 - CMake: Spam-filtering options should be files, not paths



commit 8fea38926f93f5ce6c2c46fd4f121207f74d49ff
Author: Milan Crha <mcrha redhat com>
Date:   Tue Jun 2 14:06:08 2020 +0200

    I#934 - CMake: Spam-filtering options should be files, not paths
    
    Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/934

 CMakeLists.txt                       | 24 +++++++++++++++---------
 cmake/modules/PrintableOptions.cmake |  8 ++++++++
 2 files changed, 23 insertions(+), 9 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 02c1291ab6..53a8587841 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -446,7 +446,7 @@ endif(ENABLE_YTNEF)
 # Bogofilter (spam filter)
 # ******************************
 
-add_printable_variable_path(WITH_BOGOFILTER "Enable spam filtering using Bogofilter (defaults to 
/usr/bin/bogofilter)" ON)
+add_printable_variable_filepath(WITH_BOGOFILTER "Enable spam filtering using Bogofilter (defaults to 
/usr/bin/bogofilter, if not found with 'auto')" "auto")
 
 string(LENGTH "${CMAKE_BINARY_DIR}" bindirlen)
 string(LENGTH "${WITH_BOGOFILTER}" maxlen)
@@ -458,9 +458,9 @@ endif(maxlen LESS bindirlen)
 string(TOUPPER "${WITH_BOGOFILTER}" optupper)
 
 set(BOGOFILTER_COMMAND "")
-if(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
+if(("${optupper}" STREQUAL "ON") OR ("${optupper}" STREQUAL "AUTO") OR ("${substr}" STREQUAL 
"${CMAKE_BINARY_DIR}"))
        set(WITH_BOGOFILTER ON)
-elseif(("${optupper}" STREQUAL "OFF") OR ("${optupper}" STREQUAL "NO"))
+elseif(("${optupper}" STREQUAL "OFF") OR ("${optupper}" STREQUAL "NO") OR ("${optupper}" STREQUAL ""))
        set(WITH_BOGOFILTER OFF)
 else()
        set(BOGOFILTER_COMMAND "${WITH_BOGOFILTER}")
@@ -478,6 +478,8 @@ if(WITH_BOGOFILTER)
                        set(BOGOFILTER_COMMAND "/usr/bin/bogofilter")
                endif(NOT BOGOFILTER_COMMAND)
        endif(BOGOFILTER_COMMAND STREQUAL "")
+
+       set(WITH_BOGOFILTER ${BOGOFILTER_COMMAND})
 endif(WITH_BOGOFILTER)
 
 unset(bindirlen)
@@ -489,8 +491,8 @@ unset(optupper)
 # SpamAssassin (spam filter)
 # ******************************
 
-add_printable_variable_path(WITH_SPAMASSASSIN "Enable spam filtering using SpamAssassin (defaults to 
/usr/bin/spamassassin)" ON)
-add_printable_variable_path(WITH_SA_LEARN "Full path command where sa-learn is located (defaults to 
/usr/bin/sa-learn)" ON)
+add_printable_variable_filepath(WITH_SPAMASSASSIN "Enable spam filtering using SpamAssassin (defaults to 
/usr/bin/spamassassin, if not found with 'auto')" "auto")
+add_printable_variable_filepath(WITH_SA_LEARN "Full path command where sa-learn is located (defaults to 
/usr/bin/sa-learn, if not found with 'auto')" "auto")
 
 string(LENGTH "${CMAKE_BINARY_DIR}" bindirlen)
 string(LENGTH "${WITH_SPAMASSASSIN}" maxlen)
@@ -502,10 +504,11 @@ endif(maxlen LESS bindirlen)
 string(TOUPPER "${WITH_SPAMASSASSIN}" optupper)
 
 set(SPAMASSASSIN_COMMAND "")
-if(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
+if(("${optupper}" STREQUAL "ON") OR ("${optupper}" STREQUAL "AUTO") OR ("${substr}" STREQUAL 
"${CMAKE_BINARY_DIR}"))
        set(WITH_SPAMASSASSIN ON)
-elseif(("${optupper}" STREQUAL "OFF") OR ("${optupper}" STREQUAL "NO"))
+elseif(("${optupper}" STREQUAL "OFF") OR ("${optupper}" STREQUAL "NO") OR ("${optupper}" STREQUAL ""))
        set(WITH_SPAMASSASSIN OFF)
+       set(WITH_SA_LEARN OFF)
 else()
        set(SPAMASSASSIN_COMMAND "${WITH_SPAMASSASSIN}")
        set(WITH_SPAMASSASSIN ON)
@@ -532,9 +535,9 @@ if(WITH_SPAMASSASSIN)
        string(TOUPPER "${WITH_SA_LEARN}" optupper)
 
        set(SA_LEARN_COMMAND "")
-       if(("${optupper}" STREQUAL "ON") OR ("${substr}" STREQUAL "${CMAKE_BINARY_DIR}"))
+       if(("${optupper}" STREQUAL "ON") OR ("${optupper}" STREQUAL "AUTO") OR ("${substr}" STREQUAL 
"${CMAKE_BINARY_DIR}"))
                set(WITH_SA_LEARN ON)
-       elseif(("${optupper}" STREQUAL "OFF") OR ("${optupper}" STREQUAL "NO"))
+       elseif(("${optupper}" STREQUAL "OFF") OR ("${optupper}" STREQUAL "NO") OR ("${optupper}" STREQUAL ""))
                set(WITH_SA_LEARN OFF)
        else()
                set(SA_LEARN_COMMAND "${WITH_SA_LEARN}")
@@ -551,6 +554,9 @@ if(WITH_SPAMASSASSIN)
                        set(SA_LEARN_COMMAND "/usr/bin/sa-learn")
                endif(NOT SA_LEARN_COMMAND)
        endif(SA_LEARN_COMMAND STREQUAL "")
+
+       set(WITH_SPAMASSASSIN ${SPAMASSASSIN_COMMAND})
+       set(WITH_SA_LEARN ${SA_LEARN_COMMAND})
 endif(WITH_SPAMASSASSIN)
 
 unset(bindirlen)
diff --git a/cmake/modules/PrintableOptions.cmake b/cmake/modules/PrintableOptions.cmake
index a79419a02a..ba1c9d0b7f 100644
--- a/cmake/modules/PrintableOptions.cmake
+++ b/cmake/modules/PrintableOptions.cmake
@@ -49,6 +49,14 @@ macro(add_printable_variable_path _name _description _default_value)
        add_printable_variable_bare(${_name})
 endmacro()
 
+macro(add_printable_variable_filepath _name _description _default_value)
+       if(_name STREQUAL "")
+               message(FATAL_ERROR "filepath variable name cannot be empty")
+       endif(_name STREQUAL "")
+       set(${_name} ${_default_value} CACHE FILEPATH ${_description})
+       add_printable_variable_bare(${_name})
+endmacro()
+
 function(print_build_options)
        message(STATUS "Configure options:")
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]