Commit 8fea3892 authored by Milan Crha's avatar Milan Crha

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

Closes #934
parent 46f62bd4
......@@ -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)
......
......@@ -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:")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment