# # Rspamd - rapid antispam system # # Cmake configuration file # ############################# INITIAL SECTION ############################################# PROJECT(rspamd C) ENABLE_LANGUAGE(ASM) SET(RSPAMD_VERSION_MAJOR 0) SET(RSPAMD_VERSION_MINOR 9) SET(RSPAMD_VERSION_PATCH 0) SET(RSPAMD_VERSION "${RSPAMD_VERSION_MAJOR}.${RSPAMD_VERSION_MINOR}.${RSPAMD_VERSION_PATCH}") SET(RSPAMD_MASTER_SITE_URL "https://rspamd.com") IF(NOT RSPAMD_USER) SET(RSPAMD_USER "nobody") SET(RSPAMD_GROUP "nobody") ENDIF(NOT RSPAMD_USER) CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0 FATAL_ERROR) SET_PROPERTY(GLOBAL PROPERTY ALLOW_DUPLICATE_CUSTOM_TARGETS 1) ############################# OPTIONS SECTION ############################################# OPTION(DEBUG_MODE "Enable debug output [default: ON]" ON) OPTION(ENABLE_OPTIMIZATION "Enable optimization [default: OFF]" OFF) OPTION(SKIP_RELINK_RPATH "Skip relinking and full RPATH for the install tree" OFF) OPTION(ENABLE_REDIRECTOR "Enable redirector install [default: OFF]" OFF) OPTION(ENABLE_GPERF_TOOLS "Enable google perftools [default: OFF]" OFF) OPTION(ENABLE_STATIC "Enable static compiling [default: OFF]" OFF) OPTION(ENABLE_LUAJIT "Link with libluajit [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: ON]" ON) OPTION(ENABLE_URL_INCLUDE "Enable urls in ucl includes (requires libcurl or libfetch) [default: OFF]" OFF) OPTION(NO_SHARED "Build internal libs static [default: ON]" ON) OPTION(FORCE_GMIME24 "Link with gmime2.4 [default: OFF]" OFF) OPTION(INSTALL_EXAMPLES "Install examples [default: OFF]" OFF) OPTION(INSTALL_WEBUI "Install web interface [default: ON]" ON) OPTION(WANT_SYSTEMD_UNITS "Install systemd unit files on Linux [default: OFF]" OFF) # Build optimized code for following CPU (default i386) #SET(CPU_TUNE "i686") # Now CMAKE_INSTALL_PREFIX is a base prefix for everything # CONFDIR - for configuration # 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) IF(NOT MANDIR) SET(MANDIR "${CMAKE_INSTALL_PREFIX}/share/man") ENDIF(NOT MANDIR) IF(NOT RUNDIR) SET(RUNDIR "${CMAKE_INSTALL_PREFIX}/var/run/rspamd") ENDIF(NOT RUNDIR) IF(NOT DBDIR) SET(DBDIR "${CMAKE_INSTALL_PREFIX}/var/lib/rspamd") ENDIF(NOT DBDIR) IF(NOT LOGDIR) SET(LOGDIR "${CMAKE_INSTALL_PREFIX}/var/log/rspamd") 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) IF(NOT WWWDIR) SET(WWWDIR "${CMAKE_INSTALL_PREFIX}/share/rspamd/www") ENDIF(NOT WWWDIR) # Set libdir IF(NOT LIBDIR) SET(LIBDIR lib/rspamd) IF(NOT CMAKE_INSTALL_RPATH) SET(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${LIBDIR}) ENDIF(NOT CMAKE_INSTALL_RPATH) ENDIF(NOT LIBDIR) # Set includedir IF(NOT INCLUDEDIR) SET(INCLUDEDIR include/rspamd) ENDIF(NOT INCLUDEDIR) IF(NOT SYSTEMDDIR) SET(SYSTEMDDIR ${CMAKE_INSTALL_PREFIX}/lib/systemd/system) ENDIF(NOT SYSTEMDDIR) ############################# INCLUDE SECTION ############################################# INCLUDE(CheckIncludeFiles) INCLUDE(CheckFunctionExists) INCLUDE(CheckSymbolExists) INCLUDE(CheckCSourceCompiles) INCLUDE(CheckLibraryExists) INCLUDE(FindPkgConfig) INCLUDE(CheckCCompilerFlag) INCLUDE(FindPerl) INCLUDE(FindOpenSSL) ############################# MACRO SECTION ############################################# # Find lua installation MACRO(FindLua _major _minor) # Find lua libraries MESSAGE(STATUS "Check for lua ${_major}.${_minor}") UNSET(LUA_INCLUDE_DIR CACHE) UNSET(LUA_LIBRARY CACHE) FIND_PATH(LUA_INCLUDE_DIR lua.h HINTS $ENV{LUA_DIR} PATH_SUFFIXES "include/lua${_major}${_minor}" "include/lua${_major}.${_minor}" "include/lua-${_major}.${_minor}" include/lua include PATHS /usr/local /usr/pkg /usr ~/Library/Frameworks /Library/Frameworks /sw # Fink /opt/local # DarwinPorts /opt/csw # Blastwave /opt ) # Check for luajit IF(ENABLE_LUAJIT MATCHES "ON") FIND_LIBRARY(LUA_LIBRARY NAMES "luajit${_major}${_minor}" "luajit${_major}.${_minor}" "luajit-${_major}.${_minor}" "luajit" HINTS $ENV{LUA_DIR} PATH_SUFFIXES lib64 lib PATHS ~/Library/Frameworks /Library/Frameworks /usr/local /usr /sw /opt/local /opt/csw /usr/pkg /opt ) ELSE(ENABLE_LUAJIT MATCHES "ON") FIND_LIBRARY(LUA_LIBRARY NAMES lua "lua${_major}${_minor}" "lua${_major}.${_minor}" "lua-${_major}.${_minor}" HINTS $ENV{LUA_DIR} PATH_SUFFIXES lib64 lib PATHS /usr/local /usr ~/Library/Frameworks /Library/Frameworks /sw /opt/local /opt/csw /opt DOC "Lua library" ) ENDIF(ENABLE_LUAJIT MATCHES "ON") IF(LUA_LIBRARY AND LUA_INCLUDE_DIR) SET(LUA_FOUND 1) IF(NOT LUA_VERSION_MAJOR OR NOT LUA_VERSION_MINOR) SET(LUA_VERSION_MAJOR ${_major}) SET(LUA_VERSION_MINOR ${_minor}) ENDIF(NOT LUA_VERSION_MAJOR OR NOT LUA_VERSION_MINOR) MESSAGE(STATUS "Found lua ${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}") ENDIF(LUA_LIBRARY AND LUA_INCLUDE_DIR) ENDMACRO(FindLua _major _minor) FUNCTION(INSTALL_IF_NOT_EXISTS src dest destname suffix) IF(NOT IS_ABSOLUTE "${src}") SET(src "${CMAKE_CURRENT_SOURCE_DIR}/${src}") ENDIF() GET_FILENAME_COMPONENT(src_name "${src}" NAME) GET_FILENAME_COMPONENT(dest_name "${destname}" NAME) IF(NOT IS_ABSOLUTE "${dest}") SET(dest "${CMAKE_INSTALL_PREFIX}/${dest}") ENDIF() INSTALL(CODE " 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() ") ENDFUNCTION(INSTALL_IF_NOT_EXISTS) # Process required package by using FindPackage and calling for INCLUDE_DIRECTORIES and # setting list of required libraries MACRO(ProcessPackage var _name0) PKG_SEARCH_MODULE(${var} REQUIRED "${_name0}" ${ARGN}) IF(${var}_FOUND) SET(WITH_${var} 1) IF(ENABLE_STATIC MATCHES "ON") SET(_XPREFIX "${var}_STATIC") ELSE(ENABLE_STATIC MATCHES "ON") SET(_XPREFIX "${var}") ENDIF(ENABLE_STATIC MATCHES "ON") FOREACH(_arg ${${_XPREFIX}_INCLUDE_DIRS}) INCLUDE_DIRECTORIES("${_arg}") SET(${var}_INCLUDE_DIR "${_arg}") ENDFOREACH(_arg ${${_XPREFIX}_INCLUDE_DIRS}) FOREACH(_arg ${${_XPREFIX}_LIBRARY_DIRS}) LINK_DIRECTORIES("${_arg}") 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}") ELSE(${var}_FOUND) MESSAGE(FATAL_ERROR "Packages ${_name0} ${ARGN} could not be found") ENDIF(${var}_FOUND) ENDMACRO(ProcessPackage name) 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(_compi
<?xml version="1.0" encoding="UTF-8"?>
<!--
   Copyright (C) 2009-2012, Matthias Sohn <matthias.sohn@sap.com>
   and other copyright owners as documented in the project's IP log.

   This program and the accompanying materials are made available
   under the terms of the Eclipse Distribution License v1.0 which
   accompanies this distribution, is reproduced below, and is
   available at http://www.eclipse.org/org/documents/edl-v10.php

   All rights reserved.

   Redistribution and use in source and binary forms, with or
   without modification, are permitted provided that the following
   conditions are met:

   - Redistributions of source code must retain the above copyright
     notice, this list of conditions and the following disclaimer.

   - Redistributions in binary form must reproduce the above
     copyright notice, this list of conditions and the following
     disclaimer in the documentation and/or other materials provided
     with the distribution.

   - Neither the name of the Eclipse Foundation, Inc. nor the
     names of its contributors may be used to endorse or promote
     products derived from this software without specific prior
     written permission.

   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.eclipse.jgit</groupId>
    <artifactId>jgit.tycho.parent</artifactId>
    <version>4.0.2.201509141540-r</version>
  </parent>

  <groupId>org.eclipse.jgit.feature</groupId>
  <artifactId>org.eclipse.jgit</artifactId>
  <packaging>eclipse-feature</packaging>

  <name>JGit Feature</name>

  <dependencies>
    <dependency>
      <groupId>org.eclipse.jgit</groupId>
      <artifactId>org.eclipse.jgit</artifactId>
      <version>${project.version}</version>
    </dependency>
  </dependencies>

</project>
DOC "Path where the libfetch library can be found") IF(LIBFETCH_LIBRARY) FIND_FILE(HAVE_FETCH_H NAMES fetch.h PATHS /usr/include /opt/include /usr/local/include DOC "Path to libfetch header") ELSE(LIBFETCH_LIBRARY) # Try to find libcurl ProcessPackage(CURL libcurl) IF(NOT CURL_FOUND) MESSAGE(WARNING "Neither libcurl nor libfetch were found, no support of URL includes in configuration") ENDIF(NOT CURL_FOUND) ENDIF(LIBFETCH_LIBRARY) ENDIF(ENABLE_URL_INCLUDE MATCHES "ON") ProcessPackage(SQLITE sqlite3>=3.6.0) # Static build IF(ENABLE_STATIC MATCHES "ON") SET(BUILD_STATIC 1) SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -pthread") MESSAGE(STATUS "Static build of rspamd, no custom plugins support") SET(LINK_TYPE "STATIC") SET(NO_SHARED "ON") 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") # Process with warn flags SET(CMAKE_C_WARN_FLAGS "") CHECK_C_COMPILER_FLAG(-Wall SUPPORT_WALL) CHECK_C_COMPILER_FLAG(-W SUPPORT_W) 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) CHECK_C_COMPILER_FLAG(-Wstrict-prototypes SUPPORT_WSTRICT_PROTOTYPES) CHECK_C_COMPILER_FLAG(-pedantic SUPPORT_PEDANTIC_FLAG) 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) 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) IF(SUPPORT_WSTRICT_PROTOTYPES) SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wstrict-prototypes") ENDIF(SUPPORT_WSTRICT_PROTOTYPES) IF(SUPPORT_PEDANTIC_FLAG) SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -pedantic") ENDIF(SUPPORT_PEDANTIC_FLAG) IF(SUPPORT_STD_FLAG) SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -std=c99") ENDIF(SUPPORT_STD_FLAG) CHECK_C_COMPILER_FLAG(-fPIC SUPPORT_FPIC) IF(SUPPORT_FPIC) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") ENDIF(SUPPORT_FPIC) # Optimization flags IF(NOT CMAKE_C_OPT_FLAGS) IF(ENABLE_OPTIMIZATION MATCHES "ON") SET(CMAKE_C_OPT_FLAGS "-O3 -fstrict-aliasing") ELSE(ENABLE_OPTIMIZATION MATCHES "ON") SET(CMAKE_C_OPT_FLAGS "-O0 -fstrict-aliasing") ENDIF(ENABLE_OPTIMIZATION MATCHES "ON") ENDIF(NOT CMAKE_C_OPT_FLAGS) IF(DEBUG_MODE MATCHES "ON") SET(CMAKE_BUILD_TYPE "Debug") ENDIF(DEBUG_MODE MATCHES "ON") SET(CMAKE_C_FLAGS "${CMAKE_C_OPT_FLAGS} ${CMAKE_C_FLAGS} ${CMAKE_C_WARN_FLAGS}") # Check platform specific includes 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(stdbool.h HAVE_STDBOOL_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) 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) CHECK_INCLUDE_FILES(sys/file.h HAVE_SYS_FILE_H) CHECK_INCLUDE_FILES(sys/utsname.h HAVE_SYS_UTSNAME_H) CHECK_INCLUDE_FILES(sys/resource.h HAVE_SYS_RESOURCE_H) 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) CHECK_INCLUDE_FILES(siginfo.h HAVE_SIGINFO_H) CHECK_INCLUDE_FILES(locale.h HAVE_LOCALE_H) CHECK_INCLUDE_FILES(libgen.h HAVE_LIBGEN_H) CHECK_INCLUDE_FILES(search.h HAVE_SEARCH_H) CHECK_INCLUDE_FILES(pwd.h HAVE_PWD_H) CHECK_INCLUDE_FILES(grp.h HAVE_GRP_H) CHECK_INCLUDE_FILES(glob.h HAVE_GLOB_H) CHECK_INCLUDE_FILES(poll.h HAVE_POLL_H) CHECK_INCLUDE_FILES(readpassphrase.h HAVE_READPASSPHRASE_H) CHECK_INCLUDE_FILES(termios.h HAVE_TERMIOS_H) CHECK_INCLUDE_FILES(paths.h HAVE_PATHS_H) CHECK_INCLUDE_FILES(ctype.h HAVE_CTYPE_H) CHECK_INCLUDE_FILES(sys/sendfile.h HAVE_SYS_SENDFILE_H) CHECK_INCLUDE_FILES(linux/falloc.h HAVE_LINUX_FALLOC_H) 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) CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H) CHECK_INCLUDE_FILES(cpuid.h HAVE_CPUID_H) # Some dependencies IF(HAVE_SYS_WAIT_H) LIST(APPEND CMAKE_REQUIRED_INCLUDES sys/wait.h) ENDIF(HAVE_SYS_WAIT_H) IF(HAVE_TIME_H) LIST(APPEND CMAKE_REQUIRED_INCLUDES time.h) ENDIF(HAVE_TIME_H) IF(HAVE_SYS_TIME_H) LIST(APPEND CMAKE_REQUIRED_INCLUDES sys/time.h) ENDIF(HAVE_SYS_TIME_H) # Check platform API CHECK_FUNCTION_EXISTS(setproctitle HAVE_SETPROCTITLE) CHECK_FUNCTION_EXISTS(getpagesize HAVE_GETPAGESIZE) CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP) CHECK_FUNCTION_EXISTS(vfork HAVE_VFORK) CHECK_FUNCTION_EXISTS(wait4 HAVE_WAIT4) CHECK_FUNCTION_EXISTS(waitpid HAVE_WAITPID) CHECK_FUNCTION_EXISTS(flock HAVE_FLOCK) CHECK_FUNCTION_EXISTS(tanhl HAVE_TANHL) CHECK_FUNCTION_EXISTS(tanh HAVE_TANH) CHECK_FUNCTION_EXISTS(expl HAVE_EXPL) CHECK_FUNCTION_EXISTS(exp2l HAVE_EXP2L) CHECK_FUNCTION_EXISTS(sendfile HAVE_SENDFILE) CHECK_FUNCTION_EXISTS(mkstemp HAVE_MKSTEMP) CHECK_FUNCTION_EXISTS(setitimer HAVE_SETITIMER) CHECK_FUNCTION_EXISTS(inet_pton HAVE_INET_PTON) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME) CHECK_FUNCTION_EXISTS(memset_s HAVE_MEMSET_S) CHECK_FUNCTION_EXISTS(explicit_bzero HAVE_EXPLICIT_BZERO) CHECK_C_SOURCE_COMPILES( "#include void cmkcheckweak() __attribute__((weak)); int main(int argc, char** argv) { return cmkcheckweak == NULL; }" HAVE_WEAK_SYMBOLS) IF(NOT ICONV_ROOT_DIR) FIND_PATH(ICONV_INCLUDE_DIR iconv.h PATHS ~/Library/Frameworks /Library/Frameworks /usr/local /sw /opt/local /opt/csw /opt /usr PATH_SUFFIXES include include/libiconv DOC "Path where the libiconv headers can be found") FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c PATHS ~/Library/Frameworks /Library/Frameworks /usr/local /sw /opt/local /opt/csw /opt /usr PATH_SUFFIXES lib64 lib DOC "Path where the libiconv library can be found") ELSE(NOT ICONV_ROOT_DIR) FIND_PATH(ICONV_INCLUDE_DIR iconv.h PATHS "${ICONV_ROOT_DIR}" PATH_SUFFIXES include include/libiconv DOC "Path where the libiconv headers can be found" NO_DEFAULT_PATH) FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c PATHS "${ICONV_ROOT_DIR}" PATH_SUFFIXES lib64 lib DOC "Path where the libiconv library can be found" NO_DEFAULT_PATH) ENDIF(NOT ICONV_ROOT_DIR) IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) SET(ICONV_FOUND TRUE) ENDIF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR}) LIST(APPEND RSPAMD_REQUIRED_LIBRARIES ${ICONV_LIBRARIES}) IF(ICONV_FOUND) CHECK_C_SOURCE_COMPILES(" #include 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) ENDIF(ICONV_FOUND) IF(ICONV_FOUND) MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}") ELSE(ICONV_FOUND) MESSAGE(FATAL_ERROR "Could not find Iconv") ENDIF(ICONV_FOUND) # Check macros 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) CHECK_SYMBOL_EXISTS(MAP_NOCORE sys/mman.h HAVE_MMAP_NOCORE) CHECK_SYMBOL_EXISTS(O_DIRECT fcntl.h HAVE_O_DIRECT) CHECK_SYMBOL_EXISTS(IPV6_V6ONLY "sys/socket.h;netinet/in.h" HAVE_IPV6_V6ONLY) CHECK_SYMBOL_EXISTS(posix_fadvise fcntl.h HAVE_FADVISE) CHECK_SYMBOL_EXISTS(posix_fallocate fcntl.h HAVE_POSIX_FALLOCATE) CHECK_SYMBOL_EXISTS(fallocate fcntl.h HAVE_FALLOCATE) CHECK_SYMBOL_EXISTS(fdatasync unistd.h HAVE_FDATASYNC) CHECK_SYMBOL_EXISTS(_SC_NPROCESSORS_ONLN unistd.h HAVE_SC_NPROCESSORS_ONLN) CHECK_SYMBOL_EXISTS(setbit sys/param.h PARAM_H_HAS_BITSET) CHECK_SYMBOL_EXISTS(getaddrinfo "sys/types.h;sys/socket.h;netdb.h" HAVE_GETADDRINFO) CHECK_SYMBOL_EXISTS(sched_yield "sched.h" HAVE_SCHED_YIELD) CHECK_SYMBOL_EXISTS(__get_cpuid "cpuid.h" HAVE_GET_CPUID) CHECK_SYMBOL_EXISTS(PCRE_CONFIG_JIT "pcre.h" HAVE_PCRE_JIT) FILE(WRITE ${CMAKE_BINARY_DIR}/pthread_setpshared.c " #include #include int main (void) { pthread_mutexattr_t mattr; if (pthread_mutexattr_init(&mattr) != 0) return 0; if (pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED) != 0) return 0; if (pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST) != 0) return 0; return 1; } ") 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) SET(HAVE_PTHREAD_PROCESS_SHARED 1) ENDIF(_CAN_RUN EQUAL 1) 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) 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) 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) # Some hack for libevent 2.0 CHECK_C_SOURCE_COMPILES ("#include #if _EVENT_NUMERIC_VERSION < 0x02000000 #error Unsupported #endif int main() { return 0;}" HAVE_LIBEVENT2) IF(NOT CMAKE_SYSTEM_NAME STREQUAL "SunOS") 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) CHECK_INCLUDE_FILES(sys/timeb.h HAVE_SYS_TIMEB_H) ENDIF(HAVE_CLOCK_GETTIME) # Check asm pause instruction CHECK_C_SOURCE_COMPILES ("#include int main (int argc, char **argv) { __asm __volatile(\"pause\"); return 0; }" HAVE_ASM_PAUSE) ENDIF(NOT CMAKE_SYSTEM_NAME STREQUAL "SunOS") # Check queue.h compatibility IF(NOT HAVE_COMPATIBLE_QUEUE_H) INCLUDE_DIRECTORIES(compat) ENDIF(NOT HAVE_COMPATIBLE_QUEUE_H) IF(NOT DESTDIR) SET(DESTDIR $ENV{DESTDIR}) ENDIF(NOT DESTDIR) # Try to detect tip version from hg SET(ID "unknown") FIND_PROGRAM(HG "git") IF(HG) EXECUTE_PROCESS(COMMAND "${HG}" rev-parse --verify HEAD WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE HG_ID ERROR_QUIET) IF(HG_ID) STRING(SUBSTRING "${HG_ID}" 0 10 RSPAMD_ID) MESSAGE(STATUS "Git revision: ${RSPAMD_ID}") 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 RSPAMD_ID) ENDIF(HG_ID) ENDIF(HG_ARCH) 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 RSPAMD_ID) ENDIF(HG_ID) ENDIF(HG_ARCH) ENDIF(HG) ################################ SOURCES SECTION ########################### INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src" "${CMAKE_BINARY_DIR}/src" "${CMAKE_BINARY_DIR}/src/libcryptobox" "${CMAKE_SOURCE_DIR}/contrib/libucl" "${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/siphash" "${CMAKE_SOURCE_DIR}/contrib/blake2" "${CMAKE_SOURCE_DIR}/contrib/librdns") ################################ SUBDIRS SECTION ########################### ADD_SUBDIRECTORY(contrib/lgpl) IF(GLIB_COMPAT) INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/contrib/lgpl") ENDIF(GLIB_COMPAT) ADD_DEFINITIONS(-DHAVE_CONFIG_H) LIST(APPEND RSPAMD_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") LIST(APPEND RSPAMD_REQUIRED_LIBRARIES pcre) 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) LIST(APPEND RSPAMD_REQUIRED_LIBRARIES siphash) LIST(APPEND RSPAMD_REQUIRED_LIBRARIES blake2) LIST(APPEND RSPAMD_REQUIRED_LIBRARIES sqlite3) IF(OPENSSL_FOUND) LIST(APPEND RSPAMD_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) ENDIF(OPENSSL_FOUND) IF(HAVE_FETCH_H) LIST(APPEND RSPAMD_REQUIRED_LIBRARIES fetch) ENDIF(HAVE_FETCH_H) LIST(APPEND RSPAMD_REQUIRED_LIBRARIES event) IF(HAVE_LIBEVENT2) LIST(APPEND RSPAMD_REQUIRED_LIBRARIES event_pthreads) ENDIF(HAVE_LIBEVENT2) IF(WITH_DB) LIST(APPEND RSPAMD_REQUIRED_LIBRARIES db) ENDIF(WITH_DB) LIST(APPEND RSPAMD_REQUIRED_LIBRARIES "${LUA_LIBRARY}") IF(ENABLE_GPERF_TOOLS MATCHES "ON") LIST(APPEND RSPAMD_REQUIRED_LIBRARIES profiler) ENDIF(ENABLE_GPERF_TOOLS MATCHES "ON") LIST(APPEND RSPAMD_REQUIRED_LIBRARIES hiredis) IF(GLIB_COMPAT) LIST(APPEND RSPAMD_REQUIRED_LIBRARIES glibadditions) ENDIF(GLIB_COMPAT) ADD_SUBDIRECTORY(contrib/xxhash) ADD_SUBDIRECTORY(contrib/cdb) ADD_SUBDIRECTORY(contrib/http-parser) ADD_SUBDIRECTORY(contrib/libottery) ADD_SUBDIRECTORY(contrib/snowball) ADD_SUBDIRECTORY(contrib/siphash) ADD_SUBDIRECTORY(contrib/blake2) ADD_SUBDIRECTORY(contrib/libucl) ADD_SUBDIRECTORY(contrib/librdns) ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(test) ############################ TARGETS SECTION ############################### CONFIGURE_FILE(config.h.in src/config.h) CONFIGURE_FILE(contrib/exim/local_scan.c.in contrib/exim/local_scan_rspamd.c @ONLY) SET(CONFFILES conf/composites.conf conf/logging.conf conf/metrics.conf conf/modules.conf conf/options.conf conf/rspamd.conf conf/statistic.conf conf/workers.conf conf/2tld.inc conf/surbl-whitelist.inc) ##################### INSTALLATION ########################################## # Binaries # Configs 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)") # Install configs only if they are unchanged LIST(LENGTH CONFFILES CONFLIST_COUNT) MATH(EXPR CONFLIST_MAX ${CONFLIST_COUNT}-1) FOREACH(CONF_IDX RANGE ${CONFLIST_MAX}) LIST(GET CONFFILES ${CONF_IDX} CONF_FILE) IF(BUILD_PORT) INSTALL_IF_NOT_EXISTS(${CONF_FILE} ${CONFDIR} ${CONF_FILE} ".sample") ELSE(BUILD_PORT) INSTALL_IF_NOT_EXISTS(${CONF_FILE} ${CONFDIR} ${CONF_FILE} "") ENDIF(BUILD_PORT) IF(INSTALL_EXAMPLES MATCHES "ON") INSTALL(FILES ${CONF_FILE} DESTINATION ${EXAMPLESDIR}) ENDIF(INSTALL_EXAMPLES MATCHES "ON") ENDFOREACH(CONF_IDX RANGE ${CONFLIST_MAX}) # Main config is special due to systemd IF(WANT_SYSTEMD_UNITS MATCHES "ON") SET(MAIN_CONF "conf/rspamd.systemd.conf") ELSE(WANT_SYSTEMD_UNITS MATCHES "ON") SET(MAIN_CONF "conf/rspamd.sysvinit.conf") ENDIF(WANT_SYSTEMD_UNITS MATCHES "ON") 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) # Debian is also special IF(DEBIAN_BUILD) INSTALL_IF_NOT_EXISTS("conf/rspamd.sysvinit.conf" ${CONFDIR} "rspamd.sysvinit.conf" "") ENDIF(DEBIAN_BUILD) IF(INSTALL_EXAMPLES MATCHES "ON") INSTALL(FILES ${MAIN_CONF} DESTINATION ${EXAMPLESDIR}) ENDIF(INSTALL_EXAMPLES MATCHES "ON") # Lua plugins FILE(GLOB LUA_PLUGINS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/lua" "${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/lua/*.lua" ) FOREACH(LUA_PLUGIN ${LUA_PLUGINS}) GET_FILENAME_COMPONENT(_rp ${LUA_PLUGIN} PATH) INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${PLUGINSDIR}/lua/${_rp})") INSTALL(FILES "src/plugins/lua/${LUA_PLUGIN}" DESTINATION ${PLUGINSDIR}/lua/${_rp}) ENDFOREACH(LUA_PLUGIN) # Install lua fun library INSTALL(FILES "contrib/lua-fun/fun.lua" DESTINATION ${PLUGINSDIR}/lua) # Lua config INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${CONFDIR}/lua)") FILE(GLOB_RECURSE LUA_CONFIGS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/conf/lua" "${CMAKE_CURRENT_SOURCE_DIR}/conf/lua/*.lua") FOREACH(LUA_CONF ${LUA_CONFIGS}) GET_FILENAME_COMPONENT(_rp ${LUA_CONF} PATH) INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${CONFDIR}/lua/${_rp})") INSTALL(FILES "conf/lua/${LUA_CONF}" DESTINATION ${CONFDIR}/lua/${_rp}) ENDFOREACH(LUA_CONF) # systemd unit IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND WANT_SYSTEMD_UNITS MATCHES "ON") INSTALL(FILES "rspamd.service" DESTINATION ${SYSTEMDDIR}) INSTALL(FILES "rspamd.socket" DESTINATION ${SYSTEMDDIR}) ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND WANT_SYSTEMD_UNITS MATCHES "ON") # Manual pages INSTALL(FILES "doc/rspamd.8" DESTINATION ${MANDIR}/man8) INSTALL(FILES "doc/rspamc.1" DESTINATION ${MANDIR}/man1) # Install webui IF(INSTALL_WEBUI MATCHES "ON") INSTALL(DIRECTORY "interface/" DESTINATION ${WWWDIR} PATTERN ".git" EXCLUDE) ENDIF(INSTALL_WEBUI MATCHES "ON") ADD_CUSTOM_TARGET(dist ${CMAKE_SOURCE_DIR}/dist.sh "${CMAKE_BINARY_DIR}/rspamd-${RSPAMD_VERSION}.tar.xz" COMMENT "Create source distribution" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) IF(NOT DEBIAN_BUILD) ADD_CUSTOM_TARGET(check DEPENDS rspamd-test) ADD_CUSTOM_TARGET(run-test DEPENDS check COMMAND test/rspamd-test) ENDIF(NOT DEBIAN_BUILD)