2009-02-16 17:50:18 +01:00
|
|
|
#
|
2015-02-03 13:53:18 +01:00
|
|
|
# Rspamd - rapid antispam system
|
2009-02-16 17:50:18 +01:00
|
|
|
#
|
|
|
|
# Cmake configuration file
|
|
|
|
#
|
2012-01-16 17:59:37 +01:00
|
|
|
|
|
|
|
############################# INITIAL SECTION #############################################
|
2015-07-08 14:41:14 +02:00
|
|
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0 FATAL_ERROR)
|
2012-01-16 17:59:37 +01:00
|
|
|
|
2009-02-16 17:50:18 +01:00
|
|
|
PROJECT(rspamd C)
|
2015-02-14 00:45:06 +01:00
|
|
|
ENABLE_LANGUAGE(ASM)
|
2009-02-16 17:50:18 +01:00
|
|
|
|
2015-07-03 13:52:00 +02:00
|
|
|
SET(RSPAMD_VERSION_MAJOR 1)
|
2017-07-08 10:52:41 +02:00
|
|
|
SET(RSPAMD_VERSION_MINOR 7)
|
2018-06-15 18:54:21 +02:00
|
|
|
SET(RSPAMD_VERSION_PATCH 7)
|
2010-12-03 15:09:00 +01:00
|
|
|
|
2016-02-12 14:34:17 +01:00
|
|
|
# Keep two digits all the time
|
|
|
|
SET(RSPAMD_VERSION_MAJOR_NUM ${RSPAMD_VERSION_MAJOR}0)
|
|
|
|
SET(RSPAMD_VERSION_MINOR_NUM ${RSPAMD_VERSION_MINOR}0)
|
|
|
|
SET(RSPAMD_VERSION_PATCH_NUM ${RSPAMD_VERSION_PATCH}0)
|
|
|
|
|
2015-12-18 15:24:01 +01:00
|
|
|
IF(GIT_ID)
|
|
|
|
SET(GIT_VERSION 1)
|
|
|
|
SET(RSPAMD_ID "${GIT_ID}")
|
|
|
|
ENDIF()
|
|
|
|
|
2009-02-16 17:50:18 +01:00
|
|
|
SET(RSPAMD_VERSION "${RSPAMD_VERSION_MAJOR}.${RSPAMD_VERSION_MINOR}.${RSPAMD_VERSION_PATCH}")
|
2013-12-04 14:41:26 +01:00
|
|
|
SET(RSPAMD_MASTER_SITE_URL "https://rspamd.com")
|
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
|
|
|
|
2015-03-11 23:25:26 +01:00
|
|
|
# Default for SysV Init
|
|
|
|
SET(RSPAMD_WORKER_NORMAL "*:11333")
|
|
|
|
SET(RSPAMD_WORKER_CONTROLLER "*:11334")
|
2014-12-17 18:28:07 +01:00
|
|
|
SET_PROPERTY(GLOBAL PROPERTY ALLOW_DUPLICATE_CUSTOM_TARGETS 1)
|
2009-02-16 17:50:18 +01:00
|
|
|
|
2012-01-16 17:59:37 +01:00
|
|
|
############################# OPTIONS SECTION #############################################
|
|
|
|
|
2015-07-21 13:28:36 +02:00
|
|
|
OPTION(ENABLE_OPTIMIZATION "Enable extra optimizations [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-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)
|
2015-02-18 16:56:25 +01:00
|
|
|
OPTION(ENABLE_LUAJIT "Link with libluajit [default: ON]" ON)
|
2013-06-07 16:37:24 +02:00
|
|
|
OPTION(ENABLE_DB "Find and link with DB library [default: OFF]" OFF)
|
|
|
|
OPTION(ENABLE_SQLITE "Find and link with sqlite3 library [default: OFF]" OFF)
|
2015-02-18 16:35:14 +01:00
|
|
|
OPTION(ENABLE_HIREDIS "Find and link with external redis library [default: ON]" ON)
|
2013-12-26 16:28:02 +01:00
|
|
|
OPTION(ENABLE_URL_INCLUDE "Enable urls in ucl includes (requires libcurl or libfetch) [default: OFF]" OFF)
|
2015-02-08 23:21:43 +01:00
|
|
|
OPTION(NO_SHARED "Build internal libs static [default: ON]" ON)
|
2013-12-04 18:13:38 +01:00
|
|
|
OPTION(INSTALL_EXAMPLES "Install examples [default: OFF]" OFF)
|
2014-09-01 12:37:28 +02:00
|
|
|
OPTION(INSTALL_WEBUI "Install web interface [default: ON]" ON)
|
2015-03-13 12:11:58 +01:00
|
|
|
OPTION(WANT_SYSTEMD_UNITS "Install systemd unit files on Linux [default: OFF]" OFF)
|
2015-10-23 12:51:53 +02:00
|
|
|
OPTION(ENABLE_SNOWBALL "Enable snowball stemmer [default: ON]" ON)
|
2015-11-09 19:51:25 +01:00
|
|
|
OPTION(ENABLE_CLANG_PLUGIN "Enable clang static analysing plugin [default: OFF]" OFF)
|
2015-12-07 15:29:25 +01:00
|
|
|
OPTION(ENABLE_HYPERSCAN "Enable hyperscan for fast regexp processing [default: OFF]" OFF)
|
2018-03-08 15:05:56 +01:00
|
|
|
OPTION(ENABLE_FANN "Enable fann for neural network plugin [default: OFF]" OFF)
|
2016-02-09 12:26:16 +01:00
|
|
|
OPTION(ENABLE_PCRE2 "Enable pcre2 instead of pcre [default: OFF]" OFF)
|
2017-06-05 11:14:47 +02:00
|
|
|
OPTION(ENABLE_GD "Enable libgd for images processing [default: OFF]" OFF)
|
2016-04-11 12:23:47 +02:00
|
|
|
OPTION(ENABLE_JEMALLOC "Build rspamd with jemalloc allocator [default: OFF]" OFF)
|
2016-08-02 16:18:29 +02:00
|
|
|
OPTION(ENABLE_COVERAGE "Build rspamd with code coverage options [default: OFF]" OFF)
|
2016-12-25 17:23:02 +01:00
|
|
|
OPTION(ENABLE_FULL_DEBUG "Build rspamd with all possible debug [default: OFF]" OFF)
|
2017-01-23 14:53:49 +01:00
|
|
|
OPTION(ENABLE_UTILS "Build rspamd internal utils [default: OFF]" OFF)
|
2018-03-01 15:22:51 +01:00
|
|
|
OPTION(ENABLE_TORCH "Install torch7 with Rspamd [default: ON]" ON)
|
2018-06-18 18:41:47 +02:00
|
|
|
OPTION(ENABLE_LIBUNWIND "Use libunwind to print crash traces [default: OFF]" OFF)
|
2015-12-07 16:24:41 +01:00
|
|
|
|
2015-12-20 22:23:16 +01:00
|
|
|
INCLUDE(FindArch.cmake)
|
|
|
|
TARGET_ARCHITECTURE(ARCH)
|
|
|
|
|
2016-06-14 21:17:15 +02:00
|
|
|
INCLUDE(FindRagel.cmake)
|
|
|
|
IF(NOT RAGEL_FOUND)
|
|
|
|
MESSAGE(FATAL_ERROR "Ragel is required to build rspamd")
|
|
|
|
ENDIF()
|
|
|
|
|
2018-03-02 16:27:38 +01:00
|
|
|
IF (NOT "${ARCH}" STREQUAL "x86_64")
|
2015-12-20 22:23:16 +01:00
|
|
|
MESSAGE(STATUS "Hyperscan support is possible only for x86_64 architecture")
|
|
|
|
SET(ENABLE_HYPERSCAN "OFF")
|
2015-12-07 16:24:41 +01:00
|
|
|
ENDIF()
|
2016-02-09 12:26:16 +01:00
|
|
|
|
|
|
|
IF(ENABLE_PCRE2 MATCHES "ON")
|
|
|
|
SET(WITH_PCRE2 1)
|
|
|
|
# For utf8 API
|
|
|
|
LIST(APPEND CMAKE_REQUIRED_DEFINITIONS "-DPCRE2_CODE_UNIT_WIDTH=8")
|
|
|
|
ENDIF()
|
2009-02-16 17:50:18 +01:00
|
|
|
# Build optimized code for following CPU (default i386)
|
|
|
|
#SET(CPU_TUNE "i686")
|
|
|
|
|
2013-11-19 17:17:13 +01:00
|
|
|
# Now CMAKE_INSTALL_PREFIX is a base prefix for everything
|
|
|
|
# CONFDIR - for configuration
|
2016-03-10 18:35:49 +01:00
|
|
|
# LOCAL_CONFDIR - for local configuration
|
2013-11-19 17:17:13 +01:00
|
|
|
# MANDIR - for manual pages
|
|
|
|
# RUNDIR - for runtime files
|
|
|
|
# DBDIR - for static files
|
|
|
|
# LOGDIR - for log files
|
|
|
|
# EXAMPLESDIR - for examples files
|
|
|
|
|
|
|
|
IF(NOT CONFDIR)
|
|
|
|
SET(CONFDIR "${CMAKE_INSTALL_PREFIX}/etc/rspamd")
|
|
|
|
ENDIF(NOT CONFDIR)
|
|
|
|
|
2016-03-10 18:35:49 +01:00
|
|
|
IF(NOT LOCAL_CONFDIR)
|
|
|
|
SET(LOCAL_CONFDIR "${CONFDIR}")
|
|
|
|
ENDIF(NOT LOCAL_CONFDIR)
|
|
|
|
|
2013-11-19 17:17:13 +01:00
|
|
|
IF(NOT MANDIR)
|
|
|
|
SET(MANDIR "${CMAKE_INSTALL_PREFIX}/share/man")
|
|
|
|
ENDIF(NOT MANDIR)
|
|
|
|
|
|
|
|
IF(NOT RUNDIR)
|
2016-01-16 22:07:26 +01:00
|
|
|
SET(RUNDIR "/var/run/rspamd")
|
2013-11-19 17:17:13 +01:00
|
|
|
ENDIF(NOT RUNDIR)
|
|
|
|
|
|
|
|
IF(NOT DBDIR)
|
2016-01-16 22:07:26 +01:00
|
|
|
SET(DBDIR "/var/lib/rspamd")
|
2013-11-19 17:17:13 +01:00
|
|
|
ENDIF(NOT DBDIR)
|
|
|
|
|
|
|
|
IF(NOT LOGDIR)
|
2016-01-16 22:07:26 +01:00
|
|
|
SET(LOGDIR "/var/log/rspamd")
|
2013-11-19 17:17:13 +01:00
|
|
|
ENDIF(NOT LOGDIR)
|
|
|
|
|
|
|
|
IF(NOT EXAMPLESDIR)
|
|
|
|
SET(EXAMPLESDIR "${CMAKE_INSTALL_PREFIX}/share/examples/rspamd")
|
|
|
|
ENDIF(NOT EXAMPLESDIR)
|
|
|
|
|
|
|
|
IF(NOT PLUGINSDIR)
|
|
|
|
SET(PLUGINSDIR "${CMAKE_INSTALL_PREFIX}/share/rspamd")
|
|
|
|
ENDIF(NOT PLUGINSDIR)
|
|
|
|
|
2015-08-07 15:40:05 +02:00
|
|
|
IF(NOT RULESDIR)
|
|
|
|
SET(RULESDIR "${PLUGINSDIR}/rules")
|
|
|
|
ENDIF(NOT RULESDIR)
|
|
|
|
|
2017-05-18 17:04:23 +02:00
|
|
|
IF(NOT LUALIBDIR)
|
|
|
|
SET(LUALIBDIR "${PLUGINSDIR}/lib")
|
|
|
|
ENDIF(NOT LUALIBDIR)
|
|
|
|
|
2014-04-24 19:15:33 +02:00
|
|
|
IF(NOT WWWDIR)
|
|
|
|
SET(WWWDIR "${CMAKE_INSTALL_PREFIX}/share/rspamd/www")
|
|
|
|
ENDIF(NOT WWWDIR)
|
|
|
|
|
2013-11-21 15:55:00 +01:00
|
|
|
# Set libdir
|
|
|
|
IF(NOT LIBDIR)
|
2015-04-24 22:21:39 +02:00
|
|
|
SET(RSPAMD_LIBDIR "${CMAKE_INSTALL_PREFIX}/lib/rspamd")
|
|
|
|
ELSE(NOT LIBDIR)
|
2015-04-28 18:01:00 +02:00
|
|
|
SET(RSPAMD_LIBDIR "${LIBDIR}")
|
2013-11-21 15:55:00 +01:00
|
|
|
ENDIF(NOT LIBDIR)
|
2015-04-26 22:09:40 +02:00
|
|
|
SET(CMAKE_MACOSX_RPATH ON)
|
2015-04-24 22:21:39 +02:00
|
|
|
SET(CMAKE_INSTALL_RPATH "${RSPAMD_LIBDIR}")
|
2015-04-24 18:08:04 +02:00
|
|
|
|
2013-11-21 15:55:00 +01:00
|
|
|
# Set includedir
|
|
|
|
IF(NOT INCLUDEDIR)
|
|
|
|
SET(INCLUDEDIR include/rspamd)
|
|
|
|
ENDIF(NOT INCLUDEDIR)
|
|
|
|
|
2014-03-28 15:51:16 +01:00
|
|
|
IF(NOT SYSTEMDDIR)
|
|
|
|
SET(SYSTEMDDIR ${CMAKE_INSTALL_PREFIX}/lib/systemd/system)
|
|
|
|
ENDIF(NOT SYSTEMDDIR)
|
|
|
|
|
2015-05-11 14:43:16 +02:00
|
|
|
SET(RSPAMD_DEFAULT_INCLUDE_PATHS "/opt;/usr;/usr/local;/opt/local;/usr/pkg;/opt/csw;/sw")
|
2015-07-08 14:41:14 +02:00
|
|
|
SET(RSPAMD_DEFAULT_LIBRARY_PATHS "/usr/local;/usr/pkg;/usr;/Library/Frameworks;/sw;/opt/local;/opt/csw;/opt")
|
2015-03-13 12:11:58 +01:00
|
|
|
|
2015-10-21 14:05:10 +02:00
|
|
|
IF(ENABLE_STATIC MATCHES "ON")
|
|
|
|
MESSAGE(STATUS "Static build of rspamd implies that the target binary will be *GPL* licensed")
|
|
|
|
SET(GPL_RSPAMD_BINARY 1)
|
2016-07-22 14:51:04 +02:00
|
|
|
SET(CMAKE_SKIP_INSTALL_RPATH ON)
|
2015-10-21 14:05:10 +02:00
|
|
|
SET(BUILD_STATIC 1)
|
|
|
|
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
|
|
|
SET(BUILD_SHARED_LIBRARIES OFF)
|
|
|
|
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
|
|
|
|
SET(LINK_TYPE "STATIC")
|
|
|
|
SET(NO_SHARED "ON")
|
2015-10-21 14:17:34 +02:00
|
|
|
# Dirty hack for cmake
|
|
|
|
SET(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS) # remove -Wl,-Bdynamic
|
|
|
|
SET(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS)
|
|
|
|
SET(CMAKE_SHARED_LIBRARY_C_FLAGS) # remove -fPIC
|
|
|
|
SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS)
|
|
|
|
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS) # remove -rdynamic
|
|
|
|
SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
|
2015-10-21 14:05:10 +02:00
|
|
|
ELSE(ENABLE_STATIC MATCHES "ON")
|
|
|
|
IF (NO_SHARED MATCHES "OFF")
|
|
|
|
SET(LINK_TYPE "SHARED")
|
|
|
|
ELSE(NO_SHARED MATCHES "OFF")
|
|
|
|
SET(LINK_TYPE "STATIC")
|
|
|
|
ENDIF (NO_SHARED MATCHES "OFF")
|
|
|
|
ENDIF (ENABLE_STATIC MATCHES "ON")
|
|
|
|
|
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)
|
2015-11-23 10:10:12 +01:00
|
|
|
INCLUDE(CheckCSourceRuns)
|
2009-02-16 17:50:18 +01:00
|
|
|
INCLUDE(CheckLibraryExists)
|
2009-08-06 17:54:06 +02:00
|
|
|
INCLUDE(CheckCCompilerFlag)
|
2015-07-07 17:45:58 +02:00
|
|
|
INCLUDE(CMakeParseArguments)
|
2009-03-27 12:21:27 +01:00
|
|
|
|
2015-07-08 14:41:14 +02:00
|
|
|
FIND_PACKAGE(PkgConfig REQUIRED)
|
2015-12-15 15:36:12 +01:00
|
|
|
FIND_PACKAGE(Perl REQUIRED)
|
2015-07-08 14:41:14 +02:00
|
|
|
|
2014-04-21 17:25:51 +02:00
|
|
|
############################# MACRO SECTION #############################################
|
2012-01-16 17:59:37 +01:00
|
|
|
|
2013-12-26 16:28:02 +01:00
|
|
|
# Find lua installation
|
2015-07-07 17:45:58 +02:00
|
|
|
MACRO(FindLua)
|
2013-09-24 23:19:09 +02:00
|
|
|
# Find lua libraries
|
2015-02-18 18:31:40 +01:00
|
|
|
UNSET(LUA_INCLUDE_DIR CACHE)
|
2015-05-12 14:24:03 +02:00
|
|
|
UNSET(LUA_LIBRARY CACHE)
|
2015-07-07 17:45:58 +02:00
|
|
|
CMAKE_PARSE_ARGUMENTS(LUA "" "VERSION_MAJOR;VERSION_MINOR;ROOT" "" ${ARGN})
|
|
|
|
|
|
|
|
IF(NOT LUA_VERSION_MAJOR OR NOT LUA_VERSION_MINOR)
|
|
|
|
MESSAGE(FATAL_ERROR "Invalid FindLua invocation: ${ARGN}")
|
|
|
|
ENDIF()
|
|
|
|
|
2015-05-12 13:10:42 +02:00
|
|
|
IF(ENABLE_LUAJIT MATCHES "ON")
|
2015-07-07 17:45:58 +02:00
|
|
|
MESSAGE(STATUS "Check for luajit ${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}")
|
2015-09-01 15:37:58 +02:00
|
|
|
FIND_PATH(LUA_INCLUDE_DIR luajit.h
|
2015-05-12 14:24:03 +02:00
|
|
|
HINTS
|
2015-07-07 17:45:58 +02:00
|
|
|
"${RSPAMD_SEARCH_PATH}" "${LUA_ROOT}"
|
2015-05-12 14:24:03 +02:00
|
|
|
$ENV{LUA_DIR}
|
2015-11-09 19:51:25 +01:00
|
|
|
PATH_SUFFIXES "include/luajit-2.0"
|
2016-10-25 15:15:50 +02:00
|
|
|
"include/luajit-2.1"
|
2015-11-09 19:51:25 +01:00
|
|
|
"include/luajit${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}"
|
|
|
|
"include/luajit${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
|
2015-07-07 17:45:58 +02:00
|
|
|
"include/luajit-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
|
2016-11-29 11:23:28 +01:00
|
|
|
"include/luajit-${LUA_VERSION_MAJOR}_${LUA_VERSION_MINOR}-2.0"
|
|
|
|
"include/luajit-${LUA_VERSION_MAJOR}_${LUA_VERSION_MINOR}-2.1"
|
2015-11-09 19:51:25 +01:00
|
|
|
"include/luajit"
|
|
|
|
"include/lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}"
|
|
|
|
"include/lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
|
2015-07-07 17:45:58 +02:00
|
|
|
"include/lua-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
|
|
|
|
include/lua include
|
2015-05-12 14:24:03 +02:00
|
|
|
PATHS ${RSPAMD_DEFAULT_INCLUDE_PATHS}
|
|
|
|
)
|
2015-11-09 19:51:25 +01:00
|
|
|
FIND_LIBRARY(LUA_LIBRARY
|
|
|
|
NAMES luajit
|
2015-07-07 17:45:58 +02:00
|
|
|
"luajit-2.0"
|
|
|
|
"luajit2.0"
|
|
|
|
"luajit${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}"
|
2015-11-09 19:51:25 +01:00
|
|
|
"luajit${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
|
2015-07-07 17:45:58 +02:00
|
|
|
"luajit-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
|
2015-05-12 13:10:42 +02:00
|
|
|
HINTS
|
2015-07-07 17:45:58 +02:00
|
|
|
"${RSPAMD_SEARCH_PATH}" "${LUA_ROOT}"
|
|
|
|
$ENV{LUA_DIR}
|
|
|
|
PATH_SUFFIXES lib64 lib
|
|
|
|
PATHS ${RSPAMD_DEFAULT_LIBRARY_PATHS}
|
|
|
|
DOC "Lua library"
|
2015-05-12 13:10:42 +02:00
|
|
|
)
|
2015-11-09 19:51:25 +01:00
|
|
|
|
2015-05-19 14:51:50 +02:00
|
|
|
IF(NOT LUA_LIBRARY OR NOT LUA_INCLUDE_DIR)
|
|
|
|
MESSAGE(STATUS "Fallback from luajit to plain lua")
|
|
|
|
SET(ENABLE_LUAJIT "OFF")
|
2015-07-07 17:45:58 +02:00
|
|
|
MESSAGE(STATUS "Check for lua ${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}")
|
2015-05-19 14:51:50 +02:00
|
|
|
FIND_PATH(LUA_INCLUDE_DIR lua.h
|
|
|
|
HINTS
|
2015-07-07 17:45:58 +02:00
|
|
|
"${RSPAMD_SEARCH_PATH}" "${LUA_ROOT}"
|
2015-05-19 14:51:50 +02:00
|
|
|
$ENV{LUA_DIR}
|
2015-11-09 19:51:25 +01:00
|
|
|
PATH_SUFFIXES "include/lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}"
|
|
|
|
"include/lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
|
2015-07-07 17:45:58 +02:00
|
|
|
"include/lua-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
|
|
|
|
include/lua include
|
2015-05-19 14:51:50 +02:00
|
|
|
PATHS ${RSPAMD_DEFAULT_INCLUDE_PATHS}
|
|
|
|
)
|
2015-11-09 19:51:25 +01:00
|
|
|
FIND_LIBRARY(LUA_LIBRARY
|
|
|
|
NAMES lua
|
2015-07-07 17:45:58 +02:00
|
|
|
"lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}"
|
2015-11-09 19:51:25 +01:00
|
|
|
"lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
|
2015-07-07 17:45:58 +02:00
|
|
|
"lua-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
|
2015-05-19 14:51:50 +02:00
|
|
|
HINTS
|
2015-07-07 17:45:58 +02:00
|
|
|
"${RSPAMD_SEARCH_PATH}" "${LUA_ROOT}"
|
|
|
|
$ENV{LUA_DIR}
|
|
|
|
PATH_SUFFIXES lib64 lib
|
|
|
|
PATHS ${RSPAMD_DEFAULT_LIBRARY_PATHS}
|
|
|
|
DOC "Lua library"
|
2015-05-19 14:51:50 +02:00
|
|
|
)
|
2016-05-09 11:11:33 +02:00
|
|
|
ELSE()
|
|
|
|
SET(WITH_LUAJIT 1)
|
2015-05-19 14:51:50 +02:00
|
|
|
ENDIF()
|
2015-05-12 13:10:42 +02:00
|
|
|
ELSE(ENABLE_LUAJIT MATCHES "ON")
|
2015-07-07 17:45:58 +02:00
|
|
|
MESSAGE(STATUS "Check for lua ${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}")
|
2015-05-12 14:24:03 +02:00
|
|
|
FIND_PATH(LUA_INCLUDE_DIR lua.h
|
|
|
|
HINTS
|
2015-07-07 17:45:58 +02:00
|
|
|
"${RSPAMD_SEARCH_PATH}" "${LUA_ROOT}"
|
2015-05-12 14:24:03 +02:00
|
|
|
$ENV{LUA_DIR}
|
2015-11-09 19:51:25 +01:00
|
|
|
PATH_SUFFIXES "include/lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}"
|
|
|
|
"include/lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
|
2015-07-07 17:45:58 +02:00
|
|
|
"include/lua-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
|
|
|
|
include/lua include
|
2015-05-12 14:24:03 +02:00
|
|
|
PATHS ${RSPAMD_DEFAULT_INCLUDE_PATHS}
|
|
|
|
)
|
2015-11-09 19:51:25 +01:00
|
|
|
FIND_LIBRARY(LUA_LIBRARY
|
|
|
|
NAMES lua
|
2015-07-07 17:45:58 +02:00
|
|
|
"lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}"
|
2015-11-09 19:51:25 +01:00
|
|
|
"lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
|
2015-07-07 17:45:58 +02:00
|
|
|
"lua-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
|
2015-05-12 13:10:42 +02:00
|
|
|
HINTS
|
2015-07-07 17:45:58 +02:00
|
|
|
"${RSPAMD_SEARCH_PATH}" "${LUA_ROOT}"
|
|
|
|
$ENV{LUA_DIR}
|
|
|
|
PATH_SUFFIXES lib64 lib
|
|
|
|
PATHS ${RSPAMD_DEFAULT_LIBRARY_PATHS}
|
|
|
|
DOC "Lua library"
|
2015-05-12 13:10:42 +02:00
|
|
|
)
|
|
|
|
ENDIF(ENABLE_LUAJIT MATCHES "ON")
|
|
|
|
|
2015-02-18 18:31:40 +01:00
|
|
|
IF(LUA_LIBRARY AND LUA_INCLUDE_DIR)
|
|
|
|
SET(LUA_FOUND 1)
|
|
|
|
IF(NOT LUA_VERSION_MAJOR OR NOT LUA_VERSION_MINOR)
|
2015-07-08 16:51:16 +02:00
|
|
|
SET(LUA_VERSION_MAJOR ${LUA_VERSION_MAJOR})
|
|
|
|
SET(LUA_VERSION_MINOR ${LUA_VERSION_MINOR})
|
2015-02-18 18:31:40 +01:00
|
|
|
ENDIF(NOT LUA_VERSION_MAJOR OR NOT LUA_VERSION_MINOR)
|
2015-05-12 13:10:42 +02:00
|
|
|
IF(ENABLE_LUAJIT MATCHES "ON")
|
2017-02-27 13:59:05 +01:00
|
|
|
MESSAGE(STATUS "Found luajit ${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR} in lib:${LUA_LIBRARY}, headers:${LUA_INCLUDE_DIR}")
|
2015-05-12 13:10:42 +02:00
|
|
|
ELSE(ENABLE_LUAJIT MATCHES "ON")
|
2017-02-27 13:59:05 +01:00
|
|
|
MESSAGE(STATUS "Found lua ${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR} in lib:${LUA_LIBRARY}, headers:${LUA_INCLUDE_DIR}")
|
2015-05-12 13:10:42 +02:00
|
|
|
ENDIF(ENABLE_LUAJIT MATCHES "ON")
|
2015-02-18 18:31:40 +01:00
|
|
|
ENDIF(LUA_LIBRARY AND LUA_INCLUDE_DIR)
|
2015-07-07 17:45:58 +02:00
|
|
|
ENDMACRO()
|
2013-09-24 23:19:09 +02:00
|
|
|
|
2015-03-13 12:11:58 +01:00
|
|
|
FUNCTION(INSTALL_IF_NOT_EXISTS src dest destname suffix)
|
2013-12-02 15:19:25 +01:00
|
|
|
IF(NOT IS_ABSOLUTE "${src}")
|
2015-07-07 17:45:58 +02:00
|
|
|
SET(src "${CMAKE_CURRENT_SOURCE_DIR}/${src}")
|
2013-12-02 15:19:25 +01:00
|
|
|
ENDIF()
|
|
|
|
GET_FILENAME_COMPONENT(src_name "${src}" NAME)
|
2015-03-13 12:11:58 +01:00
|
|
|
GET_FILENAME_COMPONENT(dest_name "${destname}" NAME)
|
2013-12-02 15:19:25 +01:00
|
|
|
IF(NOT IS_ABSOLUTE "${dest}")
|
2015-07-07 17:45:58 +02:00
|
|
|
SET(dest "${CMAKE_INSTALL_PREFIX}/${dest}")
|
2013-12-02 15:19:25 +01:00
|
|
|
ENDIF()
|
|
|
|
INSTALL(CODE "
|
2015-07-07 17:45:58 +02:00
|
|
|
IF(NOT EXISTS \"\$ENV{DESTDIR}${dest}/${dest_name}${suffix}\")
|
|
|
|
#FILE(INSTALL \"${src}\" DESTINATION \"${dest}\")
|
|
|
|
MESSAGE(STATUS \"Installing: \$ENV{DESTDIR}${dest}/${dest_name}${suffix}\")
|
|
|
|
EXECUTE_PROCESS(COMMAND \${CMAKE_COMMAND} -E copy \"${src}\"
|
|
|
|
\"\$ENV{DESTDIR}${dest}/${dest_name}${suffix}\"
|
|
|
|
RESULT_VARIABLE copy_result
|
|
|
|
ERROR_VARIABLE error_output)
|
|
|
|
IF(copy_result)
|
|
|
|
MESSAGE(FATAL_ERROR \${error_output})
|
|
|
|
ENDIF()
|
|
|
|
ELSE()
|
|
|
|
MESSAGE(STATUS \"Skipping : \$ENV{DESTDIR}${dest}/${dest_name}${suffix}\")
|
|
|
|
ENDIF()
|
2013-12-02 15:19:25 +01:00
|
|
|
")
|
|
|
|
ENDFUNCTION(INSTALL_IF_NOT_EXISTS)
|
|
|
|
|
2013-12-26 16:28:02 +01:00
|
|
|
# Process required package by using FindPackage and calling for INCLUDE_DIRECTORIES and
|
|
|
|
# setting list of required libraries
|
2015-07-07 20:16:26 +02:00
|
|
|
# Usage:
|
|
|
|
# ProcessPackage(VAR [OPTIONAL] [ROOT path] [INCLUDE path]
|
|
|
|
# [LIBRARY path] [INCLUDE_SUFFIXES path1 path2 ...] [LIB_SUFFIXES path1 path2 ...]
|
|
|
|
# [MODULES module1 module2 ...])
|
|
|
|
# params:
|
|
|
|
# OPTIONAL - do not fail if a package has not been found
|
|
|
|
# ROOT - defines root directory for a package
|
|
|
|
# INCLUDE - name of the include file to check
|
2015-11-09 19:51:25 +01:00
|
|
|
# LIBRARY - name of the library to check
|
2015-07-07 20:16:26 +02:00
|
|
|
# INCLUDE_SUFFIXES - list of include suffixes (relative to ROOT)
|
|
|
|
# LIB_SUFFIXES - list of library suffixes
|
|
|
|
# MODULES - modules to search using pkg_config
|
|
|
|
MACRO(ProcessPackage PKG_NAME)
|
2015-07-08 00:57:21 +02:00
|
|
|
|
2015-11-09 19:51:25 +01:00
|
|
|
CMAKE_PARSE_ARGUMENTS(PKG "OPTIONAL" "ROOT;INCLUDE"
|
2015-07-08 14:00:14 +02:00
|
|
|
"LIBRARY;INCLUDE_SUFFIXES;LIB_SUFFIXES;MODULES" ${ARGN})
|
|
|
|
|
2015-07-07 20:16:26 +02:00
|
|
|
IF(NOT PKG_LIBRARY)
|
|
|
|
SET(PKG_LIBRARY "${PKG_NAME}")
|
|
|
|
ENDIF()
|
|
|
|
IF(NOT PKG_INCLUDE)
|
|
|
|
SET(PKG_INCLUDE "${PKG_NAME}.h")
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
IF(NOT PKG_ROOT AND PKG_MODULES)
|
|
|
|
PKG_SEARCH_MODULE(${PKG_NAME} ${PKG_MODULES})
|
|
|
|
ENDIF()
|
2015-11-09 19:51:25 +01:00
|
|
|
|
2015-07-07 20:16:26 +02:00
|
|
|
IF(${PKG_NAME}_FOUND)
|
2015-07-08 00:57:21 +02:00
|
|
|
MESSAGE(STATUS "Found package ${PKG_NAME} in pkg-config modules ${PKG_MODULES}")
|
2015-07-08 16:51:16 +02:00
|
|
|
SET(WITH_${PKG_NAME} 1 CACHE INTERNAL "")
|
2015-07-07 20:16:26 +02:00
|
|
|
IF(ENABLE_STATIC MATCHES "ON")
|
|
|
|
SET(_XPREFIX "${PKG_NAME}_STATIC")
|
|
|
|
ELSE(ENABLE_STATIC MATCHES "ON")
|
|
|
|
SET(_XPREFIX "${PKG_NAME}")
|
|
|
|
ENDIF(ENABLE_STATIC MATCHES "ON")
|
|
|
|
FOREACH(_arg ${${_XPREFIX}_INCLUDE_DIRS})
|
|
|
|
INCLUDE_DIRECTORIES("${_arg}")
|
2016-02-09 12:26:05 +01:00
|
|
|
SET(${PKG_NAME}_INCLUDE "${_arg}" CACHE INTERNAL "")
|
2015-07-07 20:16:26 +02:00
|
|
|
ENDFOREACH(_arg ${${_XPREFIX}_INCLUDE_DIRS})
|
|
|
|
FOREACH(_arg ${${_XPREFIX}_LIBRARY_DIRS})
|
|
|
|
LINK_DIRECTORIES("${_arg}")
|
2016-01-26 22:23:41 +01:00
|
|
|
SET(${PKG_NAME}_LIBRARY_PATH "${_arg}" CACHE INTERNAL "")
|
2015-07-07 20:16:26 +02:00
|
|
|
ENDFOREACH(_arg ${${_XPREFIX}_LIBRARY_DIRS})
|
|
|
|
# Handle other CFLAGS and LDFLAGS
|
|
|
|
FOREACH(_arg ${${_XPREFIX}_CFLAGS_OTHER})
|
|
|
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_arg}")
|
|
|
|
ENDFOREACH(_arg ${${_XPREFIX}_CFLAGS_OTHER})
|
|
|
|
FOREACH(_arg ${${_XPREFIX}_LDFLAGS_OTHER})
|
|
|
|
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${_arg}")
|
|
|
|
ENDFOREACH(_arg ${${_XPREFIX}_LDFLAGS_OTHER})
|
|
|
|
LIST(APPEND RSPAMD_REQUIRED_LIBRARIES "${${_XPREFIX}_LIBRARIES}")
|
2015-07-08 00:57:21 +02:00
|
|
|
INCLUDE_DIRECTORIES(${${_XPREFIX}_INCLUDEDIR})
|
2015-07-07 20:16:26 +02:00
|
|
|
ELSE()
|
2015-07-08 16:51:16 +02:00
|
|
|
IF(NOT ${PKG_NAME}_GUESSED)
|
|
|
|
# Try some more heuristic
|
|
|
|
FIND_LIBRARY(_lib NAMES ${PKG_LIBRARY}
|
2015-08-04 17:20:44 +02:00
|
|
|
HINTS ${PKG_ROOT} ${RSPAMD_SEARCH_PATH}
|
|
|
|
PATH_SUFFIXES ${PKG_LIB_SUFFIXES} lib64 lib
|
2015-07-08 16:51:16 +02:00
|
|
|
PATHS ${RSPAMD_DEFAULT_LIBRARY_PATHS})
|
|
|
|
IF(NOT _lib)
|
2016-05-04 15:21:05 +02:00
|
|
|
IF(PKG_OPTIONAL)
|
|
|
|
MESSAGE(STATUS "Cannot find library ${PKG_LIBRARY} for package ${PKG_NAME}, ignoring")
|
2015-07-08 16:51:16 +02:00
|
|
|
ELSE()
|
|
|
|
MESSAGE(FATAL_ERROR "Cannot find library ${PKG_LIBRARY} for package ${PKG_NAME}")
|
|
|
|
ENDIF()
|
|
|
|
ENDIF(NOT _lib)
|
2015-11-09 19:51:25 +01:00
|
|
|
|
2015-08-04 17:20:44 +02:00
|
|
|
FIND_PATH(_incl ${PKG_INCLUDE}
|
|
|
|
HINTS ${PKG_ROOT} ${RSPAMD_SEARCH_PATH}
|
|
|
|
PATH_SUFFIXES ${PKG_INCLUDE_SUFFIXES} include
|
|
|
|
PATHS {RSPAMD_DEFAULT_INCLUDE_PATHS})
|
2015-07-08 16:51:16 +02:00
|
|
|
IF(NOT _incl)
|
2016-05-04 15:21:05 +02:00
|
|
|
IF(PKG_OPTIONAL)
|
|
|
|
MESSAGE(STATUS "Cannot find header ${PKG_INCLUDE} for package ${PKG_NAME}")
|
2015-07-08 16:51:16 +02:00
|
|
|
ELSE()
|
|
|
|
MESSAGE(FATAL_ERROR "Cannot find header ${PKG_INCLUDE} for package ${PKG_NAME}")
|
|
|
|
ENDIF()
|
|
|
|
ENDIF(NOT _incl)
|
2015-11-09 19:51:25 +01:00
|
|
|
|
2015-07-08 16:51:16 +02:00
|
|
|
IF(_incl AND _lib)
|
2018-03-08 14:56:56 +01:00
|
|
|
# We need to apply heuristic to find the real dir name
|
|
|
|
STRING(REGEX REPLACE "/[^/]+$" "" _incl_path "${PKG_INCLUDE}")
|
2018-03-08 15:04:09 +01:00
|
|
|
STRING(REGEX REPLACE "${_incl_path}/$" "" _stripped_incl "${_incl}")
|
2015-07-08 16:51:16 +02:00
|
|
|
GET_FILENAME_COMPONENT(_lib_path "${_lib}" PATH)
|
2018-03-08 14:56:56 +01:00
|
|
|
INCLUDE_DIRECTORIES("${_stripped_incl}")
|
2015-07-08 16:51:16 +02:00
|
|
|
LINK_DIRECTORIES("${_lib_path}")
|
|
|
|
LIST(APPEND RSPAMD_REQUIRED_LIBRARIES ${_lib})
|
2018-03-08 14:56:56 +01:00
|
|
|
SET(${PKG_NAME}_INCLUDE "${_stripped_incl}" CACHE INTERNAL "")
|
2015-07-08 16:51:16 +02:00
|
|
|
SET(${PKG_NAME}_LIBRARY_PATH "${_lib_path}" CACHE INTERNAL "")
|
|
|
|
SET(${PKG_NAME}_LIBRARY "${_lib}" CACHE INTERNAL "")
|
|
|
|
SET(${PKG_NAME}_GUESSED 1 CACHE INTERNAL "")
|
|
|
|
SET(WITH_${PKG_NAME} 1 CACHE INTERNAL "")
|
2018-03-08 14:56:56 +01:00
|
|
|
MESSAGE(STATUS "Found package ${PKG_NAME} in '${_lib_path}' (${_lib}) and '${_stripped_incl}' (${PKG_INCLUDE}).")
|
2015-07-08 14:41:14 +02:00
|
|
|
ENDIF()
|
2015-11-09 19:51:25 +01:00
|
|
|
|
2015-07-08 16:51:16 +02:00
|
|
|
ELSE()
|
|
|
|
MESSAGE(STATUS "Found package ${PKG_NAME} (cached)")
|
|
|
|
INCLUDE_DIRECTORIES("${${PKG_NAME}_INCLUDE}")
|
|
|
|
LINK_DIRECTORIES("${${PKG_NAME}_LIBRARY_PATH}")
|
|
|
|
LIST(APPEND RSPAMD_REQUIRED_LIBRARIES "${${PKG_NAME}_LIBRARY}")
|
2015-07-08 14:41:14 +02:00
|
|
|
ENDIF()
|
2015-07-07 20:16:26 +02:00
|
|
|
ENDIF(${PKG_NAME}_FOUND)
|
2015-07-08 14:41:14 +02:00
|
|
|
|
|
|
|
UNSET(_lib CACHE)
|
|
|
|
UNSET(_incl CACHE)
|
2013-12-26 16:28:02 +01:00
|
|
|
ENDMACRO(ProcessPackage name)
|
2013-12-02 15:19:25 +01:00
|
|
|
|
2014-08-29 11:38:50 +02:00
|
|
|
MACRO(ADD_PRECOMPILED_HEADER _target _input)
|
|
|
|
GET_FILENAME_COMPONENT(_name ${_input} NAME)
|
|
|
|
SET(_outdir "${CMAKE_BINARY_DIR}/${_name}.pch")
|
|
|
|
MAKE_DIRECTORY(${_outdir})
|
|
|
|
SET(_output "${_outdir}/${_name}.pch")
|
|
|
|
STRING(TOUPPER "CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}" _flags_var_name)
|
|
|
|
SET(_compiler_FLAGS ${${_flags_var_name}})
|
|
|
|
GET_DIRECTORY_PROPERTY(_directory_flags INCLUDE_DIRECTORIES)
|
|
|
|
FOREACH(item ${_directory_flags})
|
|
|
|
LIST(APPEND _compiler_FLAGS "-I${item}")
|
|
|
|
ENDFOREACH(item)
|
|
|
|
|
|
|
|
INCLUDE_DIRECTORIES(${_outdir})
|
|
|
|
IF("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
|
|
|
|
IF(NOT TARGET ${_name}_pch)
|
|
|
|
MESSAGE("${CMAKE_C_COMPILER} -DPCHCOMPILE ${CMAKE_C_FLAGS} -x c-header -o ${_output} ${_input}")
|
|
|
|
ADD_CUSTOM_COMMAND(OUTPUT ${_output}
|
|
|
|
COMMAND ${CMAKE_C_COMPILER} -DPCHCOMPILE ${_compiler_FLAGS} -x c-header -o ${_output} ${_input}
|
|
|
|
DEPENDS ${_input})
|
|
|
|
ADD_CUSTOM_TARGET(${_name}_pch DEPENDS ${_output})
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
ADD_CUSTOM_TARGET(${_target}_pch DEPENDS ${_name}_pch)
|
|
|
|
ADD_DEPENDENCIES(${_target} ${_target}_pch)
|
|
|
|
SET_TARGET_PROPERTIES(${_target} PROPERTIES COMPILE_FLAGS "-include ${_name} -Winvalid-pch")
|
|
|
|
ENDIF()
|
|
|
|
ENDMACRO()
|
|
|
|
|
2012-01-16 17:59:37 +01:00
|
|
|
############################# CONFIG SECTION #############################################
|
2010-06-22 15:39:03 +02:00
|
|
|
# Initial set
|
|
|
|
|
2015-09-29 14:32:47 +02:00
|
|
|
# Prefer local include dirs to system ones
|
2016-08-30 19:36:14 +02:00
|
|
|
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/"
|
|
|
|
"${CMAKE_SOURCE_DIR}/src"
|
2015-09-29 14:32:47 +02:00
|
|
|
"${CMAKE_SOURCE_DIR}/src/libutil"
|
|
|
|
"${CMAKE_SOURCE_DIR}/src/libserver"
|
|
|
|
"${CMAKE_SOURCE_DIR}/src/libmime"
|
|
|
|
"${CMAKE_SOURCE_DIR}/src/libstat"
|
|
|
|
"${CMAKE_SOURCE_DIR}/src/libcryptobox"
|
|
|
|
"${CMAKE_SOURCE_DIR}/contrib/libucl"
|
2016-05-08 21:22:38 +02:00
|
|
|
"${CMAKE_SOURCE_DIR}/contrib/linenoise"
|
2015-09-29 14:32:47 +02:00
|
|
|
"${CMAKE_SOURCE_DIR}/contrib/uthash"
|
|
|
|
"${CMAKE_SOURCE_DIR}/contrib/http-parser"
|
|
|
|
"${CMAKE_SOURCE_DIR}/contrib/libottery"
|
|
|
|
"${CMAKE_SOURCE_DIR}/contrib/xxhash"
|
|
|
|
"${CMAKE_SOURCE_DIR}/contrib/cdb"
|
|
|
|
"${CMAKE_SOURCE_DIR}/contrib/snowball/include"
|
|
|
|
"${CMAKE_SOURCE_DIR}/contrib/librdns"
|
|
|
|
"${CMAKE_SOURCE_DIR}/contrib/aho-corasick"
|
2016-02-11 10:57:13 +01:00
|
|
|
"${CMAKE_SOURCE_DIR}/contrib/lc-btrie"
|
2018-05-23 19:14:15 +02:00
|
|
|
"${CMAKE_SOURCE_DIR}/contrib/lua-lpeg"
|
2015-09-29 14:32:47 +02:00
|
|
|
"${CMAKE_BINARY_DIR}/src" #Stored in the binary dir
|
|
|
|
"${CMAKE_BINARY_DIR}/src/libcryptobox")
|
2014-09-12 11:37:18 +02:00
|
|
|
|
2010-09-15 14:24:37 +02:00
|
|
|
IF(CMAKE_INSTALL_PREFIX)
|
2015-07-07 17:45:58 +02:00
|
|
|
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
|
2010-09-15 14:24:37 +02:00
|
|
|
ENDIF(CMAKE_INSTALL_PREFIX)
|
|
|
|
|
2012-06-07 17:06:09 +02:00
|
|
|
LIST(APPEND CMAKE_REQUIRED_LIBRARIES m)
|
|
|
|
|
2015-06-16 20:09:27 +02:00
|
|
|
SET(POE_LOOP "Loop::IO_Poll")
|
2015-06-30 15:50:31 +02:00
|
|
|
SET(TAR "tar")
|
2015-06-16 18:39:26 +02:00
|
|
|
|
2011-08-08 15:20:34 +02:00
|
|
|
# Platform specific configuration
|
2016-04-18 16:17:44 +02:00
|
|
|
IF(CMAKE_SYSTEM_NAME MATCHES "^.*BSD$|DragonFly")
|
2015-12-11 17:30:37 +01:00
|
|
|
ADD_DEFINITIONS(-DFREEBSD -D_BSD_SOURCE)
|
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")
|
2015-12-11 17:30:37 +01:00
|
|
|
MESSAGE(STATUS "Configuring for BSD system")
|
2015-05-11 18:08:58 +02:00
|
|
|
# Find util library
|
2015-07-08 14:00:14 +02:00
|
|
|
ProcessPackage(LIBUTIL LIBRARY util INCLUDE libutil.h
|
|
|
|
ROOT ${LIBUTIL_ROOT_DIR} OPTIONAL)
|
2015-07-08 16:51:16 +02:00
|
|
|
IF(WITH_LIBUTIL)
|
2015-07-08 14:00:14 +02:00
|
|
|
SET(HAVE_LIBUTIL_H 1)
|
|
|
|
LIST(APPEND RSPAMD_REQUIRED_LIBRARIES util)
|
|
|
|
LIST(APPEND CMAKE_REQUIRED_LIBRARIES util)
|
|
|
|
CHECK_FUNCTION_EXISTS(pidfile_open HAVE_PIDFILE)
|
|
|
|
CHECK_FUNCTION_EXISTS(pidfile_fileno HAVE_PIDFILE_FILENO)
|
|
|
|
ENDIF()
|
2015-06-16 20:09:27 +02:00
|
|
|
SET(POE_LOOP "Loop::Kqueue")
|
2015-06-30 15:50:31 +02:00
|
|
|
SET(TAR "gtar")
|
2015-12-11 17:30:37 +01:00
|
|
|
ENDIF()
|
2010-06-22 15:39:03 +02:00
|
|
|
|
|
|
|
IF(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
|
|
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_BSD_SOURCE -DDARWIN")
|
2015-07-07 17:45:58 +02:00
|
|
|
SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -undefined dynamic_lookup")
|
2015-04-24 18:08:04 +02:00
|
|
|
IF(ENABLE_LUAJIT MATCHES "ON")
|
2015-04-30 17:18:16 +02:00
|
|
|
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pagezero_size 10000 -image_base 100000000")
|
2015-04-24 18:08:04 +02:00
|
|
|
ENDIF(ENABLE_LUAJIT MATCHES "ON")
|
2010-07-19 09:57:45 +02:00
|
|
|
MESSAGE(STATUS "Configuring for Darwin")
|
2015-06-30 15:50:31 +02:00
|
|
|
SET(TAR "gnutar")
|
2015-07-08 14:41:14 +02:00
|
|
|
SET(CMAKE_FIND_FRAMEWORK "NEVER")
|
2010-06-22 15:39:03 +02:00
|
|
|
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
|
|
|
|
|
|
|
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
2015-12-11 20:18:25 +01:00
|
|
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE")
|
2015-12-11 20:08:36 +01:00
|
|
|
ADD_DEFINITIONS(-D_GNU_SOURCE -DLINUX)
|
2015-07-07 17:45:58 +02:00
|
|
|
# Workaround with architecture specific includes
|
2017-03-31 13:49:34 +02:00
|
|
|
#IF(IS_DIRECTORY "/usr/include/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu/")
|
|
|
|
# INCLUDE_DIRECTORIES("/usr/include/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu/")
|
|
|
|
# LIST(APPEND CMAKE_REQUIRED_INCLUDES "/usr/include/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu/")
|
|
|
|
#ENDIF(IS_DIRECTORY "/usr/include/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu/")
|
2015-11-09 19:51:25 +01:00
|
|
|
|
2010-06-22 15:39:03 +02:00
|
|
|
LIST(APPEND CMAKE_REQUIRED_LIBRARIES rt)
|
|
|
|
LIST(APPEND CMAKE_REQUIRED_LIBRARIES dl)
|
2016-11-26 14:27:44 +01:00
|
|
|
LIST(APPEND CMAKE_REQUIRED_LIBRARIES resolv)
|
|
|
|
LIST(APPEND CMAKE_REQUIRED_LIBRARIES nsl)
|
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")
|
2015-06-16 20:09:27 +02:00
|
|
|
SET(POE_LOOP "XS::Loop::EPoll")
|
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")
|
2015-11-09 19:51:25 +01:00
|
|
|
|
2011-10-17 13:19:38 +02:00
|
|
|
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")
|
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")
|
|
|
|
ENDIF("${CMAKE_C_COMPILER_ID}" MATCHES SunPro)
|
|
|
|
|
2015-07-07 17:45:58 +02:00
|
|
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__EXTENSIONS__ -DSOLARIS -D_POSIX_SOURCE -D_POSIX_C_SOURCE=200112L")
|
2015-11-09 19:51:25 +01:00
|
|
|
|
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)
|
2015-07-07 17:45:58 +02:00
|
|
|
LIST(APPEND CMAKE_REQUIRED_LIBRARIES nsl)
|
|
|
|
LIST(APPEND CMAKE_REQUIRED_LIBRARIES socket)
|
|
|
|
LIST(APPEND CMAKE_REQUIRED_LIBRARIES umem)
|
|
|
|
# Ugly hack, but FindOpenSSL on Solaris does not link with libcrypto
|
|
|
|
SET(CMAKE_VERBOSE_MAKEFILE ON)
|
|
|
|
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
|
|
|
|
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:${RSPAMD_LIBDIR}")
|
2010-06-23 12:45:33 +02:00
|
|
|
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
|
|
|
|
|
2011-08-08 15:20:34 +02:00
|
|
|
# Now find libraries and headers
|
2011-08-03 16:30:25 +02:00
|
|
|
|
2015-03-11 11:26:58 +01:00
|
|
|
IF(ENABLE_LUAJIT MATCHES "ON")
|
2015-05-19 14:51:50 +02:00
|
|
|
#ProcessPackage(LUAJIT luajit)
|
2015-03-21 12:46:05 +01:00
|
|
|
SET(WITH_LUA 1)
|
2015-07-07 17:45:58 +02:00
|
|
|
FindLua(VERSION_MAJOR "5" VERSION_MINOR "1" ROOT "${LUA_ROOT}")
|
2015-05-11 15:17:15 +02:00
|
|
|
IF(NOT LUA_FOUND)
|
2015-07-07 17:45:58 +02:00
|
|
|
MESSAGE(FATAL_ERROR "Lua not found, lua support is required")
|
2015-05-11 15:17:15 +02:00
|
|
|
ELSE(NOT LUA_FOUND)
|
2015-07-07 17:45:58 +02:00
|
|
|
SET(WITH_LUA 1)
|
|
|
|
INCLUDE_DIRECTORIES("${LUA_INCLUDE_DIR}")
|
2015-05-11 15:17:15 +02:00
|
|
|
ENDIF(NOT LUA_FOUND)
|
2015-03-21 18:23:26 +01:00
|
|
|
ELSE(ENABLE_LUAJIT MATCHES "ON")
|
2016-11-25 14:47:27 +01:00
|
|
|
FindLua(VERSION_MAJOR "5" VERSION_MINOR "3" ROOT "${LUA_ROOT}")
|
2015-03-11 11:26:58 +01:00
|
|
|
IF(NOT LUA_FOUND)
|
2016-11-25 14:47:27 +01:00
|
|
|
FindLua(VERSION_MAJOR "5" VERSION_MINOR "2" ROOT "${LUA_ROOT}")
|
|
|
|
IF(NOT LUA_FOUND)
|
|
|
|
FindLua(VERSION_MAJOR "5" VERSION_MINOR "1" ROOT "${LUA_ROOT}")
|
|
|
|
ENDIF(NOT LUA_FOUND)
|
2015-03-21 11:56:54 +01:00
|
|
|
ENDIF(NOT LUA_FOUND)
|
|
|
|
IF(NOT LUA_FOUND)
|
2015-07-07 17:45:58 +02:00
|
|
|
MESSAGE(FATAL_ERROR "Lua not found, lua support is required")
|
2015-03-21 11:56:54 +01:00
|
|
|
ELSE(NOT LUA_FOUND)
|
2015-07-07 17:45:58 +02:00
|
|
|
SET(WITH_LUA 1)
|
|
|
|
INCLUDE_DIRECTORIES("${LUA_INCLUDE_DIR}")
|
2015-03-11 11:26:58 +01:00
|
|
|
ENDIF(NOT LUA_FOUND)
|
|
|
|
ENDIF(ENABLE_LUAJIT MATCHES "ON")
|
2011-03-14 15:44:39 +01:00
|
|
|
|
2016-11-26 14:33:27 +01:00
|
|
|
IF(ENABLE_JEMALLOC MATCHES "ON")
|
|
|
|
ProcessPackage(JEMALLOC LIBRARY jemalloc INCLUDE jemalloc.h INCLUDE_SUFFIXES include/jemalloc
|
|
|
|
ROOT ${JEMALLOC_ROOT_DIR} MODULES jemalloc)
|
|
|
|
SET(WITH_JEMALLOC "1")
|
2017-03-02 16:39:39 +01:00
|
|
|
LIST(APPEND RSPAMD_REQUIRED_LIBRARIES "-lpthread")
|
2016-11-26 14:33:27 +01:00
|
|
|
ENDIF()
|
2018-06-18 18:41:47 +02:00
|
|
|
|
|
|
|
IF(ENABLE_LIBUNWIND MATCHES "ON")
|
|
|
|
ProcessPackage(LIBUNWIND LIBRARY unwind INCLUDE libunwind.h INCLUDE_SUFFIXES include/libunwind
|
|
|
|
ROOT ${LIBUNWIND_ROOT_DIR} MODULES libunwind)
|
|
|
|
SET(WITH_LIBUNWIND "1")
|
|
|
|
ENDIF()
|
2017-03-01 18:31:09 +01:00
|
|
|
ProcessPackage(GTHREAD2 LIBRARY gthread-2.0 INCLUDE glib.h
|
2017-01-27 13:13:10 +01:00
|
|
|
INCLUDE_SUFFIXES include/glib include/glib-2.0
|
|
|
|
ROOT ${GLIB_ROOT_DIR} MODULES gthread-2.0>=2.28)
|
2016-11-26 14:33:27 +01:00
|
|
|
ProcessPackage(GLIB2 LIBRARY glib-2.0 INCLUDE glib.h
|
|
|
|
INCLUDE_SUFFIXES include/glib include/glib-2.0
|
|
|
|
ROOT ${GLIB_ROOT_DIR} MODULES glib-2.0>=2.28)
|
2016-02-09 12:26:16 +01:00
|
|
|
|
|
|
|
IF(ENABLE_PCRE2 MATCHES "ON")
|
2017-03-02 16:39:39 +01:00
|
|
|
ProcessPackage(PCRE LIBRARY pcre2 pcre2-8 INCLUDE pcre2.h INCLUDE_SUFFIXES include/pcre2
|
|
|
|
ROOT ${PCRE_ROOT_DIR} MODULES pcre2 pcre2-8 libpcre2 libpcre2-8)
|
2016-02-09 12:26:16 +01:00
|
|
|
ELSE()
|
|
|
|
ProcessPackage(PCRE LIBRARY pcre INCLUDE pcre.h INCLUDE_SUFFIXES include/pcre
|
|
|
|
ROOT ${PCRE_ROOT_DIR} MODULES pcre libpcre pcre3 libpcre3)
|
|
|
|
ENDIF()
|
2016-11-26 14:33:27 +01:00
|
|
|
|
2015-11-09 19:51:25 +01:00
|
|
|
ProcessPackage(LIBEVENT LIBRARY event INCLUDE event.h INCLUDE_SUFFIXES include/event
|
2015-07-08 14:00:14 +02:00
|
|
|
ROOT ${LIBEVENT_ROOT_DIR} MODULES event libevent)
|
2015-11-09 19:51:25 +01:00
|
|
|
ProcessPackage(SQLITE3 LIBRARY sqlite3 INCLUDE sqlite3.h INCLUDE_SUFFIXES include/sqlite3 include/sqlite
|
2015-07-08 14:00:14 +02:00
|
|
|
ROOT ${SQLITE3_ROOT_DIR} MODULES sqlite3 sqlite)
|
2018-03-08 14:56:56 +01:00
|
|
|
ProcessPackage(ICUDATA LIBRARY icudata INCLUDE unicode/ucnv.h
|
2017-02-23 16:47:58 +01:00
|
|
|
ROOT ${ICU_ROOT_DIR} MODULES icu-i18n)
|
2018-03-08 14:56:56 +01:00
|
|
|
ProcessPackage(ICUC LIBRARY icuuc INCLUDE unicode/ucnv.h
|
2017-02-23 16:47:58 +01:00
|
|
|
ROOT ${ICU_ROOT_DIR} MODULES icu-i18n)
|
2018-03-08 14:56:56 +01:00
|
|
|
ProcessPackage(ICUI18N LIBRARY icui18n INCLUDE unicode/ucnv.h
|
2017-02-23 14:10:03 +01:00
|
|
|
ROOT ${ICU_ROOT_DIR} MODULES icu-i18n)
|
2018-03-08 14:56:56 +01:00
|
|
|
ProcessPackage(LIBCRYPT LIBRARY crypto INCLUDE openssl/evp.h
|
2016-06-11 13:40:25 +02:00
|
|
|
ROOT ${OPENSSL_ROOT_DIR} MODULES openssl libcrypt)
|
2018-03-08 14:56:56 +01:00
|
|
|
ProcessPackage(LIBSSL LIBRARY ssl INCLUDE openssl/ssl.h
|
2016-06-11 13:40:25 +02:00
|
|
|
ROOT ${OPENSSL_ROOT_DIR} MODULES openssl libssl)
|
2015-11-12 15:36:48 +01:00
|
|
|
ProcessPackage(MAGIC LIBRARY magic INCLUDE magic.h INCLUDE_SUFFIXES include/libmagic
|
|
|
|
ROOT ${LIBMAGIC_ROOT_DIR} MODULES magic)
|
2017-08-12 22:57:01 +02:00
|
|
|
ProcessPackage(LIBZ LIBRARY z INCLUDE zlib.h INCLUDE_SUFFIXES include/zlib
|
|
|
|
ROOT ${LIBZ_ROOT_DIR} MODULES z)
|
2015-07-08 14:41:14 +02:00
|
|
|
|
2015-12-07 15:29:25 +01:00
|
|
|
IF(ENABLE_HYPERSCAN MATCHES "ON")
|
|
|
|
ProcessPackage(HYPERSCAN LIBRARY hs INCLUDE hs.h INCLUDE_SUFFIXES
|
2018-06-25 15:17:11 +02:00
|
|
|
hs include/hs
|
2018-06-25 15:21:20 +02:00
|
|
|
ROOT ${HYPERSCAN_ROOT_DIR} MODULES libhs)
|
2015-12-07 15:29:25 +01:00
|
|
|
SET(WITH_HYPERSCAN 1)
|
|
|
|
ENDIF()
|
2015-12-21 13:28:41 +01:00
|
|
|
IF (ENABLE_FANN MATCHES "ON")
|
|
|
|
ProcessPackage(FANN LIBRARY fann INCLUDE fann.h INCLUDE_SUFFIXES
|
|
|
|
include/fann
|
|
|
|
ROOT ${FANN_ROOT_DIR} MODULES fann)
|
|
|
|
SET(WITH_FANN 1)
|
|
|
|
ENDIF ()
|
2015-12-07 15:29:25 +01:00
|
|
|
|
2016-12-06 17:22:23 +01:00
|
|
|
IF (ENABLE_GD MATCHES "ON")
|
|
|
|
ProcessPackage(GD LIBRARY gd INCLUDE gd.h INCLUDE_SUFFIXES
|
|
|
|
include/gd include/libgd
|
|
|
|
ROOT ${GD_ROOT_DIR} MODULES gd)
|
2016-12-09 16:39:58 +01:00
|
|
|
LIST(APPEND CMAKE_REQUIRED_INCLUDES "${GD_INCLUDE}")
|
|
|
|
LIST(APPEND CMAKE_REQUIRED_LIBRARIES "${GD_LIBRARY}")
|
|
|
|
|
|
|
|
CHECK_SYMBOL_EXISTS(gdImageSetInterpolationMethod gd.h GD_INTERPOLATION)
|
|
|
|
CHECK_SYMBOL_EXISTS(gdImageScale gd.h GD_SCALE)
|
|
|
|
CHECK_SYMBOL_EXISTS(gdImageGrayScale gd.h GD_GRAYSCALE)
|
|
|
|
CHECK_SYMBOL_EXISTS(gdImageCreateFromJpegPtr gd.h GD_JPEG)
|
|
|
|
CHECK_SYMBOL_EXISTS(gdImageCreateFromPngPtr gd.h GD_PNG)
|
2018-04-16 15:07:55 +02:00
|
|
|
CHECK_SYMBOL_EXISTS(gdImageCreateFromBmpPtr gd.h GD_BMP)
|
|
|
|
CHECK_SYMBOL_EXISTS(gdImageCreateFromGifPtr gd.h GD_GIF)
|
2016-12-09 16:39:58 +01:00
|
|
|
|
|
|
|
IF(GD_INTERPOLATION AND GD_SCALE AND GD_GRAYSCALE AND GD_JPEG AND GD_PNG AND GD_GIF AND GD_BMP)
|
2016-12-09 17:02:31 +01:00
|
|
|
SET(USABLE_GD 1)
|
2016-12-09 16:39:58 +01:00
|
|
|
ELSE()
|
|
|
|
MESSAGE(STATUS "Libgd is found but it is unusable")
|
|
|
|
ENDIF()
|
2016-12-06 17:22:23 +01:00
|
|
|
ENDIF ()
|
|
|
|
|
2015-07-08 15:15:46 +02:00
|
|
|
#Check for openssl (required for dkim)
|
2016-06-11 13:40:25 +02:00
|
|
|
SET(HAVE_OPENSSL 1)
|
2015-07-08 15:15:46 +02:00
|
|
|
|
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")
|
2015-07-08 00:57:21 +02:00
|
|
|
ProcessPackage(GPERF LIBRARY profiler INCLUDE profiler.h INCLUDE_SUFFIXES include/google
|
2015-07-08 14:00:14 +02:00
|
|
|
ROOT ${GPERF_ROOT_DIR})
|
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")
|
|
|
|
|
2018-03-02 16:27:38 +01:00
|
|
|
IF (ENABLE_HYPERSCAN MATCHES "ON")
|
|
|
|
IF(${HYPERSCAN_LIBRARY} MATCHES ".*[.]a$")
|
|
|
|
ENABLE_LANGUAGE(CXX)
|
|
|
|
SET(USE_CXX_LINKER 1)
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
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)
|
2016-07-13 18:03:05 +02:00
|
|
|
CHECK_C_COMPILER_FLAG(-Wno-sign-compare SUPPORT_WSIGN_COMPARE)
|
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)
|
2016-06-14 21:36:50 +02:00
|
|
|
CHECK_C_COMPILER_FLAG(-Wno-unused-const-variable SUPPORT_WNO_UNUSED_CONST)
|
2016-02-16 14:44:25 +01:00
|
|
|
# GCC 6 specific
|
|
|
|
CHECK_C_COMPILER_FLAG(-Wnull-dereference SUPPORT_WNULL_DEREFERENCE)
|
|
|
|
CHECK_C_COMPILER_FLAG(-Wduplicated-cond SUPPORT_WDUPLICATED_COND)
|
2017-04-07 14:07:34 +02:00
|
|
|
# GCC 7 specific
|
|
|
|
CHECK_C_COMPILER_FLAG(-Wimplicit-fallthrough SUPPORT_WIMPLICIT_FALLTHROUGH)
|
2016-06-14 21:36:50 +02:00
|
|
|
|
2013-06-20 13:21:38 +02:00
|
|
|
IF(NOT "${CMAKE_C_COMPILER_ID}" MATCHES SunPro)
|
2016-01-30 10:55:32 +01:00
|
|
|
CHECK_C_COMPILER_FLAG("-std=c11" SUPPORT_STD11_FLAG)
|
|
|
|
CHECK_C_COMPILER_FLAG("-std=c99" SUPPORT_STD99_FLAG)
|
2013-06-20 13:21:38 +02:00
|
|
|
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)
|
2016-07-05 13:57:58 +02:00
|
|
|
#IF(SUPPORT_PEDANTIC_FLAG)
|
|
|
|
# SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -pedantic")
|
|
|
|
#ENDIF(SUPPORT_PEDANTIC_FLAG)
|
2016-02-16 14:44:25 +01:00
|
|
|
IF(SUPPORT_WNULL_DEREFERENCE)
|
|
|
|
SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wnull-dereference")
|
|
|
|
ENDIF()
|
|
|
|
IF(SUPPORT_WDUPLICATED_COND)
|
|
|
|
SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wduplicated-cond")
|
|
|
|
ENDIF()
|
|
|
|
IF(SUPPORT_WLOGICAL_OP)
|
|
|
|
SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wlogical-op")
|
|
|
|
ENDIF()
|
2016-06-14 21:17:15 +02:00
|
|
|
IF(SUPPORT_WNO_UNUSED_CONST)
|
2016-06-14 21:36:50 +02:00
|
|
|
SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-unused-const-variable")
|
2016-06-14 21:17:15 +02:00
|
|
|
ENDIF()
|
2016-07-13 18:03:05 +02:00
|
|
|
IF(SUPPORT_WSIGN_COMPARE)
|
|
|
|
SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-sign-compare")
|
|
|
|
ENDIF()
|
2016-01-30 10:55:32 +01:00
|
|
|
IF(SUPPORT_STD11_FLAG)
|
|
|
|
SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -std=c11")
|
|
|
|
ELSE(SUPPORT_STD11_FLAG)
|
|
|
|
IF(SUPPORT_STD99_FLAG)
|
|
|
|
SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -std=c99")
|
|
|
|
ENDIF(SUPPORT_STD99_FLAG)
|
|
|
|
ENDIF(SUPPORT_STD11_FLAG)
|
2017-04-07 14:07:34 +02:00
|
|
|
IF(SUPPORT_WIMPLICIT_FALLTHROUGH)
|
|
|
|
SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-implicit-fallthrough")
|
|
|
|
ENDIF(SUPPORT_WIMPLICIT_FALLTHROUGH)
|
2015-11-09 19:51:25 +01:00
|
|
|
|
2012-06-07 17:48:27 +02:00
|
|
|
CHECK_C_COMPILER_FLAG(-fPIC SUPPORT_FPIC)
|
|
|
|
IF(SUPPORT_FPIC)
|
2013-09-24 14:55:47 +02:00
|
|
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
|
2012-06-07 17:48:27 +02:00
|
|
|
ENDIF(SUPPORT_FPIC)
|
2015-11-09 19:51:25 +01:00
|
|
|
|
2011-10-17 13:19:38 +02:00
|
|
|
# Optimization flags
|
|
|
|
IF(NOT CMAKE_C_OPT_FLAGS)
|
|
|
|
IF(ENABLE_OPTIMIZATION MATCHES "ON")
|
2016-07-14 14:57:10 +02:00
|
|
|
CHECK_C_COMPILER_FLAG(-flto SUPPORT_FLTO)
|
|
|
|
IF(SUPPORT_FLTO)
|
|
|
|
IF(NOT CMAKE_GCC_AR OR NOT CMAKE_GCC_RANLIB)
|
|
|
|
FIND_PROGRAM(CMAKE_GCC_AR NAMES "gcc-ar")
|
2016-07-14 15:34:31 +02:00
|
|
|
FIND_PROGRAM(CMAKE_GCC_RANLIB NAMES "gcc-ranlib")
|
2016-07-14 14:57:10 +02:00
|
|
|
MARK_AS_ADVANCED(CMAKE_GCC_AR CMAKE_GCC_RANLIB)
|
|
|
|
ENDIF()
|
|
|
|
IF(CMAKE_GCC_AR AND CMAKE_GCC_RANLIB)
|
2016-11-17 16:55:10 +01:00
|
|
|
SET(CMAKE_C_OPT_FLAGS "-g -O3 -fstrict-aliasing -flto")
|
2016-07-14 13:54:41 +02:00
|
|
|
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
|
2016-07-14 14:57:10 +02:00
|
|
|
SET(CMAKE_C_ARCHIVE_CREATE "${CMAKE_GCC_AR} cr <TARGET> <LINK_FLAGS> <OBJECTS>")
|
2016-07-14 15:34:31 +02:00
|
|
|
SET(CMAKE_C_ARCHIVE_APPEND "${CMAKE_GCC_AR} r <TARGET> <LINK_FLAGS> <OBJECTS>")
|
|
|
|
SET(CMAKE_C_ARCHIVE_FINISH "${CMAKE_GCC_RANLIB} <TARGET>")
|
2016-07-14 14:57:10 +02:00
|
|
|
SET(CMAKE_CXX_ARCHIVE_CREATE "${CMAKE_GCC_AR} cr <TARGET> <LINK_FLAGS> <OBJECTS>")
|
2016-07-14 15:34:31 +02:00
|
|
|
SET(CMAKE_CXX_ARCHIVE_APPEND "${CMAKE_GCC_AR} r <TARGET> <LINK_FLAGS> <OBJECTS>")
|
|
|
|
SET(CMAKE_CXX_ARCHIVE_FINISH "${CMAKE_GCC_RANLIB} <TARGET>")
|
2016-07-14 13:54:41 +02:00
|
|
|
ENDIF()
|
2016-07-14 14:57:10 +02:00
|
|
|
ELSE()
|
2016-11-17 16:55:10 +01:00
|
|
|
SET(CMAKE_C_OPT_FLAGS "-g -O3 -fstrict-aliasing")
|
2016-07-14 14:57:10 +02:00
|
|
|
ENDIF()
|
2011-10-17 13:19:38 +02:00
|
|
|
ELSE(ENABLE_OPTIMIZATION MATCHES "ON")
|
2016-12-25 17:23:02 +01:00
|
|
|
IF(ENABLE_FULL_DEBUG MATCHES "ON")
|
2015-07-21 13:28:36 +02:00
|
|
|
SET(CMAKE_C_OPT_FLAGS "-g -O0 -fstrict-aliasing")
|
2016-12-25 17:23:02 +01:00
|
|
|
ELSE(ENABLE_FULL_DEBUG MATCHES "ON")
|
2015-07-21 13:28:36 +02:00
|
|
|
SET(CMAKE_C_OPT_FLAGS "-g -O2 -fstrict-aliasing")
|
2016-12-25 17:23:02 +01:00
|
|
|
ENDIF(ENABLE_FULL_DEBUG MATCHES "ON")
|
2011-10-17 13:19:38 +02:00
|
|
|
ENDIF(ENABLE_OPTIMIZATION MATCHES "ON")
|
|
|
|
ENDIF(NOT CMAKE_C_OPT_FLAGS)
|
|
|
|
|
2016-08-02 16:18:29 +02:00
|
|
|
IF(ENABLE_COVERAGE)
|
|
|
|
SET(CMAKE_C_OPT_FLAGS "-g -O0 -fno-strict-aliasing")
|
2016-08-10 14:49:52 +02:00
|
|
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
|
|
|
|
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
|
2016-08-02 16:18:29 +02:00
|
|
|
ENDIF(ENABLE_COVERAGE)
|
|
|
|
|
2011-10-17 13:19:38 +02:00
|
|
|
SET(CMAKE_C_FLAGS "${CMAKE_C_OPT_FLAGS} ${CMAKE_C_FLAGS} ${CMAKE_C_WARN_FLAGS}")
|
2015-11-09 19:51:25 +01:00
|
|
|
|
2015-12-11 17:30:37 +01:00
|
|
|
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
|
|
|
|
|
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)
|
2015-03-11 11:26:58 +01:00
|
|
|
CHECK_INCLUDE_FILES(stdbool.h HAVE_STDBOOL_H)
|
2009-02-16 17:50:18 +01:00
|
|
|
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)
|
2017-08-07 09:26:32 +02:00
|
|
|
CHECK_INCLUDE_FILES(netinet/tcp.h HAVE_NETINET_TCP_H)
|
2009-02-16 17:50:18 +01:00
|
|
|
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)
|
2013-08-22 15:57:03 +02:00
|
|
|
CHECK_INCLUDE_FILES(readpassphrase.h HAVE_READPASSPHRASE_H)
|
|
|
|
CHECK_INCLUDE_FILES(termios.h HAVE_TERMIOS_H)
|
|
|
|
CHECK_INCLUDE_FILES(paths.h HAVE_PATHS_H)
|
2014-04-11 00:21:59 +02:00
|
|
|
CHECK_INCLUDE_FILES(ctype.h HAVE_CTYPE_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)
|
2014-04-11 00:48:08 +02:00
|
|
|
CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H)
|
2015-03-14 20:56:22 +01:00
|
|
|
CHECK_INCLUDE_FILES(cpuid.h HAVE_CPUID_H)
|
2015-10-03 17:09:58 +02:00
|
|
|
CHECK_INCLUDE_FILES(dirent.h HAVE_DIRENT_H)
|
2015-10-08 19:50:39 +02:00
|
|
|
CHECK_INCLUDE_FILES(stropts.h HAVE_STROPS_H)
|
|
|
|
CHECK_INCLUDE_FILES(sys/ioctl.h HAVE_SYS_IOCTL_H)
|
2009-02-17 13:04:24 +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-12-04 14:41:26 +01:00
|
|
|
CHECK_FUNCTION_EXISTS(tanh HAVE_TANH)
|
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)
|
2015-02-03 23:03:22 +01:00
|
|
|
CHECK_FUNCTION_EXISTS(memset_s HAVE_MEMSET_S)
|
|
|
|
CHECK_FUNCTION_EXISTS(explicit_bzero HAVE_EXPLICIT_BZERO)
|
|
|
|
CHECK_C_SOURCE_COMPILES(
|
2015-07-08 14:00:14 +02:00
|
|
|
"#include <stddef.h>
|
|
|
|
void cmkcheckweak() __attribute__((weak));
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
return cmkcheckweak == NULL;
|
|
|
|
}" HAVE_WEAK_SYMBOLS)
|
2018-02-18 18:08:48 +01:00
|
|
|
CHECK_C_SOURCE_COMPILES(
|
|
|
|
"#include <time.h>
|
|
|
|
extern char *tzname[2];
|
|
|
|
extern long timezone;
|
|
|
|
extern int daylight;
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
tzset();
|
|
|
|
return timezone;
|
|
|
|
}" HAVE_SANE_TZSET)
|
2015-03-03 19:22:09 +01:00
|
|
|
|
2015-07-08 16:51:16 +02:00
|
|
|
IF(WITH_ICONV)
|
2015-03-03 19:22:09 +01:00
|
|
|
CHECK_C_SOURCE_COMPILES("
|
2015-02-09 11:52:23 +01:00
|
|
|
#include <iconv.h>
|
|
|
|
int main(){
|
|
|
|
iconv_t conv = 0;
|
|
|
|
const char* in = 0;
|
|
|
|
size_t ilen = 0;
|
|
|
|
char* out = 0;
|
|
|
|
size_t olen = 0;
|
|
|
|
iconv(conv, &in, &ilen, &out, &olen);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
" ICONV_SECOND_ARGUMENT_IS_CONST)
|
2015-07-08 16:51:16 +02:00
|
|
|
ENDIF(WITH_ICONV)
|
2015-02-09 11:52:23 +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)
|
2014-01-09 16:49:29 +01:00
|
|
|
CHECK_SYMBOL_EXISTS(IPV6_V6ONLY "sys/socket.h;netinet/in.h" HAVE_IPV6_V6ONLY)
|
2011-11-17 16:34:02 +01:00
|
|
|
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)
|
2014-09-18 14:08:37 +02:00
|
|
|
CHECK_SYMBOL_EXISTS(sched_yield "sched.h" HAVE_SCHED_YIELD)
|
2015-03-14 20:56:22 +01:00
|
|
|
CHECK_SYMBOL_EXISTS(__get_cpuid "cpuid.h" HAVE_GET_CPUID)
|
2015-12-11 17:30:37 +01:00
|
|
|
CHECK_SYMBOL_EXISTS(nftw "sys/types.h;ftw.h" HAVE_NFTW)
|
2016-02-09 12:26:16 +01:00
|
|
|
IF(ENABLE_PCRE2 MATCHES "ON")
|
|
|
|
LIST(APPEND CMAKE_REQUIRED_INCLUDES "${PCRE_INCLUDE}")
|
|
|
|
CHECK_SYMBOL_EXISTS(PCRE2_CONFIG_JIT "pcre2.h" HAVE_PCRE_JIT)
|
|
|
|
ELSE()
|
|
|
|
LIST(APPEND CMAKE_REQUIRED_INCLUDES "${PCRE_INCLUDE}")
|
|
|
|
CHECK_SYMBOL_EXISTS(PCRE_CONFIG_JIT "pcre.h" HAVE_PCRE_JIT)
|
|
|
|
ENDIF()
|
2015-10-08 17:56:50 +02:00
|
|
|
CHECK_SYMBOL_EXISTS(SOCK_SEQPACKET "sys/types.h;sys/socket.h" HAVE_SOCK_SEQPACKET)
|
2015-10-08 19:50:39 +02:00
|
|
|
CHECK_SYMBOL_EXISTS(I_SETSIG "sys/types.h;sys/ioctl.h" HAVE_SETSIG)
|
|
|
|
CHECK_SYMBOL_EXISTS(O_ASYNC "sys/types.h;sys/fcntl.h" HAVE_OASYNC)
|
2016-02-03 00:42:42 +01:00
|
|
|
CHECK_SYMBOL_EXISTS(O_NOFOLLOW "sys/types.h;sys/fcntl.h" HAVE_ONOFOLLOW)
|
2017-07-25 09:38:23 +02:00
|
|
|
CHECK_SYMBOL_EXISTS(O_CLOEXEC "sys/types.h;sys/fcntl.h" HAVE_OCLOEXEC)
|
2016-06-13 11:04:21 +02:00
|
|
|
LIST(APPEND CMAKE_REQUIRED_INCLUDES "${LIBSSL_INCLUDE}")
|
|
|
|
CHECK_SYMBOL_EXISTS(SSL_set_tlsext_host_name "openssl/ssl.h" HAVE_SSL_TLSEXT_HOSTNAME)
|
2016-10-19 15:54:42 +02:00
|
|
|
CHECK_SYMBOL_EXISTS(dirfd "sys/types.h;unistd.h;dirent.h" HAVE_DIRFD)
|
|
|
|
CHECK_SYMBOL_EXISTS(fpathconf "sys/types.h;unistd.h" HAVE_FPATHCONF)
|
2018-06-18 18:41:47 +02:00
|
|
|
CHECK_SYMBOL_EXISTS(sigaltstack "signal.h" HAVE_SIGALTSTACK)
|
2015-02-09 11:04:37 +01:00
|
|
|
|
2016-02-09 12:26:16 +01:00
|
|
|
IF(ENABLE_PCRE2 MATCHES "ON")
|
|
|
|
IF(HAVE_PCRE_JIT)
|
|
|
|
SET(HAVE_PCRE_JIT_FAST 1)
|
|
|
|
ENDIF()
|
|
|
|
ELSE()
|
|
|
|
LIST(APPEND CMAKE_REQUIRED_INCLUDES "${PCRE_INCLUDE}")
|
|
|
|
IF(PCRE_LIBRARY_PATH)
|
|
|
|
SET(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};-L${PCRE_LIBRARY_PATH};${PCRE_LIBRARY}")
|
|
|
|
ELSE(PCRE_LIBRARY_PATH)
|
|
|
|
SET(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};-lpcre")
|
|
|
|
ENDIF(PCRE_LIBRARY_PATH)
|
2015-05-06 13:27:35 +02:00
|
|
|
# Some PCRE implementations are lacking of pcre_jit_exec fast path
|
|
|
|
SET(_PCRE_FAST_TEST "
|
|
|
|
#include \"pcre.h\"
|
2015-11-09 19:51:25 +01:00
|
|
|
int main (void)
|
2015-05-06 13:27:35 +02:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
int ovector[30];
|
|
|
|
pcre *re;
|
|
|
|
pcre_extra *extra;
|
|
|
|
pcre_jit_stack *jit_stack;
|
2015-11-09 19:51:25 +01:00
|
|
|
|
2015-05-06 13:27:35 +02:00
|
|
|
re = pcre_compile(\"abc\", 0, NULL, NULL, NULL);
|
|
|
|
extra = pcre_study(re, PCRE_STUDY_JIT_COMPILE, NULL);
|
|
|
|
jit_stack = pcre_jit_stack_alloc(32*1024, 512*1024);
|
|
|
|
pcre_assign_jit_stack(extra, NULL, jit_stack);
|
|
|
|
rc = pcre_jit_exec(re, extra, \"abc\", 3, 0, 0, ovector, 30, jit_stack);
|
2015-11-09 19:51:25 +01:00
|
|
|
|
2015-05-06 13:27:35 +02:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
")
|
2015-05-11 15:53:48 +02:00
|
|
|
CHECK_C_SOURCE_COMPILES("${_PCRE_FAST_TEST}" HAVE_PCRE_JIT_FAST)
|
|
|
|
IF(HAVE_PCRE_JIT_FAST)
|
2015-05-06 13:27:35 +02:00
|
|
|
MESSAGE(STATUS "pcre_jit_exec is supported")
|
2015-05-11 15:53:48 +02:00
|
|
|
ELSE(HAVE_PCRE_JIT_FAST)
|
2015-05-06 13:27:35 +02:00
|
|
|
MESSAGE(STATUS "pcre_jit_exec is -NOT- supported")
|
2015-05-11 15:53:48 +02:00
|
|
|
ENDIF(HAVE_PCRE_JIT_FAST)
|
2016-02-09 12:26:16 +01:00
|
|
|
ENDIF()
|
2015-05-06 13:27:35 +02:00
|
|
|
|
2015-02-09 11:04:37 +01:00
|
|
|
FILE(WRITE ${CMAKE_BINARY_DIR}/pthread_setpshared.c "
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
int main (void)
|
|
|
|
{
|
2015-02-09 11:12:59 +01:00
|
|
|
pthread_mutexattr_t mattr;
|
2015-02-09 11:04:37 +01:00
|
|
|
if (pthread_mutexattr_init(&mattr) != 0) return 0;
|
|
|
|
if (pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED) != 0) return 0;
|
2015-02-24 18:08:26 +01:00
|
|
|
if (pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST) != 0) return 0;
|
2015-02-09 11:04:37 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
")
|
2015-02-09 11:12:59 +01:00
|
|
|
TRY_RUN(_CAN_RUN _CAN_COMPILE
|
|
|
|
"${CMAKE_BINARY_DIR}" "${CMAKE_BINARY_DIR}/pthread_setpshared.c"
|
|
|
|
CMAKE_FLAGS CMAKE_C_FLAGS="-pthread")
|
|
|
|
IF(_CAN_RUN EQUAL 1)
|
2015-07-08 16:51:16 +02:00
|
|
|
SET(HAVE_PTHREAD_PROCESS_SHARED 1 CACHE INTERNAL "")
|
2015-12-10 12:24:53 +01:00
|
|
|
LIST(APPEND RSPAMD_REQUIRED_LIBRARIES "-lpthread")
|
2015-02-09 11:12:59 +01:00
|
|
|
ENDIF(_CAN_RUN EQUAL 1)
|
2015-02-09 11:04:37 +01:00
|
|
|
IF(HAVE_PTHREAD_PROCESS_SHARED)
|
|
|
|
MESSAGE(STATUS "pthread_mutexattr_setpshared is supported")
|
|
|
|
ELSE(HAVE_PTHREAD_PROCESS_SHARED)
|
|
|
|
MESSAGE(STATUS "pthread_mutexattr_setpshared is -NOT- supported")
|
|
|
|
ENDIF(HAVE_PTHREAD_PROCESS_SHARED)
|
2013-06-03 00:57:19 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
int main() { return 0;}" HAVE_LIBEVENT2)
|
|
|
|
|
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>
|
2015-07-07 17:45:58 +02:00
|
|
|
int main (int argc, char **argv) {
|
|
|
|
__asm __volatile(\"pause\");
|
2009-06-17 18:31:42 +02:00
|
|
|
return 0;
|
|
|
|
}" HAVE_ASM_PAUSE)
|
2011-10-17 13:19:38 +02:00
|
|
|
ENDIF(NOT CMAKE_SYSTEM_NAME STREQUAL "SunOS")
|
2009-06-17 18:31:42 +02:00
|
|
|
|
2015-11-23 10:10:12 +01:00
|
|
|
CHECK_C_SOURCE_RUNS("
|
2015-11-26 19:50:03 +01:00
|
|
|
#include <stdbool.h>
|
2015-11-23 10:10:12 +01:00
|
|
|
int main(int argc, char **argv) {
|
2015-11-26 19:50:03 +01:00
|
|
|
int a = 0, b = 0;
|
|
|
|
if (__atomic_compare_exchange_n(&a, &b, 1, false, __ATOMIC_RELEASE, __ATOMIC_RELAXED)) {
|
2015-11-23 10:10:12 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
" HAVE_ATOMIC_BUILTINS)
|
|
|
|
|
2015-11-26 19:50:03 +01:00
|
|
|
IF(NOT HAVE_ATOMIC_BUILTINS)
|
|
|
|
MESSAGE(STATUS "atomic builtins are -NOT- supported")
|
|
|
|
ELSE()
|
|
|
|
MESSAGE(STATUS "atomic builtins are supported")
|
|
|
|
ENDIF()
|
|
|
|
|
2017-10-26 16:52:11 +02:00
|
|
|
CHECK_C_SOURCE_RUNS("
|
|
|
|
#include <x86intrin.h>
|
|
|
|
int main(int argc, char **argv) {
|
2017-10-27 15:09:40 +02:00
|
|
|
__builtin_ia32_lfence ();
|
|
|
|
if (__builtin_ia32_rdtsc()) {
|
2017-10-26 16:52:11 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
2017-10-27 15:09:40 +02:00
|
|
|
" HAVE_RDTSC)
|
2017-10-26 16:52:11 +02:00
|
|
|
|
2017-10-27 15:09:40 +02:00
|
|
|
IF(NOT HAVE_RDTSC)
|
|
|
|
MESSAGE(STATUS "rdtsc intrinsic is -NOT- supported")
|
2017-10-26 16:52:11 +02:00
|
|
|
ELSE()
|
2017-10-27 15:09:40 +02:00
|
|
|
MESSAGE(STATUS "rdtsc intrinsic is supported")
|
2017-10-26 16:52:11 +02:00
|
|
|
ENDIF()
|
|
|
|
|
2016-07-05 14:40:50 +02:00
|
|
|
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
|
|
# In linux, we need to mount /run/shm to test which could be unavailable
|
|
|
|
# on a build system. On the other hand, we know that linux has stupid
|
|
|
|
# but compatible shmem support, so we assume this macro as true
|
2016-07-11 15:25:11 +02:00
|
|
|
SET(HAVE_SANE_SHMEM 1)
|
2016-06-29 15:51:50 +02:00
|
|
|
ELSE()
|
2016-07-05 14:40:50 +02:00
|
|
|
CHECK_C_SOURCE_RUNS("
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#define TEST_NAME \"/test-shmem-work\"
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
fd = shm_open (TEST_NAME, O_RDWR | O_CREAT | O_EXCL, 00600);
|
|
|
|
if (fd == -1) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (ftruncate (fd, 100) == -1) {
|
|
|
|
shm_unlink (TEST_NAME);
|
|
|
|
close (fd);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ftruncate (fd, 200) == -1) {
|
|
|
|
shm_unlink (TEST_NAME);
|
|
|
|
close (fd);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (ftruncate (fd, 300) == -1) {
|
|
|
|
shm_unlink (TEST_NAME);
|
|
|
|
close (fd);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
close (fd);
|
|
|
|
shm_unlink (TEST_NAME);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
" HAVE_SANE_SHMEM)
|
|
|
|
IF(NOT HAVE_SANE_SHMEM)
|
|
|
|
MESSAGE(STATUS "shmem support is NOT compatible with POSIX")
|
|
|
|
ELSE()
|
|
|
|
MESSAGE(STATUS "shmem support is compatible with POSIX")
|
|
|
|
ENDIF()
|
2016-06-29 15:51:50 +02:00
|
|
|
ENDIF()
|
|
|
|
|
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
|
|
|
|
2015-05-11 18:08:58 +02:00
|
|
|
IF(ENABLE_URL_INCLUDE MATCHES "ON")
|
2015-07-07 17:45:58 +02:00
|
|
|
FIND_LIBRARY(LIBFETCH_LIBRARY HINTS "${RSPAMD_SEARCH_PATH}"
|
|
|
|
NAMES fetch PATHS PATH_SUFFIXES lib64 lib
|
|
|
|
PATHS ${RSPAMD_DEFAULT_LIBRARY_PATHS}
|
|
|
|
DOC "Path where the libfetch library can be found")
|
|
|
|
IF(LIBFETCH_LIBRARY)
|
|
|
|
FIND_FILE(HAVE_FETCH_H HINTS "${RSPAMD_SEARCH_PATH}"
|
2015-11-09 19:51:25 +01:00
|
|
|
NAMES fetch.h
|
2015-07-07 17:45:58 +02:00
|
|
|
PATH_SUFFIXES include
|
|
|
|
PATHS ${RSPAMD_DEFAULT_INCLUDE_PATHS}
|
|
|
|
DOC "Path to libfetch header")
|
|
|
|
ELSE(LIBFETCH_LIBRARY)
|
|
|
|
# Try to find libcurl
|
2015-11-09 19:51:25 +01:00
|
|
|
ProcessPackage(CURL LIBRARY curl INCLUDE curl.h INCLUDE_SUFFIXES include/curl
|
2015-07-08 00:57:21 +02:00
|
|
|
ROOT ${CURL_ROOT})
|
2015-07-08 16:51:16 +02:00
|
|
|
IF(NOT WITH_CURL)
|
2015-07-07 17:45:58 +02:00
|
|
|
MESSAGE(WARNING "Neither libcurl nor libfetch were found, no support of URL includes in configuration")
|
2015-07-08 16:51:16 +02:00
|
|
|
ENDIF(NOT WITH_CURL)
|
2015-07-07 17:45:58 +02:00
|
|
|
ENDIF(LIBFETCH_LIBRARY)
|
2015-05-11 18:08:58 +02:00
|
|
|
ENDIF(ENABLE_URL_INCLUDE MATCHES "ON")
|
|
|
|
|
2010-09-15 14:24:37 +02:00
|
|
|
IF(NOT DESTDIR)
|
2015-07-07 17:45:58 +02:00
|
|
|
SET(DESTDIR $ENV{DESTDIR})
|
2010-09-15 14:24:37 +02:00
|
|
|
ENDIF(NOT DESTDIR)
|
2010-05-28 14:50:01 +02:00
|
|
|
|
2011-05-10 17:15:03 +02:00
|
|
|
|
2011-12-09 17:13:00 +01:00
|
|
|
################################ SUBDIRS SECTION ###########################
|
2017-06-05 11:14:47 +02:00
|
|
|
ADD_SUBDIRECTORY(contrib/hiredis)
|
|
|
|
SET(WITH_HIREDIS 1)
|
|
|
|
INCLUDE_DIRECTORIES(BEFORE "${CMAKE_SOURCE_DIR}/contrib/hiredis")
|
2011-12-09 17:13:00 +01:00
|
|
|
|
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
|
|
|
|
2015-02-14 00:45:06 +01:00
|
|
|
LIST(APPEND RSPAMD_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
|
|
|
|
LIST(APPEND RSPAMD_REQUIRED_LIBRARIES ucl)
|
|
|
|
LIST(APPEND RSPAMD_REQUIRED_LIBRARIES rdns)
|
|
|
|
LIST(APPEND RSPAMD_REQUIRED_LIBRARIES ottery)
|
|
|
|
LIST(APPEND RSPAMD_REQUIRED_LIBRARIES event)
|
|
|
|
LIST(APPEND RSPAMD_REQUIRED_LIBRARIES xxhash)
|
2016-07-22 11:24:21 +02:00
|
|
|
LIST(APPEND RSPAMD_REQUIRED_LIBRARIES rspamd-actrie)
|
2015-02-14 00:45:06 +01:00
|
|
|
IF(HAVE_FETCH_H)
|
|
|
|
LIST(APPEND RSPAMD_REQUIRED_LIBRARIES fetch)
|
|
|
|
ENDIF(HAVE_FETCH_H)
|
|
|
|
IF(WITH_DB)
|
|
|
|
LIST(APPEND RSPAMD_REQUIRED_LIBRARIES db)
|
|
|
|
ENDIF(WITH_DB)
|
|
|
|
|
2015-02-18 18:31:40 +01:00
|
|
|
|
|
|
|
LIST(APPEND RSPAMD_REQUIRED_LIBRARIES "${LUA_LIBRARY}")
|
2015-02-14 00:45:06 +01:00
|
|
|
|
|
|
|
IF(GLIB_COMPAT)
|
|
|
|
LIST(APPEND RSPAMD_REQUIRED_LIBRARIES glibadditions)
|
|
|
|
ENDIF(GLIB_COMPAT)
|
|
|
|
|
2016-06-25 14:39:35 +02:00
|
|
|
|
2014-02-18 19:14:53 +01:00
|
|
|
ADD_SUBDIRECTORY(contrib/xxhash)
|
2015-02-21 19:35:54 +01:00
|
|
|
ADD_SUBDIRECTORY(contrib/cdb)
|
2014-02-18 19:14:53 +01:00
|
|
|
ADD_SUBDIRECTORY(contrib/http-parser)
|
2016-02-11 10:57:13 +01:00
|
|
|
ADD_SUBDIRECTORY(contrib/lc-btrie)
|
2014-02-18 19:14:53 +01:00
|
|
|
ADD_SUBDIRECTORY(contrib/libottery)
|
2016-09-08 17:59:45 +02:00
|
|
|
ADD_SUBDIRECTORY(contrib/zstd)
|
2015-10-23 12:51:53 +02:00
|
|
|
IF(ENABLE_SNOWBALL MATCHES "ON")
|
|
|
|
ADD_SUBDIRECTORY(contrib/snowball)
|
|
|
|
SET(WITH_SNOWBALL 1)
|
|
|
|
ENDIF()
|
2015-02-21 19:11:12 +01:00
|
|
|
ADD_SUBDIRECTORY(contrib/libucl)
|
|
|
|
ADD_SUBDIRECTORY(contrib/librdns)
|
2015-04-06 19:18:05 +02:00
|
|
|
ADD_SUBDIRECTORY(contrib/aho-corasick)
|
2018-05-23 19:14:15 +02:00
|
|
|
ADD_SUBDIRECTORY(contrib/lua-lpeg)
|
2016-05-08 21:22:38 +02:00
|
|
|
ADD_SUBDIRECTORY(contrib/linenoise)
|
2018-04-28 14:38:11 +02:00
|
|
|
ADD_SUBDIRECTORY(contrib/t1ha)
|
2015-11-09 19:51:25 +01:00
|
|
|
|
2016-06-25 14:39:35 +02:00
|
|
|
IF (ENABLE_SNOWBALL MATCHES "ON")
|
|
|
|
LIST(APPEND RSPAMD_REQUIRED_LIBRARIES stemmer)
|
|
|
|
ENDIF()
|
|
|
|
IF(ENABLE_HIREDIS MATCHES "ON")
|
|
|
|
LIST(APPEND RSPAMD_REQUIRED_LIBRARIES rspamd-hiredis)
|
|
|
|
ENDIF()
|
|
|
|
IF(ENABLE_HYPERSCAN MATCHES "OFF")
|
|
|
|
LIST(APPEND RSPAMD_REQUIRED_LIBRARIES rspamd-actrie)
|
|
|
|
ENDIF()
|
2018-04-28 14:38:11 +02:00
|
|
|
LIST(APPEND RSPAMD_REQUIRED_LIBRARIES rspamd-t1ha)
|
2016-06-25 14:39:35 +02:00
|
|
|
|
2015-11-09 19:51:25 +01:00
|
|
|
IF(ENABLE_CLANG_PLUGIN MATCHES "ON")
|
|
|
|
ADD_SUBDIRECTORY(clang-plugin)
|
|
|
|
ENDIF()
|
|
|
|
|
2017-07-16 17:39:35 +02:00
|
|
|
IF(ENABLE_TORCH MATCHES "ON")
|
|
|
|
IF(WITH_LUAJIT)
|
2018-05-23 19:14:15 +02:00
|
|
|
ADD_SUBDIRECTORY(contrib/lua-torch/paths)
|
|
|
|
ADD_SUBDIRECTORY(contrib/lua-torch/torch7)
|
|
|
|
ADD_SUBDIRECTORY(contrib/lua-torch/nn)
|
|
|
|
ADD_SUBDIRECTORY(contrib/lua-torch/optim)
|
|
|
|
ADD_SUBDIRECTORY(contrib/lua-torch/decisiontree)
|
2017-08-07 09:14:04 +02:00
|
|
|
SET(WITH_TORCH 1)
|
2017-07-16 17:39:35 +02:00
|
|
|
ELSE()
|
|
|
|
MESSAGE(FATAL_ERROR "Cannot enable torch without luajit")
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
2014-01-19 17:11:34 +01:00
|
|
|
ADD_SUBDIRECTORY(src)
|
2011-05-10 17:15:03 +02:00
|
|
|
ADD_SUBDIRECTORY(test)
|
2015-10-20 11:10:35 +02:00
|
|
|
ADD_SUBDIRECTORY(utils)
|
2011-05-10 17:15:03 +02:00
|
|
|
|
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)
|
2015-11-23 10:10:12 +01:00
|
|
|
ADD_DEFINITIONS("HAVE_CONFIG_H")
|
2013-11-25 14:45:38 +01: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
|
|
|
|
|
|
|
|
# Configs
|
2013-11-19 17:17:13 +01:00
|
|
|
INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${CONFDIR})")
|
|
|
|
INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${EXAMPLESDIR})")
|
|
|
|
INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${PLUGINSDIR}/lua)")
|
2015-08-07 15:40:05 +02:00
|
|
|
INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${RULESDIR})")
|
2017-05-18 17:04:23 +02:00
|
|
|
INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${LUALIBDIR})")
|
2009-09-15 16:42:05 +02:00
|
|
|
|
2013-12-02 15:19:25 +01:00
|
|
|
# Install configs only if they are unchanged
|
|
|
|
LIST(LENGTH CONFFILES CONFLIST_COUNT)
|
|
|
|
MATH(EXPR CONFLIST_MAX ${CONFLIST_COUNT}-1)
|
2015-08-07 17:23:24 +02:00
|
|
|
|
2015-11-09 19:51:25 +01:00
|
|
|
FILE(GLOB_RECURSE CONF_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/conf"
|
2015-08-07 17:23:24 +02:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/conf/*" )
|
|
|
|
FOREACH(CONF_FILE ${CONF_FILES})
|
|
|
|
GET_FILENAME_COMPONENT(_rp ${CONF_FILE} PATH)
|
|
|
|
INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${CONFDIR}/${_rp})")
|
2015-11-09 19:51:25 +01:00
|
|
|
INSTALL(FILES "${CMAKE_CURRENT_SOURCE_DIR}/conf/${CONF_FILE}"
|
2015-08-07 17:23:24 +02:00
|
|
|
DESTINATION ${CONFDIR}/${_rp})
|
|
|
|
ENDFOREACH(CONF_FILE)
|
2009-09-15 16:42:05 +02:00
|
|
|
|
2017-06-11 19:48:57 +02:00
|
|
|
SET(MAIN_CONF "conf/rspamd.conf")
|
2015-03-13 12:11:58 +01:00
|
|
|
IF(BUILD_PORT)
|
|
|
|
INSTALL_IF_NOT_EXISTS(${MAIN_CONF} ${CONFDIR} "rspamd.conf" ".sample")
|
|
|
|
ELSE(BUILD_PORT)
|
|
|
|
INSTALL_IF_NOT_EXISTS(${MAIN_CONF} ${CONFDIR} "rspamd.conf" "")
|
|
|
|
ENDIF(BUILD_PORT)
|
|
|
|
IF(INSTALL_EXAMPLES MATCHES "ON")
|
|
|
|
INSTALL(FILES ${MAIN_CONF} DESTINATION ${EXAMPLESDIR})
|
|
|
|
ENDIF(INSTALL_EXAMPLES MATCHES "ON")
|
|
|
|
|
2009-09-15 16:42:05 +02:00
|
|
|
# Lua plugins
|
2010-07-19 09:57:45 +02:00
|
|
|
|
2015-11-09 19:51:25 +01:00
|
|
|
FILE(GLOB LUA_PLUGINS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/lua"
|
2013-11-19 17:17:13 +01:00
|
|
|
"${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)
|
2013-11-19 17:17:13 +01:00
|
|
|
INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${PLUGINSDIR}/lua/${_rp})")
|
|
|
|
INSTALL(FILES "src/plugins/lua/${LUA_PLUGIN}" DESTINATION ${PLUGINSDIR}/lua/${_rp})
|
2010-07-19 09:57:45 +02:00
|
|
|
ENDFOREACH(LUA_PLUGIN)
|
2009-09-15 16:42:05 +02:00
|
|
|
|
2015-02-16 17:35:18 +01:00
|
|
|
|
2015-04-06 17:02:51 +02:00
|
|
|
# Install TLD list
|
2015-11-09 19:51:25 +01:00
|
|
|
INSTALL(FILES "contrib/publicsuffix/effective_tld_names.dat" DESTINATION
|
2015-04-06 23:24:08 +02:00
|
|
|
"${PLUGINSDIR}")
|
2015-04-06 17:02:51 +02:00
|
|
|
|
2017-12-30 21:19:12 +01:00
|
|
|
# Install languages data
|
|
|
|
INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${PLUGINSDIR}/languages)")
|
|
|
|
FILE(GLOB LANGUAGES "${CMAKE_CURRENT_SOURCE_DIR}/contrib/languages-data/*.json")
|
|
|
|
FOREACH(_LANG ${LANGUAGES})
|
|
|
|
INSTALL(FILES "${_LANG}" DESTINATION ${PLUGINSDIR}/languages)
|
|
|
|
ENDFOREACH()
|
|
|
|
|
2010-05-06 16:40:37 +02:00
|
|
|
# Lua config
|
2015-11-09 19:51:25 +01:00
|
|
|
FILE(GLOB_RECURSE LUA_CONFIGS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/rules"
|
2015-08-07 15:40:05 +02:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/rules/*.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)
|
2015-08-07 15:40:05 +02:00
|
|
|
INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${RULESDIR}/${_rp})")
|
|
|
|
INSTALL(FILES "rules/${LUA_CONF}" DESTINATION ${RULESDIR}/${_rp})
|
2010-07-19 09:57:45 +02:00
|
|
|
ENDFOREACH(LUA_CONF)
|
2010-05-06 16:40:37 +02:00
|
|
|
|
2017-05-18 17:04:23 +02:00
|
|
|
# Lua libs
|
|
|
|
FILE(GLOB_RECURSE LUA_LIBS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/lualib"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/lualib/*.lua")
|
|
|
|
FOREACH(LUA_LIB ${LUA_LIBS})
|
|
|
|
GET_FILENAME_COMPONENT(_rp ${LUA_LIB} PATH)
|
|
|
|
INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${LUALIBDIR}/${_rp})")
|
2017-05-18 17:50:34 +02:00
|
|
|
INSTALL(FILES "lualib/${LUA_LIB}" DESTINATION ${LUALIBDIR}/${_rp})
|
2017-05-18 17:04:23 +02:00
|
|
|
ENDFOREACH(LUA_LIB)
|
|
|
|
|
2017-05-18 17:58:50 +02:00
|
|
|
# Install lua fun library
|
|
|
|
INSTALL(FILES "contrib/lua-fun/fun.lua" DESTINATION ${LUALIBDIR})
|
2018-05-23 18:54:17 +02:00
|
|
|
INSTALL(FILES "contrib/lua-argparse/argparse.lua" DESTINATION ${LUALIBDIR})
|
2017-05-18 17:58:50 +02:00
|
|
|
|
2017-07-16 17:39:35 +02:00
|
|
|
IF(ENABLE_TORCH MATCHES "ON")
|
2018-05-23 19:14:15 +02:00
|
|
|
INSTALL(FILES "contrib/lua-moses/moses.lua" DESTINATION ${LUALIBDIR})
|
2017-07-16 17:39:35 +02:00
|
|
|
ENDIF()
|
|
|
|
|
2014-03-28 15:51:16 +01:00
|
|
|
# systemd unit
|
2015-01-15 12:43:48 +01:00
|
|
|
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND WANT_SYSTEMD_UNITS MATCHES "ON")
|
2014-04-21 17:25:51 +02:00
|
|
|
INSTALL(FILES "rspamd.service" DESTINATION ${SYSTEMDDIR})
|
2015-01-15 12:43:48 +01:00
|
|
|
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND WANT_SYSTEMD_UNITS MATCHES "ON")
|
2014-03-28 15:51:16 +01:00
|
|
|
|
2011-02-07 16:53:55 +01:00
|
|
|
# Manual pages
|
2013-11-19 17:17:13 +01:00
|
|
|
INSTALL(FILES "doc/rspamd.8" DESTINATION ${MANDIR}/man8)
|
2013-12-20 16:57:07 +01:00
|
|
|
INSTALL(FILES "doc/rspamc.1" DESTINATION ${MANDIR}/man1)
|
2015-09-28 17:45:01 +02:00
|
|
|
INSTALL(FILES "doc/rspamadm.1" DESTINATION ${MANDIR}/man1)
|
2014-09-01 12:37:28 +02:00
|
|
|
|
2016-07-24 18:58:58 +02:00
|
|
|
# Utils
|
2016-07-28 19:40:11 +02:00
|
|
|
INSTALL(PROGRAMS "utils/rspamd_stats.pl" RENAME rspamd_stats DESTINATION bin)
|
2016-07-24 18:58:58 +02:00
|
|
|
|
2014-09-01 12:37:28 +02:00
|
|
|
# Install webui
|
|
|
|
IF(INSTALL_WEBUI MATCHES "ON")
|
|
|
|
INSTALL(DIRECTORY "interface/" DESTINATION ${WWWDIR} PATTERN ".git" EXCLUDE)
|
2014-09-05 12:21:42 +02:00
|
|
|
ENDIF(INSTALL_WEBUI MATCHES "ON")
|
|
|
|
|
2018-02-18 17:43:50 +01:00
|
|
|
|
|
|
|
INSTALL(DIRECTORY "contrib/elastic/" DESTINATION "${PLUGINSDIR}/elastic" PATTERN ".git" EXCLUDE)
|
|
|
|
|
2014-09-05 12:21:42 +02:00
|
|
|
ADD_CUSTOM_TARGET(dist ${CMAKE_SOURCE_DIR}/dist.sh
|
2015-06-30 15:50:31 +02:00
|
|
|
"${CMAKE_BINARY_DIR}/rspamd-${RSPAMD_VERSION}.tar.xz" "${TAR}"
|
2014-09-05 12:21:42 +02:00
|
|
|
COMMENT "Create source distribution"
|
2014-09-30 13:52:31 +02:00
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
2014-12-17 18:28:07 +01:00
|
|
|
|
2014-12-20 18:03:30 +01:00
|
|
|
IF(NOT DEBIAN_BUILD)
|
|
|
|
ADD_CUSTOM_TARGET(check DEPENDS rspamd-test)
|
|
|
|
ADD_CUSTOM_TARGET(run-test DEPENDS check COMMAND test/rspamd-test)
|
2015-11-09 19:51:25 +01:00
|
|
|
ENDIF(NOT DEBIAN_BUILD)
|