You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CMakeLists.txt 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787
  1. #
  2. # Rspamd - rapid antispam system
  3. #
  4. # Cmake configuration file
  5. #
  6. ############################# INITIAL SECTION #############################################
  7. CMAKE_MINIMUM_REQUIRED(VERSION 3.12 FATAL_ERROR)
  8. SET(RSPAMD_VERSION_MAJOR 3)
  9. SET(RSPAMD_VERSION_MINOR 6)
  10. # Keep two digits all the time
  11. SET(RSPAMD_VERSION_MAJOR_NUM ${RSPAMD_VERSION_MAJOR}0)
  12. SET(RSPAMD_VERSION_MINOR_NUM ${RSPAMD_VERSION_MINOR}0)
  13. IF(GIT_ID)
  14. SET(GIT_VERSION 1)
  15. SET(RSPAMD_ID "${GIT_ID}")
  16. ENDIF()
  17. SET(RSPAMD_VERSION "${RSPAMD_VERSION_MAJOR}.${RSPAMD_VERSION_MINOR}")
  18. PROJECT(rspamd VERSION "${RSPAMD_VERSION}" LANGUAGES C CXX ASM)
  19. CMAKE_POLICY(SET CMP0075 NEW)
  20. # This is supported merely with cmake 3.1
  21. SET(CMAKE_C_STANDARD 11)
  22. SET(CMAKE_CXX_STANDARD 20)
  23. SET(CMAKE_C_STANDARD_REQUIRED ON)
  24. SET(CMAKE_CXX_STANDARD_REQUIRED ON)
  25. LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/")
  26. SET(RSPAMD_MASTER_SITE_URL "https://rspamd.com")
  27. IF(NOT RSPAMD_USER)
  28. SET(RSPAMD_USER "nobody")
  29. SET(RSPAMD_GROUP "nobody")
  30. ENDIF(NOT RSPAMD_USER)
  31. # Default for SysV Init
  32. SET(RSPAMD_WORKER_NORMAL "*:11333")
  33. SET(RSPAMD_WORKER_CONTROLLER "*:11334")
  34. ############################# OPTIONS SECTION #############################################
  35. OPTION(ENABLE_LUAJIT "Link with libluajit [default: ON]" ON)
  36. OPTION(ENABLE_URL_INCLUDE "Enable urls in ucl includes (requires libcurl or libfetch) [default: OFF]" OFF)
  37. OPTION(NO_SHARED "Build internal libs static [default: ON]" ON)
  38. OPTION(INSTALL_WEBUI "Install web interface [default: ON]" ON)
  39. OPTION(WANT_SYSTEMD_UNITS "Install systemd unit files on Linux [default: OFF]" OFF)
  40. OPTION(ENABLE_SNOWBALL "Enable snowball stemmer [default: ON]" ON)
  41. OPTION(ENABLE_CLANG_PLUGIN "Enable clang static analysing plugin [default: OFF]" OFF)
  42. OPTION(ENABLE_PCRE2 "Enable pcre2 instead of pcre [default: ON]" ON)
  43. OPTION(ENABLE_JEMALLOC "Build rspamd with jemalloc allocator [default: OFF]" OFF)
  44. OPTION(ENABLE_UTILS "Build rspamd internal utils [default: OFF]" OFF)
  45. OPTION(ENABLE_LIBUNWIND "Use libunwind to print crash traces [default: OFF]" OFF)
  46. OPTION(ENABLE_LUA_TRACE "Trace all Lua C API invocations [default: OFF]" OFF)
  47. OPTION(ENABLE_LUA_REPL "Enables Lua repl (requires C++11 compiler) [default: ON]" ON)
  48. OPTION(ENABLE_FASTTEXT "Link with FastText library [default: OFF]" OFF)
  49. OPTION(SYSTEM_ZSTD "Use system zstd instead of bundled one [default: OFF]" OFF)
  50. OPTION(SYSTEM_FMT "Use system fmt instead of bundled one [default: OFF]" OFF)
  51. OPTION(SYSTEM_DOCTEST "Use system doctest instead of bundled one [default: OFF]" OFF)
  52. OPTION(SYSTEM_XXHASH "Use system xxhash instead of bundled one [default: OFF]" OFF)
  53. ############################# INCLUDE SECTION #############################################
  54. INCLUDE(CheckIncludeFiles)
  55. INCLUDE(CheckFunctionExists)
  56. INCLUDE(CheckSymbolExists)
  57. INCLUDE(CheckCSourceCompiles)
  58. INCLUDE(CheckCSourceRuns)
  59. INCLUDE(CheckLibraryExists)
  60. INCLUDE(CheckCCompilerFlag)
  61. INCLUDE(CMakeParseArguments)
  62. INCLUDE(FindArch)
  63. INCLUDE(AsmOp)
  64. INCLUDE(FindRagel)
  65. INCLUDE(ProcessPackage)
  66. IF(NOT RAGEL_FOUND)
  67. MESSAGE(FATAL_ERROR "Ragel is required to build rspamd")
  68. ENDIF()
  69. FIND_PACKAGE(PkgConfig REQUIRED)
  70. FIND_PACKAGE(Perl REQUIRED)
  71. INCLUDE(Toolset)
  72. INCLUDE(Sanitizer)
  73. INCLUDE(ArchDep)
  74. INCLUDE(Paths)
  75. IF(ENABLE_PCRE2 MATCHES "ON")
  76. SET(WITH_PCRE2 1)
  77. # For utf8 API
  78. LIST(APPEND CMAKE_REQUIRED_DEFINITIONS "-DPCRE2_CODE_UNIT_WIDTH=8")
  79. ENDIF()
  80. ############################# CONFIG SECTION #############################################
  81. # Initial set
  82. # Prefer local include dirs to system ones
  83. INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/"
  84. "${CMAKE_SOURCE_DIR}/src"
  85. "${CMAKE_SOURCE_DIR}/src/libutil"
  86. "${CMAKE_SOURCE_DIR}/src/libserver"
  87. "${CMAKE_SOURCE_DIR}/src/libmime"
  88. "${CMAKE_SOURCE_DIR}/src/libstat"
  89. "${CMAKE_SOURCE_DIR}/src/libcryptobox"
  90. "${CMAKE_SOURCE_DIR}/contrib/libucl"
  91. "${CMAKE_SOURCE_DIR}/contrib/replxx/include"
  92. "${CMAKE_SOURCE_DIR}/contrib/uthash"
  93. "${CMAKE_SOURCE_DIR}/contrib/http-parser"
  94. "${CMAKE_SOURCE_DIR}/contrib/fpconv"
  95. "${CMAKE_SOURCE_DIR}/contrib/libottery"
  96. "${CMAKE_SOURCE_DIR}/contrib/cdb"
  97. "${CMAKE_SOURCE_DIR}/contrib/snowball/include"
  98. "${CMAKE_SOURCE_DIR}/contrib/librdns"
  99. "${CMAKE_SOURCE_DIR}/contrib/aho-corasick"
  100. "${CMAKE_SOURCE_DIR}/contrib/lc-btrie"
  101. "${CMAKE_SOURCE_DIR}/contrib/lua-lpeg"
  102. "${CMAKE_SOURCE_DIR}/contrib/frozen/include"
  103. "${CMAKE_SOURCE_DIR}/contrib/fu2/include"
  104. "${CMAKE_BINARY_DIR}/src" #Stored in the binary dir
  105. "${CMAKE_BINARY_DIR}/src/libcryptobox")
  106. SET(TAR "tar")
  107. INCLUDE(OSDep)
  108. # Now find libraries and headers
  109. LIST(APPEND RSPAMD_REQUIRED_LIBRARIES "m")
  110. LIST(APPEND RSPAMD_REQUIRED_LIBRARIES "pthread")
  111. IF(ENABLE_LUAJIT MATCHES "ON")
  112. ProcessPackage(LIBLUAJIT LIBRARY "luajit"
  113. "luajit-2.1"
  114. "luajit2.1"
  115. "luajit-2.0"
  116. "luajit2.0"
  117. "luajit-5.1"
  118. INCLUDE luajit.h INCLUDE_SUFFIXES
  119. "include/luajit-2.1"
  120. "include/luajit-2.0"
  121. "include/luajit"
  122. ROOT ${LUA_ROOT}
  123. MODULES luajit)
  124. SET(WITH_LUAJIT 1)
  125. ELSE(ENABLE_LUAJIT MATCHES "ON")
  126. ProcessPackage(LIBLUA LIBRARY "lua"
  127. "lua-5.3"
  128. LIB_SUFFIXES "lua5.3"
  129. INCLUDE lua.h INCLUDE_SUFFIXES
  130. "include/lua-5.3"
  131. "include/lua5.3"
  132. "include/lua53"
  133. "include/lua"
  134. ROOT ${LUA_ROOT}
  135. MODULES lua53
  136. OPTIONAL)
  137. IF (NOT WITH_LIBLUA)
  138. ProcessPackage(LIBLUA LIBRARY "lua"
  139. "lua-5.4"
  140. LIB_SUFFIXES "lua5.4"
  141. INCLUDE lua.h INCLUDE_SUFFIXES
  142. "include/lua-5.4"
  143. "include/lua5.4"
  144. "include/lua54"
  145. "include/lua"
  146. ROOT ${LUA_ROOT}
  147. MODULES lua54
  148. OPTIONAL)
  149. IF (NOT WITH_LIBLUA)
  150. ProcessPackage(LIBLUA LIBRARY "lua"
  151. "lua-5.2"
  152. LIB_SUFFIXES "lua5.2"
  153. INCLUDE lua.h INCLUDE_SUFFIXES
  154. "include/lua-5.2"
  155. "include/lua5.2"
  156. "include/lua52"
  157. "include/lua"
  158. ROOT ${LUA_ROOT}
  159. MODULES lua52
  160. OPTIONAL)
  161. IF (NOT WITH_LIBLUA)
  162. ProcessPackage(LIBLUA LIBRARY "lua"
  163. "lua-5.1"
  164. INCLUDE lua.h INCLUDE_SUFFIXES
  165. "include/lua-5.1"
  166. "include/lua5.1"
  167. "include/lua51"
  168. "include/lua"
  169. ROOT ${LUA_ROOT}
  170. MODULES lua51)
  171. ENDIF()
  172. ENDIF()
  173. ENDIF()
  174. ENDIF(ENABLE_LUAJIT MATCHES "ON")
  175. IF(ENABLE_JEMALLOC MATCHES "ON" AND NOT SANITIZE)
  176. ProcessPackage(JEMALLOC LIBRARY jemalloc_pic jemalloc INCLUDE jemalloc.h INCLUDE_SUFFIXES include/jemalloc
  177. ROOT ${JEMALLOC_ROOT_DIR})
  178. SET(WITH_JEMALLOC "1")
  179. ENDIF()
  180. IF(ENABLE_LIBUNWIND MATCHES "ON")
  181. ProcessPackage(LIBUNWIND LIBRARY unwind INCLUDE libunwind.h INCLUDE_SUFFIXES include/libunwind
  182. ROOT ${LIBUNWIND_ROOT_DIR} MODULES libunwind)
  183. SET(WITH_LIBUNWIND "1")
  184. ENDIF()
  185. ProcessPackage(GLIB2 LIBRARY glib-2.0 INCLUDE glib.h
  186. INCLUDE_SUFFIXES include/glib include/glib-2.0
  187. ROOT ${GLIB_ROOT_DIR} MODULES glib-2.0>=2.28)
  188. IF(ENABLE_PCRE2 MATCHES "ON")
  189. ProcessPackage(PCRE LIBRARY pcre2 pcre2-8 INCLUDE pcre2.h INCLUDE_SUFFIXES include/pcre2
  190. ROOT ${PCRE_ROOT_DIR} MODULES pcre2 pcre2-8 libpcre2 libpcre2-8)
  191. ELSE()
  192. ProcessPackage(PCRE LIBRARY pcre INCLUDE pcre.h INCLUDE_SUFFIXES include/pcre
  193. ROOT ${PCRE_ROOT_DIR} MODULES pcre libpcre pcre3 libpcre3)
  194. ENDIF()
  195. ProcessPackage(SQLITE3 LIBRARY sqlite3 INCLUDE sqlite3.h INCLUDE_SUFFIXES include/sqlite3 include/sqlite
  196. ROOT ${SQLITE3_ROOT_DIR} MODULES sqlite3 sqlite)
  197. ProcessPackage(ICUDATA LIBRARY icudata INCLUDE unicode/ucnv.h
  198. ROOT ${ICU_ROOT_DIR} MODULES icu-uc)
  199. ProcessPackage(ICUC LIBRARY icuuc INCLUDE unicode/ucnv.h
  200. ROOT ${ICU_ROOT_DIR} MODULES icu-uc)
  201. ProcessPackage(ICUIO LIBRARY icuio INCLUDE unicode/ucnv.h
  202. ROOT ${ICU_ROOT_DIR} MODULES icu-io)
  203. ProcessPackage(ICUI18N LIBRARY icui18n INCLUDE unicode/ucnv.h
  204. ROOT ${ICU_ROOT_DIR} MODULES icu-i18n)
  205. ProcessPackage(LIBCRYPT LIBRARY crypto INCLUDE openssl/evp.h
  206. ROOT ${OPENSSL_ROOT_DIR} MODULES openssl libcrypt)
  207. ProcessPackage(LIBSSL LIBRARY ssl INCLUDE openssl/ssl.h
  208. ROOT ${OPENSSL_ROOT_DIR} MODULES openssl libssl)
  209. ProcessPackage(LIBZ LIBRARY z INCLUDE zlib.h INCLUDE_SUFFIXES include/zlib
  210. ROOT ${LIBZ_ROOT_DIR} MODULES z)
  211. ProcessPackage(SODIUM LIBRARY sodium INCLUDE sodium.h
  212. INCLUDE_SUFFIXES include/libsodium include/sodium
  213. ROOT ${LIBSODIUM_ROOT_DIR} MODULES libsodium>=1.0.0)
  214. if(ENABLE_FASTTEXT MATCHES "ON")
  215. ProcessPackage(FASTTEXT LIBRARY fasttext INCLUDE fasttext.h
  216. INCLUDE_SUFFIXES include/fasttext
  217. ROOT ${FASTTEXT_ROOT_DIR} MODULES fasttext)
  218. SET(WITH_FASTTEXT "1")
  219. endif()
  220. include (CompilerWarnings)
  221. include (Hyperscan)
  222. include (Openblas)
  223. IF(ENABLE_LUA_TRACE)
  224. SET(WITH_LUA_TRACE 1)
  225. ENDIF(ENABLE_LUA_TRACE)
  226. SET(CMAKE_C_FLAGS "${CMAKE_C_OPT_FLAGS} ${CMAKE_C_FLAGS}")
  227. SET(CMAKE_CXX_FLAGS "${CMAKE_C_OPT_FLAGS} ${CMAKE_CXX_FLAGS}")
  228. ADD_DEFINITIONS(-DHAVE_CONFIG_H)
  229. ADD_DEFINITIONS(-DDOCTEST_CONFIG_NO_MULTI_LANE_ATOMICS)
  230. ADD_DEFINITIONS(-DFMT_HEADER_ONLY)
  231. # Workaround for https://github.com/onqtam/doctest/issues/356
  232. ADD_DEFINITIONS(-DDOCTEST_CONFIG_USE_STD_HEADERS)
  233. ADD_DEFINITIONS(-DU_CHARSET_IS_UTF8)
  234. # Check platform specific includes
  235. CHECK_INCLUDE_FILES(sys/types.h HAVE_SYS_TYPES_H)
  236. CHECK_INCLUDE_FILES(sys/uio.h HAVE_SYS_UIO_H)
  237. CHECK_INCLUDE_FILES(fcntl.h HAVE_FCNTL_H)
  238. CHECK_INCLUDE_FILES(math.h HAVE_MATH_H)
  239. CHECK_INCLUDE_FILES(stdio.h HAVE_STDIO_H)
  240. CHECK_INCLUDE_FILES(stdlib.h HAVE_STDLIB_H)
  241. CHECK_INCLUDE_FILES(string.h HAVE_STRING_H)
  242. CHECK_INCLUDE_FILES(strings.h HAVE_STRINGS_H)
  243. CHECK_INCLUDE_FILES(time.h HAVE_TIME_H)
  244. CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H)
  245. CHECK_INCLUDE_FILES(stdint.h HAVE_STDINT_H)
  246. CHECK_INCLUDE_FILES(inttypes.h HAVE_INTTYPES_H)
  247. CHECK_INCLUDE_FILES(stdbool.h HAVE_STDBOOL_H)
  248. CHECK_INCLUDE_FILES(endian.h HAVE_ENDIAN_H)
  249. CHECK_INCLUDE_FILES(sys/endian.h HAVE_SYS_ENDIAN_H)
  250. CHECK_INCLUDE_FILES(machine/endian.h HAVE_MACHINE_ENDIAN_H)
  251. CHECK_INCLUDE_FILES(sys/socket.h HAVE_SYS_SOCKET_H)
  252. CHECK_INCLUDE_FILES(sys/mman.h HAVE_SYS_MMAN_H)
  253. CHECK_INCLUDE_FILES(sys/un.h HAVE_SYS_UN_H)
  254. CHECK_INCLUDE_FILES(sys/stat.h HAVE_SYS_STAT_H)
  255. CHECK_INCLUDE_FILES(sys/wait.h HAVE_SYS_WAIT_H)
  256. CHECK_INCLUDE_FILES(sys/param.h HAVE_SYS_PARAM_H)
  257. CHECK_INCLUDE_FILES(sys/file.h HAVE_SYS_FILE_H)
  258. CHECK_INCLUDE_FILES(sys/resource.h HAVE_SYS_RESOURCE_H)
  259. CHECK_INCLUDE_FILES(netinet/in.h HAVE_NETINET_IN_H)
  260. CHECK_INCLUDE_FILES(netinet/tcp.h HAVE_NETINET_TCP_H)
  261. CHECK_INCLUDE_FILES(arpa/inet.h HAVE_ARPA_INET_H)
  262. CHECK_INCLUDE_FILES(netdb.h HAVE_NETDB_H)
  263. CHECK_INCLUDE_FILES(syslog.h HAVE_SYSLOG_H)
  264. CHECK_INCLUDE_FILES(siginfo.h HAVE_SIGINFO_H)
  265. CHECK_INCLUDE_FILES(locale.h HAVE_LOCALE_H)
  266. CHECK_INCLUDE_FILES(libgen.h HAVE_LIBGEN_H)
  267. CHECK_INCLUDE_FILES(pwd.h HAVE_PWD_H)
  268. CHECK_INCLUDE_FILES(grp.h HAVE_GRP_H)
  269. CHECK_INCLUDE_FILES(glob.h HAVE_GLOB_H)
  270. CHECK_INCLUDE_FILES(poll.h HAVE_POLL_H)
  271. CHECK_INCLUDE_FILES(readpassphrase.h HAVE_READPASSPHRASE_H)
  272. CHECK_INCLUDE_FILES(termios.h HAVE_TERMIOS_H)
  273. CHECK_INCLUDE_FILES(paths.h HAVE_PATHS_H)
  274. CHECK_INCLUDE_FILES(ctype.h HAVE_CTYPE_H)
  275. CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H)
  276. CHECK_INCLUDE_FILES(cpuid.h HAVE_CPUID_H)
  277. CHECK_INCLUDE_FILES(dirent.h HAVE_DIRENT_H)
  278. CHECK_INCLUDE_FILES(ucontext.h HAVE_UCONTEXT_H)
  279. CHECK_INCLUDE_FILES(sys/ucontext.h HAVE_SYS_UCONTEXT_H) # OSX specific
  280. # Check platform API
  281. CHECK_FUNCTION_EXISTS(setproctitle HAVE_SETPROCTITLE)
  282. CHECK_FUNCTION_EXISTS(getpagesize HAVE_GETPAGESIZE)
  283. CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)
  284. CHECK_FUNCTION_EXISTS(flock HAVE_FLOCK)
  285. CHECK_LIBRARY_EXISTS(m tanh "" HAVE_TANH)
  286. CHECK_FUNCTION_EXISTS(mkstemp HAVE_MKSTEMP)
  287. CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
  288. # Check macros
  289. CHECK_SYMBOL_EXISTS(PATH_MAX limits.h HAVE_PATH_MAX)
  290. CHECK_SYMBOL_EXISTS(MAXPATHLEN sys/param.h HAVE_MAXPATHLEN)
  291. CHECK_SYMBOL_EXISTS(MAP_ANON sys/mman.h HAVE_MMAP_ANON)
  292. CHECK_SYMBOL_EXISTS(IPV6_V6ONLY "sys/socket.h;netinet/in.h" HAVE_IPV6_V6ONLY)
  293. CHECK_SYMBOL_EXISTS(posix_fallocate fcntl.h HAVE_POSIX_FALLOCATE)
  294. CHECK_SYMBOL_EXISTS(fallocate fcntl.h HAVE_FALLOCATE)
  295. CHECK_SYMBOL_EXISTS(_SC_NPROCESSORS_ONLN unistd.h HAVE_SC_NPROCESSORS_ONLN)
  296. CHECK_SYMBOL_EXISTS(setbit sys/param.h PARAM_H_HAS_BITSET)
  297. CHECK_SYMBOL_EXISTS(getaddrinfo "sys/types.h;sys/socket.h;netdb.h" HAVE_GETADDRINFO)
  298. CHECK_SYMBOL_EXISTS(sched_yield "sched.h" HAVE_SCHED_YIELD)
  299. CHECK_SYMBOL_EXISTS(nftw "sys/types.h;ftw.h" HAVE_NFTW)
  300. CHECK_SYMBOL_EXISTS(memrchr "string.h" HAVE_MEMRCHR)
  301. IF(ENABLE_PCRE2 MATCHES "ON")
  302. LIST(APPEND CMAKE_REQUIRED_INCLUDES "${PCRE_INCLUDE}")
  303. CHECK_SYMBOL_EXISTS(PCRE2_CONFIG_JIT "pcre2.h" HAVE_PCRE_JIT)
  304. ELSE()
  305. LIST(APPEND CMAKE_REQUIRED_INCLUDES "${PCRE_INCLUDE}")
  306. CHECK_SYMBOL_EXISTS(PCRE_CONFIG_JIT "pcre.h" HAVE_PCRE_JIT)
  307. ENDIF()
  308. CHECK_SYMBOL_EXISTS(SOCK_SEQPACKET "sys/types.h;sys/socket.h" HAVE_SOCK_SEQPACKET)
  309. CHECK_SYMBOL_EXISTS(O_NOFOLLOW "sys/types.h;sys/fcntl.h" HAVE_ONOFOLLOW)
  310. CHECK_SYMBOL_EXISTS(O_CLOEXEC "sys/types.h;sys/fcntl.h" HAVE_OCLOEXEC)
  311. # OpenSSL specific stuff
  312. LIST(APPEND CMAKE_REQUIRED_INCLUDES "${LIBSSL_INCLUDE}")
  313. IF(LIBCRYPT_LIBRARY_PATH)
  314. SET(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};-L${LIBCRYPT_LIBRARY_PATH};${LIBCRYPT_LIBRARY}")
  315. SET(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};-L${LIBSSL_LIBRARY_PATH};${LIBSSL_LIBRARY}")
  316. ELSE()
  317. SET(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};-lcrypt;-lssl")
  318. ENDIF()
  319. CHECK_SYMBOL_EXISTS(SSL_set_tlsext_host_name "openssl/ssl.h" HAVE_SSL_TLSEXT_HOSTNAME)
  320. CHECK_SYMBOL_EXISTS(FIPS_mode "openssl/crypto.h" HAVE_FIPS_MODE)
  321. CHECK_SYMBOL_EXISTS(dirfd "sys/types.h;unistd.h;dirent.h" HAVE_DIRFD)
  322. CHECK_SYMBOL_EXISTS(fpathconf "sys/types.h;unistd.h" HAVE_FPATHCONF)
  323. CHECK_SYMBOL_EXISTS(sigaltstack "signal.h" HAVE_SIGALTSTACK)
  324. CHECK_SYMBOL_EXISTS(open_memstream "stdio.h" HAVE_OPENMEMSTREAM)
  325. CHECK_SYMBOL_EXISTS(fmemopen "stdio.h" HAVE_FMEMOPEN)
  326. CHECK_SYMBOL_EXISTS(clock_getcpuclockid "sys/types.h;time.h" HAVE_CLOCK_GETCPUCLOCKID)
  327. CHECK_SYMBOL_EXISTS(RUSAGE_SELF "sys/types.h;sys/resource.h" HAVE_RUSAGE_SELF)
  328. CHECK_SYMBOL_EXISTS(ffsll "strings.h" HAVE_FFSLL)
  329. IF(ENABLE_PCRE2 MATCHES "ON")
  330. IF(HAVE_PCRE_JIT)
  331. SET(HAVE_PCRE_JIT_FAST 1)
  332. ENDIF()
  333. ELSE()
  334. LIST(APPEND CMAKE_REQUIRED_INCLUDES "${PCRE_INCLUDE}")
  335. IF(PCRE_LIBRARY_PATH)
  336. SET(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};-L${PCRE_LIBRARY_PATH};${PCRE_LIBRARY}")
  337. ELSE(PCRE_LIBRARY_PATH)
  338. SET(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};-lpcre")
  339. ENDIF(PCRE_LIBRARY_PATH)
  340. # Some PCRE implementations are lacking of pcre_jit_exec fast path
  341. SET(_PCRE_FAST_TEST "
  342. #include \"pcre.h\"
  343. int main (void)
  344. {
  345. int rc;
  346. int ovector[30];
  347. pcre *re;
  348. pcre_extra *extra;
  349. pcre_jit_stack *jit_stack;
  350. re = pcre_compile(\"abc\", 0, NULL, NULL, NULL);
  351. extra = pcre_study(re, PCRE_STUDY_JIT_COMPILE, NULL);
  352. jit_stack = pcre_jit_stack_alloc(32*1024, 512*1024);
  353. pcre_assign_jit_stack(extra, NULL, jit_stack);
  354. rc = pcre_jit_exec(re, extra, \"abc\", 3, 0, 0, ovector, 30, jit_stack);
  355. return rc;
  356. }
  357. ")
  358. CHECK_C_SOURCE_COMPILES("${_PCRE_FAST_TEST}" HAVE_PCRE_JIT_FAST)
  359. IF(HAVE_PCRE_JIT_FAST)
  360. MESSAGE(STATUS "pcre_jit_exec is supported")
  361. ELSE(HAVE_PCRE_JIT_FAST)
  362. MESSAGE(STATUS "pcre_jit_exec is -NOT- supported")
  363. ENDIF(HAVE_PCRE_JIT_FAST)
  364. ENDIF()
  365. CHECK_C_COMPILER_FLAG(-fPIC SUPPORT_FPIC)
  366. IF(SUPPORT_FPIC)
  367. ADD_COMPILE_OPTIONS("-fPIC")
  368. ENDIF(SUPPORT_FPIC)
  369. FILE(WRITE ${CMAKE_BINARY_DIR}/pthread_setpshared.c "
  370. #include <pthread.h>
  371. #include <stdlib.h>
  372. int main (void)
  373. {
  374. pthread_mutexattr_t mattr;
  375. if (pthread_mutexattr_init(&mattr) != 0) return 0;
  376. if (pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED) != 0) return 0;
  377. if (pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST) != 0) return 0;
  378. return 1;
  379. }
  380. ")
  381. TRY_RUN(_CAN_RUN _CAN_COMPILE
  382. "${CMAKE_BINARY_DIR}" "${CMAKE_BINARY_DIR}/pthread_setpshared.c"
  383. CMAKE_FLAGS CMAKE_C_FLAGS="-pthread")
  384. IF(_CAN_RUN EQUAL 1)
  385. SET(HAVE_PTHREAD_PROCESS_SHARED 1 CACHE INTERNAL "")
  386. ENDIF(_CAN_RUN EQUAL 1)
  387. IF(HAVE_PTHREAD_PROCESS_SHARED)
  388. MESSAGE(STATUS "pthread_mutexattr_setpshared is supported")
  389. ELSE(HAVE_PTHREAD_PROCESS_SHARED)
  390. MESSAGE(STATUS "pthread_mutexattr_setpshared is -NOT- supported")
  391. ENDIF(HAVE_PTHREAD_PROCESS_SHARED)
  392. IF(NOT HAVE_GETADDRINFO)
  393. MESSAGE(FATAL_ERROR "Your system does not support getaddrinfo call, please consider upgrading it to run rspamd")
  394. ENDIF(NOT HAVE_GETADDRINFO)
  395. IF(HAVE_SIGINFO_H)
  396. CHECK_SYMBOL_EXISTS(SA_SIGINFO "signal.h;siginfo.h" HAVE_SA_SIGINFO)
  397. ELSE(HAVE_SIGINFO_H)
  398. CHECK_SYMBOL_EXISTS(SA_SIGINFO "signal.h" HAVE_SA_SIGINFO)
  399. ENDIF(HAVE_SIGINFO_H)
  400. IF(NOT CMAKE_SYSTEM_NAME STREQUAL "SunOS")
  401. IF(HAVE_CLOCK_GETTIME)
  402. CHECK_SYMBOL_EXISTS(CLOCK_PROCESS_CPUTIME_ID time.h HAVE_CLOCK_PROCESS_CPUTIME_ID)
  403. CHECK_SYMBOL_EXISTS(CLOCK_VIRTUAL time.h HAVE_CLOCK_VIRTUAL)
  404. ELSE(HAVE_CLOCK_GETTIME)
  405. CHECK_INCLUDE_FILES(sys/timeb.h HAVE_SYS_TIMEB_H)
  406. ENDIF(HAVE_CLOCK_GETTIME)
  407. ENDIF(NOT CMAKE_SYSTEM_NAME STREQUAL "SunOS")
  408. CHECK_C_SOURCE_RUNS("
  409. #include <stdbool.h>
  410. int main(int argc, char **argv) {
  411. int a = 0, b = 0;
  412. if (__atomic_compare_exchange_n(&a, &b, 1, false, __ATOMIC_RELEASE, __ATOMIC_RELAXED)) {
  413. return 0;
  414. }
  415. return -1;
  416. }
  417. " HAVE_ATOMIC_BUILTINS)
  418. IF(NOT HAVE_ATOMIC_BUILTINS)
  419. MESSAGE(STATUS "atomic builtins are -NOT- supported")
  420. ELSE()
  421. MESSAGE(STATUS "atomic builtins are supported")
  422. ENDIF()
  423. CHECK_C_SOURCE_RUNS("
  424. #include <x86intrin.h>
  425. int main(int argc, char **argv) {
  426. __builtin_ia32_lfence ();
  427. if (__builtin_ia32_rdtsc()) {
  428. return 0;
  429. }
  430. return -1;
  431. }
  432. " HAVE_RDTSC)
  433. IF(NOT HAVE_RDTSC)
  434. MESSAGE(STATUS "rdtsc intrinsic is -NOT- supported")
  435. ELSE()
  436. MESSAGE(STATUS "rdtsc intrinsic is supported")
  437. ENDIF()
  438. IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  439. # In linux, we need to mount /run/shm to test which could be unavailable
  440. # on a build system. On the other hand, we know that linux has stupid
  441. # but compatible shmem support, so we assume this macro as true
  442. SET(HAVE_SANE_SHMEM 1)
  443. CHECK_C_SOURCE_COMPILES ("#define _GNU_SOURCE
  444. #include <sys/socket.h>
  445. int main (int argc, char **argv) {
  446. return ((int*)(&recvmmsg))[argc];
  447. }" HAVE_RECVMMSG)
  448. CHECK_C_SOURCE_COMPILES ("#define _GNU_SOURCE
  449. #include <fcntl.h>
  450. int main (int argc, char **argv) {
  451. return ((int*)(&readahead))[argc];
  452. }" HAVE_READAHEAD)
  453. ELSE()
  454. CHECK_C_SOURCE_RUNS("
  455. #include <sys/mman.h>
  456. #include <fcntl.h>
  457. #include <unistd.h>
  458. #define TEST_NAME \"/test-shmem-work\"
  459. int
  460. main (int argc, char **argv)
  461. {
  462. int fd;
  463. fd = shm_open (TEST_NAME, O_RDWR | O_CREAT | O_EXCL, 00600);
  464. if (fd == -1) {
  465. return -1;
  466. }
  467. if (ftruncate (fd, 100) == -1) {
  468. shm_unlink (TEST_NAME);
  469. close (fd);
  470. return -1;
  471. }
  472. if (ftruncate (fd, 200) == -1) {
  473. shm_unlink (TEST_NAME);
  474. close (fd);
  475. return -1;
  476. }
  477. if (ftruncate (fd, 300) == -1) {
  478. shm_unlink (TEST_NAME);
  479. close (fd);
  480. return -1;
  481. }
  482. close (fd);
  483. shm_unlink (TEST_NAME);
  484. return 0;
  485. }
  486. " HAVE_SANE_SHMEM)
  487. IF(NOT HAVE_SANE_SHMEM)
  488. MESSAGE(STATUS "shmem support is NOT compatible with POSIX")
  489. ELSE()
  490. MESSAGE(STATUS "shmem support is compatible with POSIX")
  491. ENDIF()
  492. ENDIF()
  493. IF(ENABLE_URL_INCLUDE MATCHES "ON")
  494. FIND_LIBRARY(LIBFETCH_LIBRARY HINTS "${RSPAMD_SEARCH_PATH}"
  495. NAMES fetch PATHS PATH_SUFFIXES lib64 lib
  496. PATHS ${RSPAMD_DEFAULT_LIBRARY_PATHS}
  497. DOC "Path where the libfetch library can be found")
  498. IF(LIBFETCH_LIBRARY)
  499. FIND_FILE(HAVE_FETCH_H HINTS "${RSPAMD_SEARCH_PATH}"
  500. NAMES fetch.h
  501. PATH_SUFFIXES include
  502. PATHS ${RSPAMD_DEFAULT_INCLUDE_PATHS}
  503. DOC "Path to libfetch header")
  504. ELSE(LIBFETCH_LIBRARY)
  505. # Try to find libcurl
  506. ProcessPackage(CURL LIBRARY curl INCLUDE curl.h INCLUDE_SUFFIXES include/curl
  507. ROOT ${CURL_ROOT})
  508. IF(NOT WITH_CURL)
  509. MESSAGE(WARNING "Neither libcurl nor libfetch were found, no support of URL includes in configuration")
  510. ENDIF(NOT WITH_CURL)
  511. ENDIF(LIBFETCH_LIBRARY)
  512. ENDIF(ENABLE_URL_INCLUDE MATCHES "ON")
  513. IF(NOT DESTDIR)
  514. SET(DESTDIR $ENV{DESTDIR})
  515. ENDIF(NOT DESTDIR)
  516. ################################ SUBDIRS SECTION ###########################
  517. ADD_SUBDIRECTORY(contrib/hiredis)
  518. INCLUDE_DIRECTORIES(BEFORE "${CMAKE_SOURCE_DIR}/contrib/hiredis")
  519. LIST(APPEND RSPAMD_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
  520. IF(HAVE_FETCH_H)
  521. LIST(APPEND RSPAMD_REQUIRED_LIBRARIES fetch)
  522. ENDIF(HAVE_FETCH_H)
  523. LIST(APPEND RSPAMD_REQUIRED_LIBRARIES "${LUA_LIBRARY}")
  524. LIST(APPEND RSPAMD_REQUIRED_LIBRARIES ucl)
  525. LIST(APPEND RSPAMD_REQUIRED_LIBRARIES rdns)
  526. LIST(APPEND RSPAMD_REQUIRED_LIBRARIES ottery)
  527. LIST(APPEND RSPAMD_REQUIRED_LIBRARIES xxhash)
  528. IF(SYSTEM_XXHASH MATCHES "OFF")
  529. ADD_SUBDIRECTORY(contrib/xxhash)
  530. INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/contrib/xxhash")
  531. ELSE()
  532. ProcessPackage(XXHASH LIBRARY xxhash INCLUDE xxhash.h
  533. ROOT ${LIBXXHASH_ROOT_DIR} MODULES xxhash libxxhash)
  534. ENDIF()
  535. ADD_SUBDIRECTORY(contrib/cdb)
  536. ADD_SUBDIRECTORY(contrib/http-parser)
  537. ADD_SUBDIRECTORY(contrib/fpconv)
  538. ADD_SUBDIRECTORY(contrib/lc-btrie)
  539. ADD_SUBDIRECTORY(contrib/libottery)
  540. IF(SYSTEM_ZSTD MATCHES "OFF")
  541. ADD_SUBDIRECTORY(contrib/zstd)
  542. ELSE()
  543. ProcessPackage(LIBZSTD LIBRARY zstd INCLUDE zstd.h
  544. ROOT ${LIBZSTD_ROOT_DIR} MODULES zstd libzstd)
  545. ADD_DEFINITIONS(-DSYS_ZSTD)
  546. ENDIF()
  547. IF(ENABLE_SNOWBALL MATCHES "ON")
  548. ADD_SUBDIRECTORY(contrib/snowball)
  549. SET(WITH_SNOWBALL 1)
  550. ENDIF()
  551. ADD_SUBDIRECTORY(contrib/libucl)
  552. ADD_SUBDIRECTORY(contrib/librdns)
  553. ADD_SUBDIRECTORY(contrib/aho-corasick)
  554. ADD_SUBDIRECTORY(contrib/lua-lpeg)
  555. ADD_SUBDIRECTORY(contrib/t1ha)
  556. ADD_SUBDIRECTORY(contrib/libev)
  557. ADD_SUBDIRECTORY(contrib/kann)
  558. ADD_SUBDIRECTORY(contrib/fastutf8)
  559. ADD_SUBDIRECTORY(contrib/google-ced)
  560. IF(SYSTEM_FMT MATCHES "OFF")
  561. INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/contrib/fmt/include")
  562. ELSE()
  563. find_package(fmt)
  564. ENDIF()
  565. IF(SYSTEM_DOCTEST MATCHES "OFF")
  566. ADD_SUBDIRECTORY(contrib/doctest)
  567. INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/contrib/doctest")
  568. ELSE()
  569. find_package(doctest)
  570. ENDIF()
  571. IF (NOT WITH_LUAJIT)
  572. ADD_SUBDIRECTORY(contrib/lua-bit)
  573. ENDIF()
  574. IF (ENABLE_LUA_REPL MATCHES "ON")
  575. ADD_SUBDIRECTORY(contrib/replxx)
  576. SET(WITH_LUA_REPL 1)
  577. LIST(APPEND RSPAMD_REQUIRED_LIBRARIES rspamd-replxx)
  578. ENDIF()
  579. IF (ENABLE_SNOWBALL MATCHES "ON")
  580. LIST(APPEND RSPAMD_REQUIRED_LIBRARIES stemmer)
  581. ENDIF()
  582. LIST(APPEND RSPAMD_REQUIRED_LIBRARIES rspamd-hiredis)
  583. LIST(APPEND RSPAMD_REQUIRED_LIBRARIES rspamd-actrie)
  584. LIST(APPEND RSPAMD_REQUIRED_LIBRARIES rspamd-t1ha)
  585. LIST(APPEND RSPAMD_REQUIRED_LIBRARIES rspamd-ev)
  586. LIST(APPEND RSPAMD_REQUIRED_LIBRARIES rspamd-kann)
  587. LIST(APPEND RSPAMD_REQUIRED_LIBRARIES rspamd-ced)
  588. IF(ENABLE_CLANG_PLUGIN MATCHES "ON")
  589. ADD_SUBDIRECTORY(clang-plugin)
  590. ENDIF()
  591. ADD_SUBDIRECTORY(src)
  592. ADD_SUBDIRECTORY(test)
  593. ADD_SUBDIRECTORY(utils)
  594. ############################ TARGETS SECTION ###############################
  595. CONFIGURE_FILE(config.h.in src/config.h)
  596. ##################### INSTALLATION ##########################################
  597. # Binaries
  598. # Configs
  599. INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${CONFDIR})")
  600. INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${SHAREDIR})")
  601. INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${LUALIBDIR})")
  602. INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${PLUGINSDIR})")
  603. INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${RULESDIR})")
  604. # Install configs only if they are unchanged
  605. LIST(LENGTH CONFFILES CONFLIST_COUNT)
  606. MATH(EXPR CONFLIST_MAX ${CONFLIST_COUNT}-1)
  607. FILE(GLOB_RECURSE CONF_FILES RELATIVE "${CMAKE_SOURCE_DIR}/conf" CONFIGURE_DEPENDS
  608. "${CMAKE_SOURCE_DIR}/conf/*.conf"
  609. "${CMAKE_SOURCE_DIR}/conf/*.inc" )
  610. FOREACH(CONF_FILE ${CONF_FILES})
  611. GET_FILENAME_COMPONENT(_rp ${CONF_FILE} PATH)
  612. INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${CONFDIR}/${_rp})")
  613. INSTALL(FILES "${CMAKE_CURRENT_SOURCE_DIR}/conf/${CONF_FILE}"
  614. DESTINATION ${CONFDIR}/${_rp})
  615. ENDFOREACH(CONF_FILE)
  616. # Lua plugins
  617. FILE(GLOB LUA_PLUGINS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/lua" CONFIGURE_DEPENDS
  618. "${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/lua/*.lua" )
  619. FOREACH(LUA_PLUGIN ${LUA_PLUGINS})
  620. GET_FILENAME_COMPONENT(_rp ${LUA_PLUGIN} PATH)
  621. INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${PLUGINSDIR}/${_rp})")
  622. INSTALL(FILES "src/plugins/lua/${LUA_PLUGIN}" DESTINATION ${PLUGINSDIR}/${_rp})
  623. ENDFOREACH(LUA_PLUGIN)
  624. # Install TLD list
  625. INSTALL(FILES "contrib/publicsuffix/effective_tld_names.dat" DESTINATION
  626. "${SHAREDIR}")
  627. # Install languages data
  628. INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${SHAREDIR}/languages)")
  629. FILE(GLOB LANGUAGES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/languages-data/*.json")
  630. FOREACH(_LANG ${LANGUAGES})
  631. INSTALL(FILES "${_LANG}" DESTINATION ${SHAREDIR}/languages)
  632. ENDFOREACH()
  633. INSTALL(FILES "${CMAKE_CURRENT_SOURCE_DIR}/contrib/languages-data/stop_words" DESTINATION ${SHAREDIR}/languages)
  634. # Lua config
  635. FILE(GLOB_RECURSE LUA_CONFIGS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/rules" CONFIGURE_DEPENDS
  636. "${CMAKE_CURRENT_SOURCE_DIR}/rules/*.lua")
  637. FOREACH(LUA_CONF ${LUA_CONFIGS})
  638. GET_FILENAME_COMPONENT(_rp ${LUA_CONF} PATH)
  639. INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${RULESDIR}/${_rp})")
  640. INSTALL(FILES "rules/${LUA_CONF}" DESTINATION ${RULESDIR}/${_rp})
  641. ENDFOREACH(LUA_CONF)
  642. # Lua libs
  643. FILE(GLOB_RECURSE LUA_LIBS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/lualib" CONFIGURE_DEPENDS
  644. "${CMAKE_CURRENT_SOURCE_DIR}/lualib/*.lua")
  645. FOREACH(LUA_LIB ${LUA_LIBS})
  646. GET_FILENAME_COMPONENT(_rp ${LUA_LIB} PATH)
  647. INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${LUALIBDIR}/${_rp})")
  648. INSTALL(FILES "lualib/${LUA_LIB}" DESTINATION ${LUALIBDIR}/${_rp})
  649. ENDFOREACH(LUA_LIB)
  650. # Install lua fun library
  651. INSTALL(FILES "contrib/lua-fun/fun.lua" DESTINATION ${LUALIBDIR})
  652. INSTALL(FILES "contrib/lua-argparse/argparse.lua" DESTINATION ${LUALIBDIR})
  653. INSTALL(FILES "contrib/lua-tableshape/tableshape.lua" DESTINATION ${LUALIBDIR})
  654. INSTALL(FILES "contrib/lua-lupa/lupa.lua" DESTINATION ${LUALIBDIR})
  655. INSTALL(FILES "contrib/lua-lpeg/lpegre.lua" DESTINATION ${LUALIBDIR})
  656. # systemd unit
  657. IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND WANT_SYSTEMD_UNITS MATCHES "ON")
  658. INSTALL(FILES "rspamd.service" DESTINATION ${SYSTEMDDIR})
  659. ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND WANT_SYSTEMD_UNITS MATCHES "ON")
  660. # Manual pages
  661. INSTALL(FILES "doc/rspamd.8" DESTINATION ${MANDIR}/man8)
  662. INSTALL(FILES "doc/rspamc.1" DESTINATION ${MANDIR}/man1)
  663. INSTALL(FILES "doc/rspamadm.1" DESTINATION ${MANDIR}/man1)
  664. # Utils
  665. INSTALL(PROGRAMS "utils/rspamd_stats.pl" RENAME rspamd_stats DESTINATION bin)
  666. # Install webui
  667. IF(INSTALL_WEBUI MATCHES "ON")
  668. INSTALL(DIRECTORY "interface/" DESTINATION ${WWWDIR} PATTERN ".git" EXCLUDE)
  669. ENDIF(INSTALL_WEBUI MATCHES "ON")
  670. INSTALL(DIRECTORY "contrib/elastic/" DESTINATION "${SHAREDIR}/elastic" PATTERN ".git" EXCLUDE)
  671. ADD_CUSTOM_TARGET(dist ${CMAKE_SOURCE_DIR}/dist.sh
  672. "${CMAKE_BINARY_DIR}/rspamd-${RSPAMD_VERSION}.tar.xz" "${TAR}"
  673. COMMENT "Create source distribution"
  674. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
  675. IF(NOT DEBIAN_BUILD)
  676. ADD_CUSTOM_TARGET(check DEPENDS rspamd-test-cxx rspamd-test)
  677. ADD_CUSTOM_TARGET(run-test DEPENDS check
  678. COMMAND test/rspamd-test-cxx
  679. COMMAND sh -c 'LUA_PATH="${CMAKE_SOURCE_DIR}/lualib/?.lua\;${CMAKE_SOURCE_DIR}/lualib/?/?.lua\;${CMAKE_SOURCE_DIR}/lualib/?/init.lua\;${CMAKE_SOURCE_DIR}/contrib/lua-?/?.lua"
  680. test/rspamd-test -p /rspamd/lua')
  681. ENDIF(NOT DEBIAN_BUILD)
  682. # PVS Studio
  683. find_program(_PVS_STUDIO "pvs-studio-analyzer")
  684. if(_PVS_STUDIO)
  685. include(PVS-Studio)
  686. pvs_studio_add_target(TARGET ${PROJECT_NAME}.analyze
  687. ANALYZE ${PROJECT_NAME} rspamd-server rspamadm rspamc
  688. OUTPUT FORMAT errorfile
  689. LOG target_${PROJECT_NAME}.err)
  690. endif()