2009-02-16 17:50:18 +01:00
#
# Rspamd - rambler antispam system
#
# Cmake configuration file
#
2012-01-16 17:59:37 +01:00
############################# INITIAL SECTION #############################################
2009-02-16 17:50:18 +01:00
PROJECT ( rspamd C )
SET ( RSPAMD_VERSION_MAJOR 0 )
2013-06-12 16:41:56 +02:00
SET ( RSPAMD_VERSION_MINOR 6 )
SET ( RSPAMD_VERSION_PATCH 0 )
2009-02-16 17:50:18 +01:00
2010-12-03 15:09:00 +01:00
2009-02-16 17:50:18 +01:00
SET ( RSPAMD_VERSION "${RSPAMD_VERSION_MAJOR}.${RSPAMD_VERSION_MINOR}.${RSPAMD_VERSION_PATCH}" )
2010-09-15 14:24:37 +02:00
SET ( RSPAMD_MASTER_SITE_URL "http://bitbucket.org/vstakhov/rspamd" )
2013-02-02 20:27:55 +01:00
IF ( NOT RSPAMD_USER )
SET ( RSPAMD_USER "nobody" )
SET ( RSPAMD_GROUP "nobody" )
ENDIF ( NOT RSPAMD_USER )
2009-02-16 17:50:18 +01:00
2011-02-04 18:34:50 +01:00
CMAKE_MINIMUM_REQUIRED ( VERSION 2.6.0 FATAL_ERROR )
2009-02-16 17:50:18 +01:00
2012-01-16 17:59:37 +01:00
############################# OPTIONS SECTION #############################################
2009-02-27 18:06:15 +01:00
OPTION ( DEBUG_MODE "Enable debug output [default: ON]" ON )
OPTION ( ENABLE_OPTIMIZATION "Enable optimization [default: OFF]" OFF )
2009-02-16 17:50:18 +01:00
OPTION ( SKIP_RELINK_RPATH "Skip relinking and full RPATH for the install tree" OFF )
2009-03-03 16:56:10 +01:00
OPTION ( ENABLE_REDIRECTOR "Enable redirector install [default: OFF]" OFF )
2009-04-29 14:37:03 +02:00
OPTION ( ENABLE_PROFILING "Enable profiling [default: OFF]" OFF )
2009-05-04 14:39:35 +02:00
OPTION ( ENABLE_GPERF_TOOLS "Enable google perftools [default: OFF]" OFF )
2010-02-19 16:13:54 +01:00
OPTION ( ENABLE_STATIC "Enable static compiling [default: OFF]" OFF )
2011-03-14 15:44:39 +01:00
OPTION ( ENABLE_LUAJIT "Link with libluajit [default: OFF]" OFF )
2013-06-07 16:37:24 +02:00
OPTION ( ENABLE_JUDY "Find and link with Judy library [default: ON]" ON )
OPTION ( ENABLE_DB "Find and link with DB library [default: OFF]" OFF )
OPTION ( ENABLE_SQLITE "Find and link with sqlite3 library [default: OFF]" OFF )
OPTION ( ENABLE_HIREDIS "Find and link with external redis library [default: OFF]" OFF )
2012-06-07 17:48:27 +02:00
OPTION ( NO_SHARED "Build internal libs static [default: OFF]" OFF )
2011-06-03 14:58:22 +02:00
OPTION ( FORCE_GMIME24 "Link with gmime2.4 [default: OFF]" OFF )
2009-02-16 17:50:18 +01:00
# Build optimized code for following CPU (default i386)
#SET(CPU_TUNE "i686")
2012-01-16 17:59:37 +01:00
############################# INCLUDE SECTION #############################################
2009-09-15 16:42:05 +02:00
2009-02-16 17:50:18 +01:00
INCLUDE ( CheckIncludeFiles )
INCLUDE ( CheckFunctionExists )
INCLUDE ( CheckSymbolExists )
2009-06-17 18:31:42 +02:00
INCLUDE ( CheckCSourceCompiles )
2009-02-16 17:50:18 +01:00
INCLUDE ( CheckLibraryExists )
INCLUDE ( FindPkgConfig )
2009-08-06 17:54:06 +02:00
INCLUDE ( CheckCCompilerFlag )
2009-11-16 16:43:30 +01:00
INCLUDE ( FindPerl )
2012-05-28 19:31:56 +02:00
INCLUDE ( FindOpenSSL )
2009-03-27 12:21:27 +01:00
2012-01-16 17:59:37 +01:00
############################# MODULES SECTION #############################################
MACRO ( _AddModulesForced MLIST WLIST )
# Generate unique string for this build
STRING ( RANDOM LENGTH 8 _MODULES_ID )
SET ( MODULES_ID ${ _MODULES_ID } CACHE INTERNAL "Modules ID" FORCE )
FILE ( WRITE "src/modules.c" "/* ${MODULES_ID} */\n#include \" config.h\ "\n" )
2012-06-14 20:20:50 +02:00
# Handle even old cmake
LIST ( LENGTH ${ MLIST } MLIST_COUNT )
LIST ( LENGTH ${ WLIST } WLIST_COUNT )
MATH ( EXPR MLIST_MAX ${ MLIST_COUNT } -1 )
MATH ( EXPR WLIST_MAX ${ WLIST_COUNT } -1 )
FOREACH ( MOD_IDX RANGE ${ MLIST_MAX } )
LIST ( GET ${ MLIST } ${ MOD_IDX } MOD )
2012-01-16 17:59:37 +01:00
FILE ( APPEND "src/modules.c" "extern module_t ${MOD}_module;\n" )
2012-06-14 20:20:50 +02:00
ENDFOREACH ( MOD_IDX RANGE ${ MLIST_MAX } )
2012-01-16 17:59:37 +01:00
FILE ( APPEND "src/modules.c" "\n\nmodule_t *modules[] = {\n" )
2012-06-14 20:20:50 +02:00
FOREACH ( MOD_IDX RANGE ${ MLIST_MAX } )
LIST ( GET ${ MLIST } ${ MOD_IDX } MOD )
2012-01-16 17:59:37 +01:00
FILE ( APPEND "src/modules.c" "&${MOD}_module,\n" )
2012-06-14 20:20:50 +02:00
ENDFOREACH ( MOD_IDX RANGE ${ MLIST_MAX } )
2012-01-16 17:59:37 +01:00
FILE ( APPEND "src/modules.c" "NULL\n};\n" )
2012-06-14 20:20:50 +02:00
FOREACH ( MOD_IDX RANGE ${ WLIST_MAX } )
LIST ( GET ${ WLIST } ${ MOD_IDX } WRK )
2012-01-16 17:59:37 +01:00
FILE ( APPEND "src/modules.c" "extern worker_t ${WRK}_worker;\n" )
2012-06-14 20:20:50 +02:00
ENDFOREACH ( MOD_IDX RANGE ${ WLIST_MAX } )
2012-01-16 17:59:37 +01:00
FILE ( APPEND "src/modules.c" "\n\nworker_t *workers[] = {\n" )
2012-06-14 20:20:50 +02:00
FOREACH ( MOD_IDX RANGE ${ WLIST_MAX } )
LIST ( GET ${ WLIST } ${ MOD_IDX } WRK )
2012-01-16 17:59:37 +01:00
FILE ( APPEND "src/modules.c" "&${WRK}_worker,\n" )
2012-06-14 20:20:50 +02:00
ENDFOREACH ( MOD_IDX RANGE ${ WLIST_MAX } )
2012-01-16 17:59:37 +01:00
FILE ( APPEND "src/modules.c" "NULL\n};\n" )
ENDMACRO ( _AddModulesForced MLIST WLIST )
MACRO ( AddModules MLIST WLIST )
_AddModulesForced ( ${ MLIST } ${ WLIST } )
#IF(NOT EXISTS "src/modules.c")
# _AddModulesForced(${MLIST} ${WLIST})
#ELSE(NOT EXISTS "src/modules.c")
# FILE(STRINGS "src/modules.c" FILE_ID_RAW REGEX "^/.*[a-zA-Z0-9]+.*/$")
# STRING(REGEX MATCH "[a-zA-Z0-9]+" FILE_ID "${FILE_ID_RAW}")
# IF(NOT FILE_ID STREQUAL MODULES_ID)
# MESSAGE("Regenerate modules info")
# _AddModulesForced(${MLIST} ${WLIST})
# ENDIF(NOT FILE_ID STREQUAL MODULES_ID)
#ENDIF(NOT EXISTS "src/modules.c")
ENDMACRO ( AddModules MLIST WLIST )
############################# CONFIG SECTION #############################################
2010-06-22 15:39:03 +02:00
# Initial set
2010-09-15 14:24:37 +02:00
IF ( CMAKE_INSTALL_PREFIX )
SET ( PREFIX ${ CMAKE_INSTALL_PREFIX } )
ENDIF ( CMAKE_INSTALL_PREFIX )
2012-06-07 17:06:09 +02:00
LIST ( APPEND CMAKE_REQUIRED_LIBRARIES m )
2012-03-27 16:58:04 +02:00
# Try to detect platform for further configuration
CHECK_C_SOURCE_COMPILES ( " #if !defined(__x86_64) && !defined(__amd64) && !defined(_M_X64)
#error assume 32 bit arch
#endif
i n t main ( ) { r e t u r n 0 ; } " A M D _ 6 4 )
IF ( NOT BUILD_CPU_MODE )
IF ( AMD_64 )
SET ( BUILD_CPU_MODE "64" )
ELSE ( AMD_64 )
SET ( BUILD_CPU_MODE "32" )
ENDIF ( AMD_64 )
ENDIF ( NOT BUILD_CPU_MODE )
2011-08-08 15:20:34 +02:00
# Platform specific configuration
2010-06-22 15:39:03 +02:00
IF ( CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" )
SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_BSD_SOURCE -DFREEBSD" )
2011-07-29 23:14:03 +02:00
CONFIGURE_FILE ( freebsd/rspamd.sh.in freebsd/rspamd @ONLY )
2010-06-22 15:39:03 +02:00
IF ( ENABLE_REDIRECTOR MATCHES "ON" )
2011-07-29 23:14:03 +02:00
CONFIGURE_FILE ( freebsd/redirector.sh.in freebsd/redirector @ONLY )
2010-06-22 15:39:03 +02:00
ENDIF ( ENABLE_REDIRECTOR MATCHES "ON" )
2011-01-26 19:37:48 +01:00
IF ( CMAKE_INSTALL_PREFIX )
2011-07-29 23:34:24 +02:00
IF ( NOT ETC_PREFIX )
SET ( ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc" )
ENDIF ( NOT ETC_PREFIX )
IF ( NOT MAN_PREFIX )
SET ( MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/man" )
ENDIF ( NOT MAN_PREFIX )
2011-08-08 15:20:34 +02:00
IF ( NOT LOCALSTATES_PREFIX )
SET ( LOCALSTATES_PREFIX "/var/run/rspamd" )
ENDIF ( NOT LOCALSTATES_PREFIX )
2011-01-26 19:37:48 +01:00
SET ( PREFIX "${CMAKE_INSTALL_PREFIX}" )
ELSE ( CMAKE_INSTALL_PREFIX )
IF ( NOT ETC_PREFIX )
SET ( ETC_PREFIX /usr/local/etc )
ENDIF ( NOT ETC_PREFIX )
IF ( NOT MAN_PREFIX )
SET ( MAN_PREFIX /usr/local/man )
ENDIF ( NOT MAN_PREFIX )
2011-08-08 15:20:34 +02:00
IF ( NOT LOCALSTATES_PREFIX )
SET ( LOCALSTATES_PREFIX "/var/run/rspamd" )
ENDIF ( NOT LOCALSTATES_PREFIX )
2011-01-26 19:37:48 +01:00
IF ( NOT PREFIX )
SET ( PREFIX /usr/local )
ENDIF ( NOT PREFIX )
ENDIF ( CMAKE_INSTALL_PREFIX )
2010-06-23 13:13:50 +02:00
FIND_LIBRARY ( LIBINTL_LIBRARY NAMES intl PATHS /lib
/ o p t / l i b
/ u s r / l i b
/ u s r / l o c a l / l i b
D O C " P a t h w h e r e t h e l i b i n t l l i b r a r y c a n b e f o u n d " )
LIST ( APPEND CMAKE_REQUIRED_LIBRARIES ${ LIBINTL_LIBRARY } )
2010-07-19 09:57:45 +02:00
MESSAGE ( STATUS "Configuring for FreeBSD" )
2010-06-23 13:13:50 +02:00
2010-06-22 15:39:03 +02:00
ENDIF ( CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" )
IF ( CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_BSD_SOURCE -DDARWIN" )
2011-01-26 19:37:48 +01:00
IF ( CMAKE_INSTALL_PREFIX )
2011-08-08 15:20:34 +02:00
IF ( NOT ETC_PREFIX )
SET ( ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc" )
ENDIF ( NOT ETC_PREFIX )
IF ( NOT MAN_PREFIX )
SET ( MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/man" )
ENDIF ( NOT MAN_PREFIX )
IF ( NOT LOCALSTATES_PREFIX )
SET ( LOCALSTATES_PREFIX "/var/run/rspamd" )
ENDIF ( NOT LOCALSTATES_PREFIX )
2011-01-26 19:37:48 +01:00
SET ( PREFIX "${CMAKE_INSTALL_PREFIX}" )
ELSE ( CMAKE_INSTALL_PREFIX )
IF ( NOT ETC_PREFIX )
SET ( ETC_PREFIX /usr/local/etc )
ENDIF ( NOT ETC_PREFIX )
IF ( NOT MAN_PREFIX )
SET ( MAN_PREFIX /usr/local/man )
ENDIF ( NOT MAN_PREFIX )
2011-08-08 15:20:34 +02:00
IF ( NOT LOCALSTATES_PREFIX )
SET ( LOCALSTATES_PREFIX "/var/run/rspamd" )
ENDIF ( NOT LOCALSTATES_PREFIX )
2011-01-26 19:37:48 +01:00
IF ( NOT PREFIX )
SET ( PREFIX /usr/local )
ENDIF ( NOT PREFIX )
ENDIF ( CMAKE_INSTALL_PREFIX )
2010-09-15 14:24:37 +02:00
2010-06-23 13:13:50 +02:00
FIND_LIBRARY ( LIBINTL_LIBRARY NAMES intl PATHS /lib
/ o p t / l i b
/ u s r / l i b
/ u s r / l o c a l / l i b
D O C " P a t h w h e r e t h e l i b i n t l l i b r a r y c a n b e f o u n d " )
LIST ( APPEND CMAKE_REQUIRED_LIBRARIES ${ LIBINTL_LIBRARY } )
2010-07-19 09:57:45 +02:00
MESSAGE ( STATUS "Configuring for Darwin" )
2010-06-22 15:39:03 +02:00
ENDIF ( CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
IF ( CMAKE_SYSTEM_NAME STREQUAL "Linux" )
SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -DLINUX" )
2011-01-26 19:37:48 +01:00
IF ( CMAKE_INSTALL_PREFIX )
2011-07-29 18:35:00 +02:00
IF ( NOT ETC_PREFIX )
SET ( ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc" )
ENDIF ( NOT ETC_PREFIX )
IF ( NOT MAN_PREFIX )
SET ( MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/share/man" )
ENDIF ( NOT MAN_PREFIX )
2011-08-08 15:20:34 +02:00
IF ( NOT LOCALSTATES_PREFIX )
SET ( LOCALSTATES_PREFIX "/var/run/rspamd" )
ENDIF ( NOT LOCALSTATES_PREFIX )
2011-07-29 18:35:00 +02:00
2011-01-26 19:37:48 +01:00
SET ( PREFIX "${CMAKE_INSTALL_PREFIX}" )
ELSE ( CMAKE_INSTALL_PREFIX )
IF ( NOT ETC_PREFIX )
SET ( ETC_PREFIX /etc )
ENDIF ( NOT ETC_PREFIX )
IF ( NOT PREFIX )
SET ( PREFIX /usr )
ENDIF ( NOT PREFIX )
IF ( NOT MAN_PREFIX )
SET ( MAN_PREFIX /usr/share/man )
ENDIF ( NOT MAN_PREFIX )
2011-08-08 15:20:34 +02:00
IF ( NOT LOCALSTATES_PREFIX )
SET ( LOCALSTATES_PREFIX "/var/run/rspamd" )
ENDIF ( NOT LOCALSTATES_PREFIX )
2011-07-21 15:35:29 +02:00
ENDIF ( CMAKE_INSTALL_PREFIX )
2012-03-27 16:46:21 +02:00
IF ( BUILD_CPU_MODE STREQUAL "32" )
SET ( CMAKE_C_FLAGS "-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE ${CMAKE_C_FLAGS}" )
ENDIF ( BUILD_CPU_MODE STREQUAL "32" )
2011-07-21 15:35:29 +02:00
# Workaround with architecture specific includes
IF ( IS_DIRECTORY "/usr/include/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu/" )
INCLUDE_DIRECTORIES ( "/usr/include/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu/" )
SET ( CMAKE_REQUIRED_INCLUDES "/usr/include/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu/" )
ENDIF ( IS_DIRECTORY "/usr/include/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu/" )
2011-01-26 19:37:48 +01:00
2010-06-22 15:39:03 +02:00
LIST ( APPEND CMAKE_REQUIRED_LIBRARIES rt )
LIST ( APPEND CMAKE_REQUIRED_LIBRARIES dl )
2010-07-19 09:57:45 +02:00
MESSAGE ( STATUS "Configuring for Linux" )
2011-07-20 17:35:07 +02:00
IF ( EXISTS "/etc/debian_version" )
SET ( LINUX_START_SCRIPT "rspamd_debian.in" )
ELSE ( EXISTS "/etc/debian_version" )
SET ( LINUX_START_SCRIPT "rspamd_rh.in" )
ENDIF ( EXISTS "/etc/debian_version" )
2010-06-22 15:39:03 +02:00
ENDIF ( CMAKE_SYSTEM_NAME STREQUAL "Linux" )
2010-06-23 12:45:33 +02:00
IF ( CMAKE_SYSTEM_NAME STREQUAL "SunOS" )
2011-10-17 13:19:38 +02:00
IF ( NOT BUILD_CPU_MODE )
SET ( BUILD_CPU_MODE "32" )
ENDIF ( NOT BUILD_CPU_MODE )
IF ( "${CMAKE_C_COMPILER_ID}" MATCHES SunPro )
2013-06-20 16:15:57 +02:00
SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Xa -xregs=no%frameptr -xstrconst -xc99" )
SET ( SUN_BUILD32 "-xtarget=generic" )
SET ( SUN_BUILD64 "-xtarget=generic64" )
2011-10-17 13:19:38 +02:00
IF ( ENABLE_OPTIMIZATION MATCHES "ON" )
SET ( CMAKE_C_OPT_FLAGS "-fast -xdepend" )
ELSE ( ENABLE_OPTIMIZATION MATCHES "ON" )
SET ( CMAKE_C_OPT_FLAGS "-xO0" )
ENDIF ( ENABLE_OPTIMIZATION MATCHES "ON" )
ELSE ( "${CMAKE_C_COMPILER_ID}" MATCHES SunPro )
set ( SUN_BUILD32 "-m32" )
set ( SUN_BUILD64 "-m64" )
ENDIF ( "${CMAKE_C_COMPILER_ID}" MATCHES SunPro )
IF ( BUILD_CPU_MODE STREQUAL "32" )
message ( STATUS "Building 32-bit mode on Solaris" )
# If we are asked to build 32 bit mode
set ( CMAKE_C_FLAGS "${SUN_BUILD32} ${CMAKE_C_FLAGS}" )
set ( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SUN_BUILD32}" )
ELSE ( BUILD_CPU_MODE STREQUAL "32" )
# solaris 64-bit mode
message ( STATUS "Building 64-bit mode on Solaris" )
set ( CMAKE_C_FLAGS "${SUN_BUILD64} ${CMAKE_C_FLAGS}" )
set ( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SUN_BUILD64}" )
ENDIF ( BUILD_CPU_MODE STREQUAL "32" )
2013-06-20 13:47:11 +02:00
SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__EXTENSIONS__ -DSOLARIS -D_POSIX_SOURCE -D_POSIX_C_SOURCE=200112L" )
2011-10-17 13:19:38 +02:00
2011-01-26 19:37:48 +01:00
IF ( CMAKE_INSTALL_PREFIX )
2011-08-08 15:20:34 +02:00
IF ( NOT ETC_PREFIX )
SET ( ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc" )
ENDIF ( NOT ETC_PREFIX )
IF ( NOT MAN_PREFIX )
SET ( MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/man" )
ENDIF ( NOT MAN_PREFIX )
IF ( NOT LOCALSTATES_PREFIX )
SET ( LOCALSTATES_PREFIX "/var/run/rspamd" )
ENDIF ( NOT LOCALSTATES_PREFIX )
2011-01-26 19:37:48 +01:00
SET ( PREFIX "${CMAKE_INSTALL_PREFIX}" )
ELSE ( CMAKE_INSTALL_PREFIX )
IF ( NOT ETC_PREFIX )
SET ( ETC_PREFIX /etc )
ENDIF ( NOT ETC_PREFIX )
IF ( NOT PREFIX )
2011-10-17 13:19:38 +02:00
SET ( PREFIX /usr )
2011-01-26 19:37:48 +01:00
ENDIF ( NOT PREFIX )
IF ( NOT MAN_PREFIX )
SET ( MAN_PREFIX /usr/share/man )
ENDIF ( NOT MAN_PREFIX )
2011-08-08 15:20:34 +02:00
IF ( NOT LOCALSTATES_PREFIX )
SET ( LOCALSTATES_PREFIX "/var/run/rspamd" )
ENDIF ( NOT LOCALSTATES_PREFIX )
2011-01-26 19:37:48 +01:00
ENDIF ( CMAKE_INSTALL_PREFIX )
2010-06-23 12:45:33 +02:00
LIST ( APPEND CMAKE_REQUIRED_LIBRARIES rt )
LIST ( APPEND CMAKE_REQUIRED_LIBRARIES dl )
LIST ( APPEND CMAKE_REQUIRED_LIBRARIES resolv )
2011-10-17 13:19:38 +02:00
LIST ( APPEND CMAKE_REQUIRED_LIBRARIES nsl )
2013-06-20 13:21:38 +02:00
LIST ( APPEND CMAKE_REQUIRED_LIBRARIES socket )
2011-10-17 13:19:38 +02:00
LIST ( APPEND CMAKE_REQUIRED_LIBRARIES umem )
2013-06-20 16:32:54 +02:00
# Ugly hack, but FindOpenSSL on Solaris does not link with libcrypto
LIST ( APPEND CMAKE_REQUIRED_LIBRARIES crypto )
2011-10-17 13:19:38 +02:00
SET ( CMAKE_VERBOSE_MAKEFILE ON )
SET ( CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE )
SET ( CMAKE_INSTALL_RPATH "${PREFIX}/lib" )
2010-06-23 12:45:33 +02:00
ENDIF ( CMAKE_SYSTEM_NAME STREQUAL "SunOS" )
2012-06-05 16:21:49 +02:00
# Set libdir
IF ( NOT LIBDIR )
SET ( LIBDIR lib/rspamd )
IF ( NOT CMAKE_INSTALL_RPATH )
SET ( CMAKE_INSTALL_RPATH ${ PREFIX } / ${ LIBDIR } )
ENDIF ( NOT CMAKE_INSTALL_RPATH )
ENDIF ( NOT LIBDIR )
# Set includedir
IF ( NOT INCLUDEDIR )
SET ( INCLUDEDIR include/rspamd )
ENDIF ( NOT INCLUDEDIR )
2011-08-08 15:20:34 +02:00
# Check prefixes
2011-08-03 16:30:25 +02:00
IF ( NOT ETC_PREFIX )
IF ( CMAKE_INSTALL_PREFIX )
MESSAGE ( WARNING "Your system is unknown for rspamd, assume defining ETC_PREFIX and MAN_PREFIX by -D option, now ETC_PREFIX and MAN_PREFIX are relative to ${CMAKE_INSTALL_PREFIX}" )
SET ( ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc" )
ELSE ( CMAKE_INSTALL_PREFIX )
MESSAGE ( FATAL_ERROR "Your system is unknown for rspamd and no CMAKE_INSTALL_PREFIX specified, assume defining CMAKE_INSTALL_PREFIX" )
ENDIF ( CMAKE_INSTALL_PREFIX )
MESSAGE ( STATUS "Configuring for ${CMAKE_SYSTEM_NAME}" )
ENDIF ( NOT ETC_PREFIX )
2011-08-08 15:20:34 +02:00
IF ( NOT MAN_PREFIX )
IF ( CMAKE_INSTALL_PREFIX )
SET ( MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/man" )
ENDIF ( CMAKE_INSTALL_PREFIX )
ENDIF ( NOT MAN_PREFIX )
IF ( NOT LOCALSTATES_PREFIX )
IF ( CMAKE_INSTALL_PREFIX )
SET ( LOCALSTATES_PREFIX "/var/run/rspamd" )
ENDIF ( CMAKE_INSTALL_PREFIX )
ENDIF ( NOT LOCALSTATES_PREFIX )
# Now CMAKE_INSTALL_PREFIX is a base prefix for everything
# ETC_PREFIX - for configuration
# MAN_PREFIX - for manual pages
# LOCALSTATES_PREFIX - for runtime files
# Now find libraries and headers
2011-08-03 16:30:25 +02:00
2013-06-08 17:07:25 +02:00
# Find lua libraries
IF ( NOT LUA_VERSION_MAJOR OR NOT LUA_VERSION_MINOR )
SET ( LUA_VERSION_MAJOR "5" )
SET ( LUA_VERSION_MINOR "1" )
ENDIF ( NOT LUA_VERSION_MAJOR OR NOT LUA_VERSION_MINOR )
FIND_PATH ( LUA_INCLUDE_DIR lua.h
H I N T S
$ E N V { L U A _ D I R }
P A T H _ S U F F I X E S " i n c l u d e / l u a $ { L U A _ V E R S I O N _ M A J O R } $ { L U A _ V E R S I O N _ M I N O R } "
" i n c l u d e / l u a $ { L U A _ V E R S I O N _ M A J O R } . $ { L U A _ V E R S I O N _ M I N O R } "
i n c l u d e / l u a i n c l u d e
P A T H S
/ u s r / l o c a l
/ u s r
~ / L i b r a r y / F r a m e w o r k s
/ L i b r a r y / F r a m e w o r k s
/ s w # Fink
/ o p t / l o c a l # DarwinPorts
/ o p t / c s w # Blastwave
/ o p t
)
FIND_LIBRARY ( LUA_LIBRARY
N A M E S l u a
" l u a $ { L U A _ V E R S I O N _ M A J O R } $ { L U A _ V E R S I O N _ M I N O R } "
" l u a $ { L U A _ V E R S I O N _ M A J O R } . $ { L U A _ V E R S I O N _ M I N O R } "
" l u a - $ { L U A _ V E R S I O N _ M A J O R } . $ { L U A _ V E R S I O N _ M I N O R } "
H I N T S
$ E N V { L U A _ D I R }
P A T H _ S U F F I X E S l i b 6 4 l i b
P A T H S
/ u s r / l o c a l
/ u s r
~ / L i b r a r y / F r a m e w o r k s
/ L i b r a r y / F r a m e w o r k s
/ s w
/ o p t / l o c a l
/ o p t / c s w
/ o p t
D O C " L u a l i b r a r y "
)
IF ( LUA_LIBRARY AND LUA_INCLUDE_DIR )
SET ( LUA_FOUND 1 )
ENDIF ( LUA_LIBRARY AND LUA_INCLUDE_DIR )
2011-03-14 15:44:39 +01:00
# Check for luajit
IF ( ENABLE_LUAJIT MATCHES "ON" )
2013-06-08 17:07:25 +02:00
FIND_LIBRARY ( LUAJIT_LIBRARY NAMES
" l u a j i t $ { L U A _ V E R S I O N _ M A J O R } $ { L U A _ V E R S I O N _ M I N O R } "
" l u a j i t $ { L U A _ V E R S I O N _ M A J O R } . $ { L U A _ V E R S I O N _ M I N O R } "
" l u a j i t - $ { L U A _ V E R S I O N _ M A J O R } . $ { L U A _ V E R S I O N _ M I N O R } "
l u a j i t
2011-03-14 15:44:39 +01:00
H I N T S
$ E N V { L U A _ D I R }
P A T H _ S U F F I X E S l i b 6 4 l i b
P A T H S
~ / L i b r a r y / F r a m e w o r k s
/ L i b r a r y / F r a m e w o r k s
/ u s r / l o c a l
/ u s r
/ s w
/ o p t / l o c a l
/ o p t / c s w
/ o p t
)
IF ( NOT LUAJIT_LIBRARY )
MESSAGE ( FATAL_ERROR "Luajit not found but enabled in configuration" )
ENDIF ( NOT LUAJIT_LIBRARY )
ENDIF ( ENABLE_LUAJIT MATCHES "ON" )
2010-04-05 19:09:40 +02:00
IF ( NOT LUA_FOUND )
2013-06-08 17:07:25 +02:00
MESSAGE ( FATAL_ERROR "Lua not found, lua support is required for working" )
2010-04-05 19:09:40 +02:00
ELSE ( NOT LUA_FOUND )
SET ( WITH_LUA 1 )
INCLUDE_DIRECTORIES ( "${LUA_INCLUDE_DIR}" )
ENDIF ( NOT LUA_FOUND )
2009-03-27 16:30:40 +01:00
2011-07-29 18:35:00 +02:00
# Check and link to pcre
pkg_check_modules ( PCRE REQUIRED libpcre )
IF ( PCRE_INCLUDE_DIRS )
INCLUDE_DIRECTORIES ( "${PCRE_INCLUDE_DIRS}" )
ENDIF ( PCRE_INCLUDE_DIRS )
IF ( PCRE_LIBRARY_DIRS )
LINK_DIRECTORIES ( "${PCRE_LIBRARY_DIRS}" )
ENDIF ( PCRE_LIBRARY_DIRS )
2013-06-07 16:37:24 +02:00
IF ( ENABLE_SQLITE MATCHES "ON" )
# Find optional sqlite3 support
pkg_check_modules ( SQLITE sqlite3>=3.6.0 )
IF ( SQLITE_FOUND )
SET ( WITH_SQLITE 1 )
ENDIF ( SQLITE_FOUND )
IF ( SQLITE_INCLUDE_DIRS )
INCLUDE_DIRECTORIES ( "${SQLITE_INCLUDE_DIRS}" )
ENDIF ( SQLITE_INCLUDE_DIRS )
IF ( SQLITE_LIBRARY_DIRS )
LINK_DIRECTORIES ( "${SQLITE_LIBRARY_DIRS}" )
ENDIF ( SQLITE_LIBRARY_DIRS )
ENDIF ( ENABLE_SQLITE MATCHES "ON" )
2011-11-02 15:49:09 +01:00
2012-05-28 19:31:56 +02:00
#Check for openssl (required for dkim)
IF ( OPENSSL_FOUND )
SET ( HAVE_OPENSSL 1 )
INCLUDE_DIRECTORIES ( "${OPENSSL_INCLUDE_DIR}" )
ENDIF ( OPENSSL_FOUND )
2010-02-19 16:13:54 +01:00
IF ( ENABLE_STATIC MATCHES "ON" )
2012-08-07 13:59:20 +02:00
pkg_check_modules ( GLIB2 REQUIRED glib-2.0>=2.12 gthread-2.0 gmodule-2.0 )
2012-06-05 17:22:57 +02:00
SET ( LINK_TYPE "STATIC" )
2010-02-19 16:13:54 +01:00
ELSE ( ENABLE_STATIC MATCHES "ON" )
2012-08-07 13:59:20 +02:00
pkg_check_modules ( GLIB2 REQUIRED glib-2.0>=2.12 gthread-2.0 gmodule-2.0 )
2012-06-07 17:48:27 +02:00
IF ( NO_SHARED MATCHES "OFF" )
SET ( LINK_TYPE "SHARED" )
ELSE ( NO_SHARED MATCHES "OFF" )
SET ( LINK_TYPE "STATIC" )
ENDIF ( NO_SHARED MATCHES "OFF" )
2010-02-19 16:13:54 +01:00
ENDIF ( ENABLE_STATIC MATCHES "ON" )
2012-06-05 17:22:57 +02:00
SET ( GLIB2_VERSION "${GLIB2_glib-2.0_VERSION}" )
IF ( GLIB2_VERSION VERSION_GREATER "2.30.0" )
pkg_check_modules ( LIBFFI libffi )
IF ( LIBFFI_FOUND )
SET ( GLIB2_LDFLAGS "${GLIB2_LDFLAGS};${LIBFFI_LDFLAGS}" )
SET ( GLIB2_LIBRARIES "${GLIB2_LIBRARIES};${LIBFFI_LIBRARIES}" )
SET ( GLIB2_STATIC_LDFLAGS "${GLIB2_STATIC_LDFLAGS};${LIBFFI_STATIC_LDFLAGS}" )
SET ( GLIB2_CFLAGS "${GLIB2_CFLAGS};${LIBFFI_CFLAGS}" )
ENDIF ( LIBFFI_FOUND )
ENDIF ( GLIB2_VERSION VERSION_GREATER "2.30.0" )
2009-03-01 23:59:39 +01:00
pkg_check_modules ( GMIME2 gmime-2.0 )
2013-06-07 16:37:24 +02:00
IF ( ENABLE_HIREDIS MATCHES "ON" )
# Try to find hiredis library
pkg_check_modules ( HIREDIS REQUIRED libhiredis )
IF ( HIREDIS_INCLUDE_DIRS )
INCLUDE_DIRECTORIES ( "${HIREDIS_INCLUDE_DIRS}" )
ENDIF ( HIREDIS_INCLUDE_DIRS )
IF ( HIREDIS_LIBRARY_DIRS )
LINK_DIRECTORIES ( "${HIREDIS_LIBRARY_DIRS}" )
ENDIF ( HIREDIS_LIBRARY_DIRS )
IF ( HIREDIS_FOUND )
SET ( WITH_SYSTEM_HIREDIS 1 )
ENDIF ( HIREDIS_FOUND )
ENDIF ( ENABLE_HIREDIS MATCHES "ON" )
2011-12-09 17:13:00 +01:00
2009-03-01 23:59:39 +01:00
# Try to link with gmime24
2011-06-03 14:58:22 +02:00
IF ( NOT GMIME2_FOUND OR FORCE_GMIME24 )
2012-07-03 17:45:03 +02:00
pkg_check_modules ( GMIME24 gmime-2.4 )
IF ( NOT GMIME24_FOUND )
pkg_check_modules ( GMIME24 REQUIRED gmime-2.6 )
ENDIF ( NOT GMIME24_FOUND )
2010-05-31 17:45:13 +02:00
SET ( GMIME24 "yes" )
# Gmime2
FOREACH ( arg ${ GMIME24_CFLAGS } )
SET ( GMIME_CFLAGS "${GMIME_CFLAGS} ${arg}" )
ENDFOREACH ( arg ${ GMIME24_CFLAGS } )
IF ( ENABLE_STATIC MATCHES "ON" )
FOREACH ( arg ${ GMIME24_STATIC_LDFLAGS } )
SET ( GMIME_LDFLAGS "${GMIME_LDFLAGS} ${arg}" )
ENDFOREACH ( arg ${ GMIME24_LDFLAGS } )
ELSE ( ENABLE_STATIC MATCHES "ON" )
FOREACH ( arg ${ GMIME24_LDFLAGS } )
SET ( GMIME_LDFLAGS "${GMIME_LDFLAGS} ${arg}" )
ENDFOREACH ( arg ${ GMIME24_LDFLAGS } )
ENDIF ( ENABLE_STATIC MATCHES "ON" )
2011-07-29 18:35:00 +02:00
IF ( GMIME24_INCLUDE_DIRS )
INCLUDE_DIRECTORIES ( ${ GMIME24_INCLUDE_DIRS } )
ENDIF ( GMIME24_INCLUDE_DIRS )
IF ( GMIME24_LIBRARY_DIRS )
LINK_DIRECTORIES ( ${ GMIME24_LIBRARY_DIRS } )
ENDIF ( GMIME24_LIBRARY_DIRS )
2011-06-03 14:58:22 +02:00
ELSE ( NOT GMIME2_FOUND OR FORCE_GMIME24 )
2010-05-31 17:45:13 +02:00
# Gmime2
FOREACH ( arg ${ GMIME2_CFLAGS } )
SET ( GMIME_CFLAGS "${GMIME_CFLAGS} ${arg}" )
ENDFOREACH ( arg ${ GMIME2_CFLAGS } )
IF ( ENABLE_STATIC MATCHES "ON" )
FOREACH ( arg ${ GMIME2_STATIC_LDFLAGS } )
SET ( GMIME_LDFLAGS "${GMIME_LDFLAGS} ${arg}" )
ENDFOREACH ( arg ${ GMIME2_LDFLAGS } )
ELSE ( ENABLE_STATIC MATCHES "ON" )
FOREACH ( arg ${ GMIME2_LDFLAGS } )
SET ( GMIME_LDFLAGS "${GMIME_LDFLAGS} ${arg}" )
ENDFOREACH ( arg ${ GMIME2_LDFLAGS } )
ENDIF ( ENABLE_STATIC MATCHES "ON" )
2011-07-29 18:35:00 +02:00
IF ( GMIME2_INCLUDE_DIRS )
INCLUDE_DIRECTORIES ( ${ GMIME2_INCLUDE_DIRS } )
ENDIF ( GMIME2_INCLUDE_DIRS )
IF ( GMIME2_LIBRARY_DIRS )
LINK_DIRECTORIES ( ${ GMIME2_LIBRARY_DIRS } )
ENDIF ( GMIME2_LIBRARY_DIRS )
2011-06-03 14:58:22 +02:00
ENDIF ( NOT GMIME2_FOUND OR FORCE_GMIME24 )
2009-02-16 17:50:18 +01:00
2009-02-17 13:04:24 +01:00
# Make from ; separated list normal space separated list
# Glib2
FOREACH ( arg ${ GLIB2_CFLAGS } )
SET ( GLIB_CFLAGS "${GLIB_CFLAGS} ${arg}" )
ENDFOREACH ( arg ${ GLIB2_CFLAGS } )
2010-02-19 16:13:54 +01:00
IF ( ENABLE_STATIC MATCHES "ON" )
FOREACH ( arg ${ GLIB2_STATIC_LDFLAGS } )
SET ( GLIB_LDFLAGS "${GLIB_LDFLAGS} ${arg}" )
ENDFOREACH ( arg ${ GLIB2_LDFLAGS } )
ELSE ( ENABLE_STATIC MATCHES "ON" )
FOREACH ( arg ${ GLIB2_LDFLAGS } )
SET ( GLIB_LDFLAGS "${GLIB_LDFLAGS} ${arg}" )
ENDFOREACH ( arg ${ GLIB2_LDFLAGS } )
ENDIF ( ENABLE_STATIC MATCHES "ON" )
2009-02-17 13:04:24 +01:00
2009-02-16 17:50:18 +01:00
INCLUDE_DIRECTORIES ( ${ GLIB2_INCLUDE_DIRS } )
LINK_DIRECTORIES ( ${ GLIB2_LIBRARY_DIRS } )
2013-03-27 12:53:05 +01:00
FIND_LIBRARY ( LIBZ_LIBRARY NAMES z PATH_SUFFIXES lib64 lib
P A T H S
~ / L i b r a r y / F r a m e w o r k s
/ L i b r a r y / F r a m e w o r k s
/ u s r / l o c a l
/ u s r
/ s w
/ o p t / l o c a l
/ o p t / c s w
/ o p t
D O C " P a t h w h e r e t h e l i b z l i b r a r y c a n b e f o u n d " )
IF ( NOT LIBZ_LIBRARY )
MESSAGE ( FATAL_ERROR "libz is required for libgmime" )
ENDIF ( NOT LIBZ_LIBRARY )
2010-03-18 17:43:55 +01:00
# Check for libevent
2011-10-11 17:39:38 +02:00
FIND_LIBRARY ( LIBEVENT_LIBRARY NAMES event PATH_SUFFIXES lib64 lib
P A T H S
~ / L i b r a r y / F r a m e w o r k s
/ L i b r a r y / F r a m e w o r k s
/ u s r / l o c a l
/ u s r
/ s w
/ o p t / l o c a l
/ o p t / c s w
/ o p t
2009-02-17 13:04:24 +01:00
D O C " P a t h w h e r e t h e l i b e v e n t l i b r a r y c a n b e f o u n d " )
IF ( NOT LIBEVENT_LIBRARY )
2009-02-16 17:50:18 +01:00
MESSAGE ( FATAL_ERROR "libevent is required for building rspamd" )
2009-02-17 13:04:24 +01:00
ENDIF ( NOT LIBEVENT_LIBRARY )
2010-03-18 17:43:55 +01:00
FIND_PATH ( LIBEVENT_INCLUDE event.h PATHS /opt/include
/ u s r / i n c l u d e
/ u s r / l o c a l / i n c l u d e
D O C " P a t h w h e r e t h e l i b e v e n t h e a d e r f i l e s c a n b e f o u n d " )
2013-06-20 13:21:38 +02:00
FIND_PATH ( LIBEVENT_EVHTTP evhttp.h PATHS /opt/include
/ u s r / i n c l u d e
/ u s r / l o c a l / i n c l u d e
D O C " P a t h w h e r e t h e l i b e v h t t p h e a d e r f i l e s c a n b e f o u n d " )
2010-03-18 17:43:55 +01:00
GET_FILENAME_COMPONENT ( LIBEVENT_PATH "${LIBEVENT_LIBRARY}" PATH )
INCLUDE_DIRECTORIES ( "${LIBEVENT_INCLUDE}" )
LINK_DIRECTORIES ( "${LIBEVENT_PATH}" )
2013-06-07 16:37:24 +02:00
IF ( ENABLE_JUDY MATCHES "ON" )
# Find libjudy
FIND_LIBRARY ( LIBJUDY_LIBRARY NAMES Judy PATH_SUFFIXES lib64 lib
P A T H S
~ / L i b r a r y / F r a m e w o r k s
/ L i b r a r y / F r a m e w o r k s
/ u s r / l o c a l
/ u s r
/ s w
/ o p t / l o c a l
/ o p t / c s w
/ o p t
D O C " P a t h w h e r e t h e l i b j u d y l i b r a r y c a n b e f o u n d " )
IF ( LIBJUDY_LIBRARY )
FIND_PATH ( LIBJUDY_INCLUDE Judy.h PATHS /opt/include
/ u s r / i n c l u d e
/ u s r / l o c a l / i n c l u d e
D O C " P a t h w h e r e t h e j u d y h e a d e r f i l e s c a n b e f o u n d " )
GET_FILENAME_COMPONENT ( LIBJUDY_PATH "${LIBJUDY_LIBRARY}" PATH )
INCLUDE_DIRECTORIES ( "${LIBJUDY_INCLUDE}" )
LINK_DIRECTORIES ( "${LIBJUDY_PATH}" )
SET ( WITH_JUDY 1 )
ENDIF ( LIBJUDY_LIBRARY )
ENDIF ( ENABLE_JUDY MATCHES "ON" )
2010-03-18 17:43:55 +01:00
2011-10-11 17:39:38 +02:00
# Find libbd
2013-06-07 16:37:24 +02:00
IF ( ENABLE_DB MATCHES "ON" )
FIND_LIBRARY ( LIBDB_LIBRARY NAMES db PATHS PATH_SUFFIXES lib64 lib
P A T H S
~ / L i b r a r y / F r a m e w o r k s
/ L i b r a r y / F r a m e w o r k s
/ u s r / l o c a l
/ u s r
/ s w
/ o p t / l o c a l
/ o p t / c s w
/ o p t
D O C " P a t h w h e r e t h e l i b d b l i b r a r y c a n b e f o u n d " )
IF ( LIBDB_LIBRARY )
FIND_PATH ( LIBDB_INCLUDE db.h PATHS /opt/include
/ u s r / i n c l u d e
/ u s r / l o c a l / i n c l u d e
D O C " P a t h w h e r e t h e b d b h e a d e r f i l e s c a n b e f o u n d " )
GET_FILENAME_COMPONENT ( LIBDB_PATH "${LIBDB_LIBRARY}" PATH )
INCLUDE_DIRECTORIES ( "${LIBDB_INCLUDE}" )
LINK_DIRECTORIES ( "${LIBDB_PATH}" )
SET ( WITH_DB 1 )
ENDIF ( LIBDB_LIBRARY )
ENDIF ( ENABLE_DB MATCHES "ON" )
2011-10-11 17:39:38 +02:00
2009-04-29 14:37:03 +02:00
IF ( ENABLE_PROFILING MATCHES "ON" )
SET ( WITH_PROFILER 1 )
SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg" )
SET ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg" )
ENDIF ( ENABLE_PROFILING MATCHES "ON" )
2011-08-08 15:20:34 +02:00
# Static build
2010-02-19 16:13:54 +01:00
IF ( ENABLE_STATIC MATCHES "ON" )
SET ( BUILD_STATIC 1 )
2011-11-02 17:53:18 +01:00
SET ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -pthread" )
2010-02-19 16:13:54 +01:00
MESSAGE ( STATUS "Static build of rspamd, no custom plugins support" )
ENDIF ( ENABLE_STATIC MATCHES "ON" )
2011-08-08 15:20:34 +02:00
# Google performance tools
2009-05-04 14:39:35 +02:00
IF ( ENABLE_GPERF_TOOLS MATCHES "ON" )
2009-08-25 11:50:35 +02:00
FIND_PATH ( GPERF_INCLUDE google/profiler.h PATHS /opt/include
/ u s r / i n c l u d e
/ u s r / l o c a l / i n c l u d e
D O C " P a t h w h e r e g o o g l e p e r f t o o l s i n c l u d e s c a n b e f o u n d " )
INCLUDE_DIRECTORIES ( "${GPERF_INCLUDE}" )
2011-10-11 17:39:38 +02:00
FIND_LIBRARY ( GPERF_LIBRARY NAMES profiler PATH_SUFFIXES lib64 lib
P A T H S
~ / L i b r a r y / F r a m e w o r k s
/ L i b r a r y / F r a m e w o r k s
/ u s r / l o c a l
/ u s r
/ s w
/ o p t / l o c a l
/ o p t / c s w
/ o p t
2009-08-25 11:50:35 +02:00
D O C " P a t h w h e r e t h e g p e r f l i b r a r y c a n b e f o u n d " )
IF ( NOT GPERF_LIBRARY )
MESSAGE ( FATAL_ERROR "gperf tools support is enabled but not found in system" )
ENDIF ( NOT GPERF_LIBRARY )
GET_FILENAME_COMPONENT ( GPERF_PATH "${GPERF_LIBRARY}" PATH )
LINK_DIRECTORIES ( "${GPERF_PATH}" )
2009-08-25 12:17:55 +02:00
SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-omit-frame-pointer" )
2009-05-04 14:39:35 +02:00
SET ( WITH_GPERF_TOOLS 1 )
ENDIF ( ENABLE_GPERF_TOOLS MATCHES "ON" )
2011-08-08 15:20:34 +02:00
# Find util library
2009-03-27 14:28:12 +01:00
2011-10-11 17:39:38 +02:00
FIND_LIBRARY ( LIBUTIL_LIBRARY NAMES util PATHS PATH_SUFFIXES lib64 lib
P A T H S
~ / L i b r a r y / F r a m e w o r k s
/ L i b r a r y / F r a m e w o r k s
/ u s r / l o c a l
/ u s r
/ s w
/ o p t / l o c a l
/ o p t / c s w
/ o p t
2009-02-17 13:04:24 +01:00
D O C " P a t h w h e r e t h e l i b u t i l l i b r a r y c a n b e f o u n d " )
IF ( LIBUTIL_LIBRARY )
LIST ( APPEND CMAKE_REQUIRED_LIBRARIES util )
CHECK_FUNCTION_EXISTS ( pidfile_open HAVE_PIDFILE )
2012-07-26 14:43:36 +02:00
CHECK_FUNCTION_EXISTS ( pidfile_fileno HAVE_PIDFILE_FILENO )
2009-02-17 13:04:24 +01:00
FIND_FILE ( HAVE_LIBUTIL_H NAMES libutil.h PATHS /usr/include
/ o p t / i n c l u d e
/ u s r / l o c a l / i n c l u d e
D O C " P a t h t o l i b u t i l h e a d e r " )
ENDIF ( LIBUTIL_LIBRARY )
2009-02-16 17:50:18 +01:00
2011-12-20 17:11:49 +01:00
# Process with warn flags
SET ( CMAKE_C_WARN_FLAGS "" )
CHECK_C_COMPILER_FLAG ( -Wall SUPPORT_WALL )
2012-06-05 18:52:41 +02:00
CHECK_C_COMPILER_FLAG ( -W SUPPORT_W )
2011-12-20 17:11:49 +01:00
CHECK_C_COMPILER_FLAG ( -Wpointer-arith SUPPORT_WPOINTER )
CHECK_C_COMPILER_FLAG ( -Wno-unused-parameter SUPPORT_WPARAM )
CHECK_C_COMPILER_FLAG ( -Wno-unused-function SUPPORT_WFUNCTION )
CHECK_C_COMPILER_FLAG ( -Wunused-variable SUPPORT_WUNUSED_VAR )
CHECK_C_COMPILER_FLAG ( -Wno-pointer-sign SUPPORT_WPOINTER_SIGN )
2012-06-05 18:52:41 +02:00
CHECK_C_COMPILER_FLAG ( -Wstrict-prototypes SUPPORT_WSTRICT_PROTOTYPES )
2011-12-20 17:11:49 +01:00
CHECK_C_COMPILER_FLAG ( -pedantic SUPPORT_PEDANTIC_FLAG )
2013-06-20 13:21:38 +02:00
IF ( NOT "${CMAKE_C_COMPILER_ID}" MATCHES SunPro )
CHECK_C_COMPILER_FLAG ( "-std=c99" SUPPORT_STD_FLAG )
ENDIF ( NOT "${CMAKE_C_COMPILER_ID}" MATCHES SunPro )
2011-12-20 17:11:49 +01:00
IF ( SUPPORT_W )
SET ( CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -W" )
ENDIF ( SUPPORT_W )
IF ( SUPPORT_WALL )
SET ( CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wall" )
ENDIF ( SUPPORT_WALL )
IF ( SUPPORT_WPOINTER )
SET ( CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wpointer-arith" )
ENDIF ( SUPPORT_WPOINTER )
IF ( SUPPORT_WPARAM )
SET ( CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-unused-parameter" )
ENDIF ( SUPPORT_WPARAM )
IF ( SUPPORT_WFUNCTION )
SET ( CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-unused-function" )
ENDIF ( SUPPORT_WFUNCTION )
IF ( SUPPORT_WUNUSED_VAR )
SET ( CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wunused-variable" )
ENDIF ( SUPPORT_WUNUSED_VAR )
IF ( SUPPORT_WPOINTER_SIGN )
SET ( CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-pointer-sign" )
ENDIF ( SUPPORT_WPOINTER_SIGN )
2012-06-05 18:52:41 +02:00
IF ( SUPPORT_WSTRICT_PROTOTYPES )
SET ( CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wstrict-prototypes" )
ENDIF ( SUPPORT_WSTRICT_PROTOTYPES )
2011-12-20 17:11:49 +01:00
IF ( SUPPORT_PEDANTIC_FLAG )
SET ( CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -pedantic" )
ENDIF ( SUPPORT_PEDANTIC_FLAG )
2011-12-20 17:14:29 +01:00
IF ( SUPPORT_STD_FLAG )
SET ( CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -std=c99" )
ENDIF ( SUPPORT_STD_FLAG )
2011-10-17 13:19:38 +02:00
2012-06-07 17:48:27 +02:00
CHECK_C_COMPILER_FLAG ( -fPIC SUPPORT_FPIC )
IF ( SUPPORT_FPIC )
SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC" )
ENDIF ( SUPPORT_FPIC )
CHECK_C_COMPILER_FLAG ( -fpic SUPPORT_Fpic )
IF ( SUPPORT_Fpic )
SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fpic" )
ENDIF ( SUPPORT_Fpic )
2011-10-17 13:19:38 +02:00
# Optimization flags
IF ( NOT CMAKE_C_OPT_FLAGS )
IF ( ENABLE_OPTIMIZATION MATCHES "ON" )
2012-06-05 18:52:41 +02:00
SET ( CMAKE_C_OPT_FLAGS "-O3 -fstrict-aliasing" )
2011-10-17 13:19:38 +02:00
ELSE ( ENABLE_OPTIMIZATION MATCHES "ON" )
2012-06-05 18:52:41 +02:00
SET ( CMAKE_C_OPT_FLAGS "-O0 -fstrict-aliasing" )
2011-10-17 13:19:38 +02:00
ENDIF ( ENABLE_OPTIMIZATION MATCHES "ON" )
ENDIF ( NOT CMAKE_C_OPT_FLAGS )
IF ( DEBUG_MODE MATCHES "ON" )
SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g" )
ENDIF ( DEBUG_MODE MATCHES "ON" )
2011-08-08 15:20:34 +02:00
2011-10-17 13:19:38 +02:00
SET ( CMAKE_C_FLAGS "${CMAKE_C_OPT_FLAGS} ${CMAKE_C_FLAGS} ${CMAKE_C_WARN_FLAGS}" )
2011-08-08 15:20:34 +02:00
# Check platform specific includes
2009-02-16 17:50:18 +01:00
CHECK_INCLUDE_FILES ( sys/types.h HAVE_SYS_TYPES_H )
CHECK_INCLUDE_FILES ( sys/time.h HAVE_SYS_TIME_H )
CHECK_INCLUDE_FILES ( sys/uio.h HAVE_SYS_UIO_H )
CHECK_INCLUDE_FILES ( fcntl.h HAVE_FCNTL_H )
CHECK_INCLUDE_FILES ( math.h HAVE_MATH_H )
CHECK_INCLUDE_FILES ( stdio.h HAVE_STDIO_H )
CHECK_INCLUDE_FILES ( stdlib.h HAVE_STDLIB_H )
CHECK_INCLUDE_FILES ( string.h HAVE_STRING_H )
CHECK_INCLUDE_FILES ( strings.h HAVE_STRINGS_H )
CHECK_INCLUDE_FILES ( time.h HAVE_TIME_H )
CHECK_INCLUDE_FILES ( unistd.h HAVE_UNISTD_H )
CHECK_INCLUDE_FILES ( sysexits.h HAVE_SYSEXITS_H )
CHECK_INCLUDE_FILES ( stdint.h HAVE_STDINT_H )
CHECK_INCLUDE_FILES ( inttypes.h HAVE_INTTYPES_H )
CHECK_INCLUDE_FILES ( endian.h HAVE_ENDIAN_H )
CHECK_INCLUDE_FILES ( sys/endian.h HAVE_SYS_ENDIAN_H )
CHECK_INCLUDE_FILES ( machine/endian.h HAVE_MACHINE_ENDIAN_H )
CHECK_INCLUDE_FILES ( sys/queue.h HAVE_SYS_QUEUE_H )
CHECK_INCLUDE_FILES ( sys/socket.h HAVE_SYS_SOCKET_H )
CHECK_INCLUDE_FILES ( sys/mman.h HAVE_SYS_MMAN_H )
CHECK_INCLUDE_FILES ( sys/un.h HAVE_SYS_UN_H )
CHECK_INCLUDE_FILES ( sys/stat.h HAVE_SYS_STAT_H )
2009-02-17 13:04:24 +01:00
CHECK_INCLUDE_FILES ( sys/wait.h HAVE_SYS_WAIT_H )
CHECK_INCLUDE_FILES ( sys/param.h HAVE_SYS_PARAM_H )
CHECK_INCLUDE_FILES ( sys/cdefs.h HAVE_SYS_CDEFS_H )
2009-03-24 16:38:11 +01:00
CHECK_INCLUDE_FILES ( sys/file.h HAVE_SYS_FILE_H )
2010-12-15 20:10:42 +01:00
CHECK_INCLUDE_FILES ( sys/utsname.h HAVE_SYS_UTSNAME_H )
2009-04-15 14:30:06 +02:00
CHECK_INCLUDE_FILES ( sys/resource.h HAVE_SYS_RESOURCE_H )
2009-02-16 17:50:18 +01:00
CHECK_INCLUDE_FILES ( netinet/in.h HAVE_NETINET_IN_H )
CHECK_INCLUDE_FILES ( arpa/inet.h HAVE_ARPA_INET_H )
CHECK_INCLUDE_FILES ( netdb.h HAVE_NETDB_H )
CHECK_INCLUDE_FILES ( syslog.h HAVE_SYSLOG_H )
2011-10-24 17:30:43 +02:00
CHECK_INCLUDE_FILES ( siginfo.h HAVE_SIGINFO_H )
2009-03-19 10:25:14 +01:00
CHECK_INCLUDE_FILES ( locale.h HAVE_LOCALE_H )
2009-02-24 18:16:53 +01:00
CHECK_INCLUDE_FILES ( libgen.h HAVE_LIBGEN_H )
2010-08-13 16:50:29 +02:00
CHECK_INCLUDE_FILES ( search.h HAVE_SEARCH_H )
2009-03-03 16:56:10 +01:00
CHECK_INCLUDE_FILES ( pwd.h HAVE_PWD_H )
CHECK_INCLUDE_FILES ( grp.h HAVE_GRP_H )
2009-09-06 17:55:23 +02:00
CHECK_INCLUDE_FILES ( glob.h HAVE_GLOB_H )
2009-09-21 16:46:48 +02:00
CHECK_INCLUDE_FILES ( poll.h HAVE_POLL_H )
2010-06-10 19:47:22 +02:00
CHECK_INCLUDE_FILES ( sys/sendfile.h HAVE_SYS_SENDFILE_H )
2011-12-14 17:34:50 +01:00
CHECK_INCLUDE_FILES ( linux/falloc.h HAVE_LINUX_FALLOC_H )
2012-01-16 14:36:22 +01:00
CHECK_INCLUDE_FILES ( sys/eventfd.h HAVE_SYS_EVENTFD_H )
CHECK_INCLUDE_FILES ( aio.h HAVE_AIO_H )
CHECK_INCLUDE_FILES ( libaio.h HAVE_LIBAIO_H )
2009-02-17 13:04:24 +01:00
2011-08-08 15:20:34 +02:00
# Some dependencies
2009-02-25 12:03:42 +01:00
IF ( HAVE_SYS_WAIT_H )
LIST ( APPEND CMAKE_REQUIRED_INCLUDES sys/wait.h )
ENDIF ( HAVE_SYS_WAIT_H )
2010-06-22 15:39:03 +02:00
IF ( HAVE_TIME_H )
LIST ( APPEND CMAKE_REQUIRED_INCLUDES time.h )
ENDIF ( HAVE_TIME_H )
2011-03-23 15:42:33 +01:00
IF ( HAVE_SYS_TIME_H )
LIST ( APPEND CMAKE_REQUIRED_INCLUDES sys/time.h )
ENDIF ( HAVE_SYS_TIME_H )
2009-02-25 12:03:42 +01:00
2011-08-08 15:20:34 +02:00
# Check platform API
2009-02-16 17:50:18 +01:00
CHECK_FUNCTION_EXISTS ( setproctitle HAVE_SETPROCTITLE )
CHECK_FUNCTION_EXISTS ( getpagesize HAVE_GETPAGESIZE )
CHECK_FUNCTION_EXISTS ( nanosleep HAVE_NANOSLEEP )
2009-02-25 12:03:42 +01:00
CHECK_FUNCTION_EXISTS ( vfork HAVE_VFORK )
CHECK_FUNCTION_EXISTS ( wait4 HAVE_WAIT4 )
CHECK_FUNCTION_EXISTS ( waitpid HAVE_WAITPID )
2009-10-30 16:30:51 +01:00
CHECK_FUNCTION_EXISTS ( flock HAVE_FLOCK )
2010-05-31 15:17:13 +02:00
CHECK_FUNCTION_EXISTS ( tanhl HAVE_TANHL )
2013-06-09 16:47:34 +02:00
CHECK_FUNCTION_EXISTS ( expl HAVE_EXPL )
2013-06-10 14:20:45 +02:00
CHECK_FUNCTION_EXISTS ( exp2l HAVE_EXP2L )
2010-06-10 19:47:22 +02:00
CHECK_FUNCTION_EXISTS ( sendfile HAVE_SENDFILE )
2010-06-18 20:07:28 +02:00
CHECK_FUNCTION_EXISTS ( mkstemp HAVE_MKSTEMP )
2011-03-23 15:42:33 +01:00
CHECK_FUNCTION_EXISTS ( setitimer HAVE_SETITIMER )
2012-04-20 18:02:28 +02:00
CHECK_FUNCTION_EXISTS ( inet_pton HAVE_INET_PTON )
2010-06-22 15:39:03 +02:00
CHECK_FUNCTION_EXISTS ( clock_gettime HAVE_CLOCK_GETTIME )
2009-02-16 17:50:18 +01:00
2012-01-16 14:36:22 +01:00
#
2011-08-08 15:20:34 +02:00
# Check macros
2009-02-16 17:50:18 +01:00
CHECK_SYMBOL_EXISTS ( PATH_MAX limits.h HAVE_PATH_MAX )
CHECK_SYMBOL_EXISTS ( MAXPATHLEN sys/param.h HAVE_MAXPATHLEN )
CHECK_SYMBOL_EXISTS ( MAP_SHARED sys/mman.h HAVE_MMAP_SHARED )
CHECK_SYMBOL_EXISTS ( MAP_ANON sys/mman.h HAVE_MMAP_ANON )
2010-02-27 16:59:05 +01:00
CHECK_SYMBOL_EXISTS ( MAP_NOCORE sys/mman.h HAVE_MMAP_NOCORE )
2011-11-17 16:34:02 +01:00
CHECK_SYMBOL_EXISTS ( O_DIRECT fcntl.h HAVE_O_DIRECT )
CHECK_SYMBOL_EXISTS ( posix_fadvise fcntl.h HAVE_FADVISE )
2011-12-14 17:34:50 +01:00
CHECK_SYMBOL_EXISTS ( posix_fallocate fcntl.h HAVE_POSIX_FALLOCATE )
CHECK_SYMBOL_EXISTS ( fallocate fcntl.h HAVE_FALLOCATE )
2011-11-17 16:34:02 +01:00
CHECK_SYMBOL_EXISTS ( fdatasync unistd.h HAVE_FDATASYNC )
2009-02-16 17:50:18 +01:00
CHECK_SYMBOL_EXISTS ( _SC_NPROCESSORS_ONLN unistd.h HAVE_SC_NPROCESSORS_ONLN )
2012-06-14 20:20:50 +02:00
CHECK_SYMBOL_EXISTS ( setbit sys/param.h PARAM_H_HAS_BITSET )
2013-06-03 00:57:19 +02:00
CHECK_SYMBOL_EXISTS ( getaddrinfo "sys/types.h;sys/socket.h;netdb.h" HAVE_GETADDRINFO )
IF ( NOT HAVE_GETADDRINFO )
MESSAGE ( FATAL_ERROR "Your system does not support getaddrinfo call, please consider upgrading it to run rspamd" )
ENDIF ( NOT HAVE_GETADDRINFO )
2011-10-24 17:30:43 +02:00
IF ( HAVE_SIGINFO_H )
CHECK_SYMBOL_EXISTS ( SA_SIGINFO "signal.h;siginfo.h" HAVE_SA_SIGINFO )
ELSE ( HAVE_SIGINFO_H )
CHECK_SYMBOL_EXISTS ( SA_SIGINFO "signal.h" HAVE_SA_SIGINFO )
ENDIF ( HAVE_SIGINFO_H )
2010-06-22 15:39:03 +02:00
2011-10-31 18:02:55 +01:00
# Some hack for libevent 2.0
CHECK_C_SOURCE_COMPILES ( " #include <event.h>
#if _EVENT_NUMERIC_VERSION < 0x02000000
#error Unsupported
#endif
i n t main ( ) { r e t u r n 0 ; } " H A V E _ L I B E V E N T 2 )
2011-10-17 13:19:38 +02:00
IF ( NOT CMAKE_SYSTEM_NAME STREQUAL "SunOS" )
2010-06-22 15:39:03 +02:00
IF ( HAVE_CLOCK_GETTIME )
CHECK_SYMBOL_EXISTS ( CLOCK_PROCESS_CPUTIME_ID time.h HAVE_CLOCK_PROCESS_CPUTIME_ID )
CHECK_SYMBOL_EXISTS ( CLOCK_VIRTUAL time.h HAVE_CLOCK_VIRTUAL )
ELSE ( HAVE_CLOCK_GETTIME )
2010-06-22 19:28:41 +02:00
CHECK_INCLUDE_FILES ( sys/timeb.h HAVE_SYS_TIMEB_H )
2010-06-22 15:39:03 +02:00
ENDIF ( HAVE_CLOCK_GETTIME )
2009-02-16 17:50:18 +01:00
2011-08-08 15:20:34 +02:00
# Check asm pause instruction
2009-06-17 18:31:42 +02:00
CHECK_C_SOURCE_COMPILES ( " #include <sys/types.h>
i n t main ( int argc, char **argv ) {
_ _ a s m __volatile ( \"pause\");
r e t u r n 0 ;
} " H A V E _ A S M _ P A U S E )
2011-10-17 13:19:38 +02:00
ENDIF ( NOT CMAKE_SYSTEM_NAME STREQUAL "SunOS" )
2009-06-17 18:31:42 +02:00
2011-08-08 15:20:34 +02:00
# Check queue.h compatibility
2009-02-17 13:04:24 +01:00
IF ( NOT HAVE_COMPATIBLE_QUEUE_H )
2009-02-16 17:50:18 +01:00
INCLUDE_DIRECTORIES ( compat )
2009-02-17 13:04:24 +01:00
ENDIF ( NOT HAVE_COMPATIBLE_QUEUE_H )
2009-02-16 17:50:18 +01:00
SET ( CONTRIBSRC "" )
2010-09-15 14:24:37 +02:00
IF ( NOT DESTDIR )
SET ( DESTDIR $ENV{ DESTDIR } )
ENDIF ( NOT DESTDIR )
2010-05-28 14:50:01 +02:00
2010-12-03 15:09:00 +01:00
# Try to detect tip version from hg
SET ( ID "unknown" )
FIND_PROGRAM ( HG "hg" )
IF ( HG )
2011-11-25 14:15:00 +01:00
EXECUTE_PROCESS ( COMMAND "${HG}" id OUTPUT_VARIABLE HG_ID ERROR_QUIET )
2010-12-03 15:09:00 +01:00
IF ( HG_ID )
STRING ( REGEX MATCH ^[0-9a-z]+ ID "${HG_ID}" )
2011-02-02 14:31:06 +01:00
ELSE ( HG_ID )
FIND_FILE ( HG_ARCH ".hg_archival.txt" "${CMAKE_CURRENT_SOURCE_DIR}" )
IF ( HG_ARCH )
FILE ( READ ${ HG_ARCH } HG_ID )
IF ( HG_ID )
STRING ( REGEX MATCH "node: [0-9a-z]+" _tmp "${HG_ID}" )
STRING ( SUBSTRING "${_tmp}" 6 12 ID )
2011-11-25 14:15:00 +01:00
ENDIF ( HG_ID )
ELSE ( HG_ARCH )
# Maybe this is git copy
FIND_PROGRAM ( GIT "git" )
IF ( GIT )
2011-11-25 15:01:10 +01:00
EXECUTE_PROCESS ( COMMAND "${GIT}" --git-dir= ${ CMAKE_SOURCE_DIR } /.git branch -v OUTPUT_VARIABLE GIT_ID ERROR_QUIET )
2011-11-25 14:15:00 +01:00
IF ( GIT_ID )
STRING ( REGEX REPLACE "^. [0-9a-z]+ ([0-9a-f]+) .*" \\1 ID "${GIT_ID}" )
ENDIF ( GIT_ID )
ENDIF ( GIT )
ENDIF ( HG_ARCH )
2010-12-03 15:09:00 +01:00
ENDIF ( HG_ID )
ELSE ( HG )
# Now check .hg_archival.txt
FIND_FILE ( HG_ARCH ".hg_archival.txt" "${CMAKE_CURRENT_SOURCE_DIR}" )
IF ( HG_ARCH )
FILE ( READ ${ HG_ARCH } HG_ID )
IF ( HG_ID )
STRING ( REGEX MATCH "node: [0-9a-z]+" _tmp "${HG_ID}" )
STRING ( SUBSTRING "${_tmp}" 6 12 ID )
ENDIF ( HG_ID )
2011-11-25 14:15:00 +01:00
ELSE ( HG_ARCH )
# Maybe this is git copy
FIND_PROGRAM ( GIT "git" )
IF ( GIT )
2011-11-25 15:01:10 +01:00
EXECUTE_PROCESS ( COMMAND "${GIT}" --git-dir= ${ CMAKE_SOURCE_DIR } /.git branch -v OUTPUT_VARIABLE GIT_ID ERROR_QUIET )
2011-11-25 14:15:00 +01:00
IF ( GIT_ID )
STRING ( REGEX REPLACE "^. [0-9a-z]+ ([0-9a-f]+) .*" \\1 ID "${GIT_ID}" )
ENDIF ( GIT_ID )
ENDIF ( GIT )
2010-12-03 15:09:00 +01:00
ENDIF ( HG_ARCH )
ENDIF ( HG )
2009-09-15 16:42:05 +02:00
################################ SOURCES SECTION ###########################
2011-07-29 18:35:00 +02:00
INCLUDE_DIRECTORIES ( "${CMAKE_SOURCE_DIR}/src" "${CMAKE_BINARY_DIR}/src" )
2011-05-10 17:15:03 +02:00
2009-02-16 17:50:18 +01:00
SET ( RSPAMDSRC src/modules.c
2009-11-06 18:31:03 +01:00
s r c / c o n t r o l l e r . c
s r c / f u z z y _ s t o r a g e . c
2012-07-26 19:50:13 +02:00
s r c / l u a _ w o r k e r . c
2009-11-06 18:31:03 +01:00
s r c / m a i n . c
2009-07-20 17:33:48 +02:00
s r c / m a p . c
2010-05-11 16:58:18 +02:00
s r c / s m t p . c
2012-03-07 17:47:55 +01:00
s r c / s m t p _ p r o x y . c
2013-01-05 17:29:26 +01:00
s r c / w e b u i . c
2009-11-06 18:31:03 +01:00
s r c / w o r k e r . c )
2009-02-16 17:50:18 +01:00
SET ( PLUGINSSRC src/plugins/surbl.c
2009-04-21 14:09:30 +02:00
s r c / p l u g i n s / r e g e x p . c
2009-06-15 17:42:28 +02:00
s r c / p l u g i n s / c h a r t a b l e . c
2009-12-04 17:46:01 +01:00
s r c / p l u g i n s / f u z z y _ c h e c k . c
2012-05-29 18:39:14 +02:00
s r c / p l u g i n s / s p f . c
s r c / p l u g i n s / d k i m _ c h e c k . c )
2012-01-16 17:59:37 +01:00
2012-05-29 18:39:14 +02:00
SET ( MODULES_LIST surbl regexp chartable fuzzy_check spf dkim )
2013-07-20 19:42:29 +02:00
SET ( WORKERS_LIST normal controller smtp smtp_proxy fuzzy lua webui )
2009-02-16 17:50:18 +01:00
2012-01-16 17:59:37 +01:00
AddModules ( MODULES_LIST WORKERS_LIST )
2011-12-09 17:13:00 +01:00
################################ SUBDIRS SECTION ###########################
2013-03-27 12:53:05 +01:00
ADD_SUBDIRECTORY ( contrib/lgpl )
2011-07-29 18:35:00 +02:00
IF ( GLIB_COMPAT )
INCLUDE_DIRECTORIES ( "${CMAKE_CURRENT_SOURCE_DIR}/contrib/lgpl" )
ENDIF ( GLIB_COMPAT )
2011-05-11 18:17:13 +02:00
2011-12-12 18:14:49 +01:00
IF ( NOT HIREDIS_FOUND )
ADD_SUBDIRECTORY ( contrib/hiredis )
INCLUDE_DIRECTORIES ( "${CMAKE_CURRENT_SOURCE_DIR}/contrib/hiredis" )
ENDIF ( NOT HIREDIS_FOUND )
2012-06-07 17:06:09 +02:00
2011-05-10 17:15:03 +02:00
ADD_SUBDIRECTORY ( src/lua )
ADD_SUBDIRECTORY ( src/json )
ADD_SUBDIRECTORY ( src/cdb )
ADD_SUBDIRECTORY ( lib )
2012-06-07 17:06:09 +02:00
2011-05-10 17:15:03 +02:00
ADD_SUBDIRECTORY ( src/client )
ADD_SUBDIRECTORY ( utils )
ADD_SUBDIRECTORY ( test )
2009-02-16 17:50:18 +01:00
LIST ( LENGTH PLUGINSSRC RSPAMD_MODULES_NUM )
2009-09-15 16:42:05 +02:00
############################ TARGETS SECTION ###############################
2011-05-11 17:11:05 +02:00
2009-02-16 17:50:18 +01:00
CONFIGURE_FILE ( config.h.in src/config.h )
2010-10-18 18:21:24 +02:00
CONFIGURE_FILE ( contrib/exim/local_scan.c.in contrib/exim/local_scan_rspamd.c @ONLY )
2011-07-15 16:56:47 +02:00
CONFIGURE_FILE ( conf/rspamd-basic.xml.in conf/rspamd.xml.sample @ONLY )
2009-02-17 13:04:24 +01:00
2009-09-15 16:42:05 +02:00
######################### LINK SECTION ###############################
2011-05-10 17:15:03 +02:00
2012-12-15 11:41:15 +01:00
ADD_EXECUTABLE ( rspamd ${ RSPAMDSRC } ${ CONTRIBSRC } ${ PLUGINSSRC } )
2009-02-16 17:50:18 +01:00
SET_TARGET_PROPERTIES ( rspamd PROPERTIES LINKER_LANGUAGE C )
2009-08-25 11:50:35 +02:00
SET_TARGET_PROPERTIES ( rspamd PROPERTIES COMPILE_FLAGS "-DRSPAMD_MAIN" )
2012-08-03 15:04:03 +02:00
IF ( NOT DEBIAN_BUILD )
2009-02-16 17:50:18 +01:00
SET_TARGET_PROPERTIES ( rspamd PROPERTIES VERSION ${ RSPAMD_VERSION } )
2012-08-03 15:04:03 +02:00
ENDIF ( NOT DEBIAN_BUILD )
2009-03-27 12:21:27 +01:00
2012-06-05 16:21:49 +02:00
TARGET_LINK_LIBRARIES ( rspamd rspamd-mime )
TARGET_LINK_LIBRARIES ( rspamd rspamd-server )
TARGET_LINK_LIBRARIES ( rspamd rspamd-util )
TARGET_LINK_LIBRARIES ( rspamd rspamd-lua )
2011-05-10 17:15:03 +02:00
2010-03-18 17:43:55 +01:00
IF ( LIBJUDY_LIBRARY )
2010-03-22 16:41:35 +01:00
TARGET_LINK_LIBRARIES ( rspamd Judy )
2010-03-18 17:43:55 +01:00
ENDIF ( LIBJUDY_LIBRARY )
2012-06-05 16:21:49 +02:00
2009-02-16 17:50:18 +01:00
TARGET_LINK_LIBRARIES ( rspamd event )
2011-10-31 18:02:55 +01:00
IF ( HAVE_LIBEVENT2 )
TARGET_LINK_LIBRARIES ( rspamd event_pthreads )
ENDIF ( HAVE_LIBEVENT2 )
2012-06-05 17:22:57 +02:00
IF ( WITH_DB )
TARGET_LINK_LIBRARIES ( rspamd db )
ENDIF ( WITH_DB )
IF ( SQLITE_LIBRARIES )
TARGET_LINK_LIBRARIES ( rspamd ${ SQLITE_LIBRARIES } )
ENDIF ( SQLITE_LIBRARIES )
2011-05-10 17:15:03 +02:00
2012-06-05 17:22:57 +02:00
IF ( OPENSSL_FOUND )
TARGET_LINK_LIBRARIES ( rspamd ${ OPENSSL_LIBRARIES } )
ENDIF ( OPENSSL_FOUND )
TARGET_LINK_LIBRARIES ( rspamd ${ PCRE_LIBRARIES } )
IF ( GMIME24 )
TARGET_LINK_LIBRARIES ( rspamd ${ GMIME24_LIBRARIES } )
ELSE ( GMIME24 )
TARGET_LINK_LIBRARIES ( rspamd ${ GMIME2_LIBRARIES } )
ENDIF ( GMIME24 )
TARGET_LINK_LIBRARIES ( rspamd ${ GLIB2_LIBRARIES } )
2010-06-23 12:45:33 +02:00
TARGET_LINK_LIBRARIES ( rspamd ${ CMAKE_REQUIRED_LIBRARIES } )
2012-01-16 14:36:22 +01:00
2010-02-19 16:13:54 +01:00
IF ( ENABLE_STATIC MATCHES "ON" )
TARGET_LINK_LIBRARIES ( rspamd ${ PCRE_LIBRARIES } )
2012-06-05 17:22:57 +02:00
TARGET_LINK_LIBRARIES ( rspamd "z" )
2010-02-19 16:13:54 +01:00
ENDIF ( ENABLE_STATIC MATCHES "ON" )
2009-02-17 13:04:24 +01:00
2011-11-02 17:53:18 +01:00
IF ( ENABLE_LUAJIT MATCHES "ON" )
TARGET_LINK_LIBRARIES ( rspamd "${LUAJIT_LIBRARY}" )
ELSE ( ENABLE_LUAJIT MATCHES "ON" )
TARGET_LINK_LIBRARIES ( rspamd "${LUA_LIBRARY}" )
ENDIF ( ENABLE_LUAJIT MATCHES "ON" )
2009-05-04 14:39:35 +02:00
IF ( ENABLE_GPERF_TOOLS MATCHES "ON" )
TARGET_LINK_LIBRARIES ( rspamd profiler )
ENDIF ( ENABLE_GPERF_TOOLS MATCHES "ON" )
2012-06-05 16:21:49 +02:00
TARGET_LINK_LIBRARIES ( rspamd hiredis )
2011-07-29 18:35:00 +02:00
IF ( GLIB_COMPAT )
TARGET_LINK_LIBRARIES ( rspamd glibadditions )
ENDIF ( GLIB_COMPAT )
2009-04-27 17:03:11 +02:00
2009-09-15 16:42:05 +02:00
##################### INSTALLATION ##########################################
2009-06-24 15:09:57 +02:00
2009-09-15 16:42:05 +02:00
# Binaries
2011-02-02 14:16:51 +01:00
INSTALL ( TARGETS rspamd RUNTIME DESTINATION bin )
2009-09-15 16:42:05 +02:00
# Configs
2011-07-29 23:14:03 +02:00
INSTALL ( CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${ETC_PREFIX}/rspamd)" )
2009-09-15 16:42:05 +02:00
2013-05-26 21:26:26 +02:00
INSTALL ( FILES conf/2tld.inc RENAME 2tld.inc DESTINATION ${ ETC_PREFIX } /rspamd )
2011-10-17 13:24:28 +02:00
IF ( NOT EXISTS ${ ETC_PREFIX } /rspamd/2tld.inc OR BUILD_PORT )
2011-07-29 23:34:24 +02:00
INSTALL ( FILES conf/2tld.inc DESTINATION ${ ETC_PREFIX } /rspamd )
2011-10-17 13:24:28 +02:00
ENDIF ( NOT EXISTS ${ ETC_PREFIX } /rspamd/2tld.inc OR BUILD_PORT )
2009-09-15 16:42:05 +02:00
2011-07-29 23:34:24 +02:00
INSTALL ( FILES conf/surbl-whitelist.inc RENAME surbl-whitelist.inc DESTINATION ${ ETC_PREFIX } /rspamd )
2011-10-17 13:24:28 +02:00
IF ( NOT EXISTS ${ ETC_PREFIX } /rspamd/surbl-whitelist.inc OR BUILD_PORT )
2011-07-29 23:34:24 +02:00
INSTALL ( FILES conf/surbl-whitelist.inc DESTINATION ${ ETC_PREFIX } /rspamd )
2011-10-17 13:24:28 +02:00
ENDIF ( NOT EXISTS ${ ETC_PREFIX } /rspamd/surbl-whitelist.inc OR BUILD_PORT )
2011-02-14 00:49:59 +01:00
2013-02-02 20:27:55 +01:00
IF ( NOT DEBIAN_BUILD )
INSTALL ( FILES ${ CMAKE_BINARY_DIR } /conf/rspamd.xml.sample DESTINATION ${ ETC_PREFIX } )
ENDIF ( NOT DEBIAN_BUILD )
2009-09-15 16:42:05 +02:00
# Lua plugins
2011-07-29 23:14:03 +02:00
INSTALL ( CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${ETC_PREFIX}/rspamd/plugins/lua)" )
2010-07-19 09:57:45 +02:00
FILE ( GLOB LUA_PLUGINS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/lua" "${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/lua/*.lua" )
2010-07-19 15:12:09 +02:00
FOREACH ( LUA_PLUGIN ${ LUA_PLUGINS } )
2010-07-19 09:57:45 +02:00
GET_FILENAME_COMPONENT ( _rp ${ LUA_PLUGIN } PATH )
2011-07-29 23:14:03 +02:00
INSTALL ( CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${ETC_PREFIX}/rspamd/plugins/lua/${_rp})" )
2011-07-29 23:34:24 +02:00
INSTALL ( FILES "src/plugins/lua/${LUA_PLUGIN}" DESTINATION ${ ETC_PREFIX } /rspamd/plugins/lua/ ${ _rp } )
2010-07-19 09:57:45 +02:00
ENDFOREACH ( LUA_PLUGIN )
2009-09-15 16:42:05 +02:00
2010-05-06 16:40:37 +02:00
# Lua config
2011-07-29 23:14:03 +02:00
INSTALL ( CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${ETC_PREFIX}/rspamd/lua)" )
2010-07-19 09:57:45 +02:00
FILE ( GLOB_RECURSE LUA_CONFIGS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/conf/lua" "${CMAKE_CURRENT_SOURCE_DIR}/conf/lua/*.lua" )
2010-07-19 15:12:09 +02:00
FOREACH ( LUA_CONF ${ LUA_CONFIGS } )
2010-07-19 09:57:45 +02:00
GET_FILENAME_COMPONENT ( _rp ${ LUA_CONF } PATH )
2011-07-29 23:14:03 +02:00
INSTALL ( CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${ETC_PREFIX}/rspamd/lua/${_rp})" )
2012-05-28 15:33:54 +02:00
INSTALL ( FILES "conf/lua/${LUA_CONF}" DESTINATION ${ ETC_PREFIX } /rspamd/lua/ ${ _rp } )
2010-07-19 09:57:45 +02:00
ENDFOREACH ( LUA_CONF )
2010-05-06 16:40:37 +02:00
2011-02-07 16:53:55 +01:00
# Manual pages
2011-07-29 23:34:24 +02:00
INSTALL ( FILES "doc/rspamd.8" DESTINATION ${ MAN_PREFIX } /man8 )
INSTALL ( FILES "doc/rspamc.1" DESTINATION ${ MAN_PREFIX } /man1 )
2011-02-07 16:53:55 +01:00
2009-09-15 16:42:05 +02:00
# Start scripts
2010-10-01 17:01:28 +02:00
IF ( CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND NOT BUILD_PORT )
2011-07-29 23:34:24 +02:00
INSTALL ( PROGRAMS ${ CMAKE_BINARY_DIR } /freebsd/rspamd DESTINATION ${ ETC_PREFIX } /rc.d )
2009-03-03 16:56:10 +01:00
IF ( ENABLE_REDIRECTOR MATCHES "ON" )
2011-07-29 23:34:24 +02:00
INSTALL ( PROGRAMS ${ CMAKE_BINARY_DIR } /freebsd/redirector DESTINATION ${ ETC_PREFIX } /rc.d )
2009-03-03 16:56:10 +01:00
ENDIF ( ENABLE_REDIRECTOR MATCHES "ON" )
2011-08-08 15:20:34 +02:00
INSTALL ( CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}/${LOCALSTATES_PREFIX})" )
INSTALL ( CODE "EXECUTE_PROCESS(COMMAND chown ${RSPAMD_USER}:${RSPAMD_GROUP} \$ENV{DESTDIR}/${LOCALSTATES_PREFIX})" )
2010-10-01 17:01:28 +02:00
ENDIF ( CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND NOT BUILD_PORT )
2013-02-02 20:27:55 +01:00
IF ( CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT DEBIAN_BUILD )
2011-07-29 23:34:24 +02:00
INSTALL ( PROGRAMS "linux/${LINUX_START_SCRIPT}" DESTINATION ${ ETC_PREFIX } /init.d RENAME rspamd )
2011-08-08 15:20:34 +02:00
INSTALL ( CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}/${LOCALSTATES_PREFIX})" )
INSTALL ( CODE "EXECUTE_PROCESS(COMMAND chown ${RSPAMD_USER}:${RSPAMD_GROUP} \$ENV{DESTDIR}/${LOCALSTATES_PREFIX})" )
2013-02-02 20:27:55 +01:00
ENDIF ( CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT DEBIAN_BUILD )