diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-11-09 18:51:25 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-11-09 18:51:25 +0000 |
commit | 5570704c53a565e9eb70e362ee341d6aacf8b823 (patch) | |
tree | abe233dc7aed3f7b66267bac172c15b0b43aea71 /CMakeLists.txt | |
parent | 7d7d5953c9b9a64acd6bf3bc5995992761a52deb (diff) | |
download | rspamd-5570704c53a565e9eb70e362ee341d6aacf8b823.tar.gz rspamd-5570704c53a565e9eb70e362ee341d6aacf8b823.zip |
Start implemetation of static analysis plugin
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 112 |
1 files changed, 59 insertions, 53 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e1af8555..f6b916f1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,7 @@ OPTION(INSTALL_EXAMPLES "Install examples [default: OFF]" OPTION(INSTALL_WEBUI "Install web interface [default: ON]" ON) OPTION(WANT_SYSTEMD_UNITS "Install systemd unit files on Linux [default: OFF]" OFF) OPTION(ENABLE_SNOWBALL "Enable snowball stemmer [default: ON]" ON) +OPTION(ENABLE_CLANG_PLUGIN "Enable clang static analysing plugin [default: OFF]" OFF) # Build optimized code for following CPU (default i386) #SET(CPU_TUNE "i686") @@ -171,23 +172,23 @@ MACRO(FindLua) HINTS "${RSPAMD_SEARCH_PATH}" "${LUA_ROOT}" $ENV{LUA_DIR} - PATH_SUFFIXES "include/luajit-2.0" - "include/luajit${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}" - "include/luajit${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" + PATH_SUFFIXES "include/luajit-2.0" + "include/luajit${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}" + "include/luajit${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" "include/luajit-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" - "include/luajit" - "include/lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}" - "include/lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" + "include/luajit" + "include/lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}" + "include/lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" "include/lua-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" include/lua include PATHS ${RSPAMD_DEFAULT_INCLUDE_PATHS} ) - FIND_LIBRARY(LUA_LIBRARY - NAMES luajit + FIND_LIBRARY(LUA_LIBRARY + NAMES luajit "luajit-2.0" "luajit2.0" "luajit${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}" - "luajit${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" + "luajit${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" "luajit-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" HINTS "${RSPAMD_SEARCH_PATH}" "${LUA_ROOT}" @@ -196,7 +197,7 @@ MACRO(FindLua) PATHS ${RSPAMD_DEFAULT_LIBRARY_PATHS} DOC "Lua library" ) - + IF(NOT LUA_LIBRARY OR NOT LUA_INCLUDE_DIR) MESSAGE(STATUS "Fallback from luajit to plain lua") SET(ENABLE_LUAJIT "OFF") @@ -205,16 +206,16 @@ MACRO(FindLua) HINTS "${RSPAMD_SEARCH_PATH}" "${LUA_ROOT}" $ENV{LUA_DIR} - PATH_SUFFIXES "include/lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}" - "include/lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" + PATH_SUFFIXES "include/lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}" + "include/lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" "include/lua-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" include/lua include PATHS ${RSPAMD_DEFAULT_INCLUDE_PATHS} ) - FIND_LIBRARY(LUA_LIBRARY - NAMES lua + FIND_LIBRARY(LUA_LIBRARY + NAMES lua "lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}" - "lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" + "lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" "lua-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" HINTS "${RSPAMD_SEARCH_PATH}" "${LUA_ROOT}" @@ -230,16 +231,16 @@ MACRO(FindLua) HINTS "${RSPAMD_SEARCH_PATH}" "${LUA_ROOT}" $ENV{LUA_DIR} - PATH_SUFFIXES "include/lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}" - "include/lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" + PATH_SUFFIXES "include/lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}" + "include/lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" "include/lua-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" include/lua include PATHS ${RSPAMD_DEFAULT_INCLUDE_PATHS} ) - FIND_LIBRARY(LUA_LIBRARY - NAMES lua + FIND_LIBRARY(LUA_LIBRARY + NAMES lua "lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}" - "lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" + "lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" "lua-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}" HINTS "${RSPAMD_SEARCH_PATH}" "${LUA_ROOT}" @@ -300,13 +301,13 @@ ENDFUNCTION(INSTALL_IF_NOT_EXISTS) # 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 -# LIBRARY - name of the library to check +# LIBRARY - name of the library to check # 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) - CMAKE_PARSE_ARGUMENTS(PKG "OPTIONAL" "ROOT;INCLUDE" + CMAKE_PARSE_ARGUMENTS(PKG "OPTIONAL" "ROOT;INCLUDE" "LIBRARY;INCLUDE_SUFFIXES;LIB_SUFFIXES;MODULES" ${ARGN}) IF(NOT PKG_LIBRARY) @@ -319,7 +320,7 @@ MACRO(ProcessPackage PKG_NAME) IF(NOT PKG_ROOT AND PKG_MODULES) PKG_SEARCH_MODULE(${PKG_NAME} ${PKG_MODULES}) ENDIF() - + IF(${PKG_NAME}_FOUND) MESSAGE(STATUS "Found package ${PKG_NAME} in pkg-config modules ${PKG_MODULES}") SET(WITH_${PKG_NAME} 1 CACHE INTERNAL "") @@ -359,7 +360,7 @@ MACRO(ProcessPackage PKG_NAME) MESSAGE(FATAL_ERROR "Cannot find library ${PKG_LIBRARY} for package ${PKG_NAME}") ENDIF() ENDIF(NOT _lib) - + FIND_PATH(_incl ${PKG_INCLUDE} HINTS ${PKG_ROOT} ${RSPAMD_SEARCH_PATH} PATH_SUFFIXES ${PKG_INCLUDE_SUFFIXES} include @@ -371,7 +372,7 @@ MACRO(ProcessPackage PKG_NAME) MESSAGE(FATAL_ERROR "Cannot find header ${PKG_INCLUDE} for package ${PKG_NAME}") ENDIF() ENDIF(NOT _incl) - + IF(_incl AND _lib) GET_FILENAME_COMPONENT(_lib_path "${_lib}" PATH) INCLUDE_DIRECTORIES("${_incl}") @@ -384,7 +385,7 @@ MACRO(ProcessPackage PKG_NAME) SET(WITH_${PKG_NAME} 1 CACHE INTERNAL "") MESSAGE(STATUS "Found package ${PKG_NAME} in '${_lib_path}' (${_lib}) and '${_incl}' (${PKG_INCLUDE}).") ENDIF() - + ELSE() MESSAGE(STATUS "Found package ${PKG_NAME} (cached)") INCLUDE_DIRECTORIES("${${PKG_NAME}_INCLUDE}") @@ -509,11 +510,11 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") SET(CMAKE_C_FLAGS "-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE ${CMAKE_C_FLAGS}") ENDIF(BUILD_CPU_MODE STREQUAL "32") # Workaround with architecture specific includes - IF(IS_DIRECTORY "/usr/include/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu/") + 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/") - + LIST(APPEND CMAKE_REQUIRED_LIBRARIES rt) LIST(APPEND CMAKE_REQUIRED_LIBRARIES dl) #XXX: gio bug workaround @@ -533,7 +534,7 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS") IF(NOT BUILD_CPU_MODE) SET (BUILD_CPU_MODE "32") ENDIF(NOT BUILD_CPU_MODE) - + IF("${CMAKE_C_COMPILER_ID}" MATCHES SunPro) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Xa -xregs=no%frameptr -xstrconst -xc99") SET(SUN_BUILD32 "-xtarget=generic") @@ -545,7 +546,7 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS") ENDIF(ENABLE_OPTIMIZATION MATCHES "ON") ELSE("${CMAKE_C_COMPILER_ID}" MATCHES SunPro) set(SUN_BUILD32 "-m32") - set(SUN_BUILD64 "-m64") + set(SUN_BUILD64 "-m64") ENDIF("${CMAKE_C_COMPILER_ID}" MATCHES SunPro) IF (BUILD_CPU_MODE STREQUAL "32") @@ -561,7 +562,7 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS") ENDIF (BUILD_CPU_MODE STREQUAL "32") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__EXTENSIONS__ -DSOLARIS -D_POSIX_SOURCE -D_POSIX_C_SOURCE=200112L") - + LIST(APPEND CMAKE_REQUIRED_LIBRARIES rt) LIST(APPEND CMAKE_REQUIRED_LIBRARIES dl) LIST(APPEND CMAKE_REQUIRED_LIBRARIES resolv) @@ -600,15 +601,15 @@ ELSE(ENABLE_LUAJIT MATCHES "ON") ENDIF(NOT LUA_FOUND) ENDIF(ENABLE_LUAJIT MATCHES "ON") -ProcessPackage(GLIB2 LIBRARY glib-2.0 INCLUDE glib.h INCLUDE_SUFFIXES include/glib +ProcessPackage(GLIB2 LIBRARY glib-2.0 INCLUDE glib.h INCLUDE_SUFFIXES include/glib ROOT ${GLIB_ROOT_DIR} MODULES glib-2.0>=2.28) -ProcessPackage(PCRE LIBRARY pcre INCLUDE pcre.h INCLUDE_SUFFIXES include/pcre +ProcessPackage(PCRE LIBRARY pcre INCLUDE pcre.h INCLUDE_SUFFIXES include/pcre ROOT ${PCRE_ROOT_DIR} MODULES pcre libpcre pcre3 libpcre3) -ProcessPackage(GMIME LIBRARY gmime-2.6 gmime-2.4 gmime-2.2 gmime-2 INCLUDE gmime.h INCLUDE_SUFFIXES include/gmime +ProcessPackage(GMIME LIBRARY gmime-2.6 gmime-2.4 gmime-2.2 gmime-2 INCLUDE gmime.h INCLUDE_SUFFIXES include/gmime ROOT ${GMIME_ROOT_DIR} MODULES gmime-2.6 gmime-2.4 gmime-2.0) -ProcessPackage(LIBEVENT LIBRARY event INCLUDE event.h INCLUDE_SUFFIXES include/event +ProcessPackage(LIBEVENT LIBRARY event INCLUDE event.h INCLUDE_SUFFIXES include/event ROOT ${LIBEVENT_ROOT_DIR} MODULES event libevent) -ProcessPackage(SQLITE3 LIBRARY sqlite3 INCLUDE sqlite3.h INCLUDE_SUFFIXES include/sqlite3 include/sqlite +ProcessPackage(SQLITE3 LIBRARY sqlite3 INCLUDE sqlite3.h INCLUDE_SUFFIXES include/sqlite3 include/sqlite ROOT ${SQLITE3_ROOT_DIR} MODULES sqlite3 sqlite) ProcessPackage(ICONV LIBRARY iconv libiconv libiconv-2 c INCLUDE iconv.h INCLUDE_SUFFIXES include/libiconv ROOT ${ICONV_ROOT_DIR} MODULES iconv) @@ -690,12 +691,12 @@ 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") @@ -710,7 +711,7 @@ IF(NOT CMAKE_C_OPT_FLAGS) ENDIF(NOT CMAKE_C_OPT_FLAGS) 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) @@ -835,20 +836,20 @@ CHECK_SYMBOL_EXISTS(O_ASYNC "sys/types.h;sys/fcntl.h" HAVE_OASYNC) # Some PCRE implementations are lacking of pcre_jit_exec fast path SET(_PCRE_FAST_TEST " #include \"pcre.h\" -int main (void) +int main (void) { int rc; int ovector[30]; pcre *re; pcre_extra *extra; pcre_jit_stack *jit_stack; - + 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); - + return rc; } ") @@ -928,13 +929,13 @@ IF(ENABLE_URL_INCLUDE MATCHES "ON") DOC "Path where the libfetch library can be found") IF(LIBFETCH_LIBRARY) FIND_FILE(HAVE_FETCH_H HINTS "${RSPAMD_SEARCH_PATH}" - NAMES fetch.h + NAMES fetch.h PATH_SUFFIXES include PATHS ${RSPAMD_DEFAULT_INCLUDE_PATHS} DOC "Path to libfetch header") ELSE(LIBFETCH_LIBRARY) # Try to find libcurl - ProcessPackage(CURL LIBRARY curl INCLUDE curl.h INCLUDE_SUFFIXES include/curl + ProcessPackage(CURL LIBRARY curl INCLUDE curl.h INCLUDE_SUFFIXES include/curl ROOT ${CURL_ROOT}) IF(NOT WITH_CURL) MESSAGE(WARNING "Neither libcurl nor libfetch were found, no support of URL includes in configuration") @@ -951,14 +952,14 @@ SET(ID "unknown") FIND_PROGRAM(HG "git") IF(HG) - EXECUTE_PROCESS(COMMAND "${HG}" rev-parse --verify HEAD + 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}") + FIND_FILE(HG_ARCH ".hg_archival.txt" "${CMAKE_CURRENT_SOURCE_DIR}") IF(HG_ARCH) FILE(READ ${HG_ARCH} HG_ID) IF(HG_ID) @@ -969,7 +970,7 @@ IF(HG) ENDIF(HG_ID) ELSE(HG) # Now check .hg_archival.txt - FIND_FILE(HG_ARCH ".hg_archival.txt" "${CMAKE_CURRENT_SOURCE_DIR}") + FIND_FILE(HG_ARCH ".hg_archival.txt" "${CMAKE_CURRENT_SOURCE_DIR}") IF(HG_ARCH) FILE(READ ${HG_ARCH} HG_ID) IF(HG_ID) @@ -1020,6 +1021,11 @@ ENDIF() ADD_SUBDIRECTORY(contrib/libucl) ADD_SUBDIRECTORY(contrib/librdns) ADD_SUBDIRECTORY(contrib/aho-corasick) + +IF(ENABLE_CLANG_PLUGIN MATCHES "ON") + ADD_SUBDIRECTORY(clang-plugin) +ENDIF() + ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(test) ADD_SUBDIRECTORY(utils) @@ -1043,12 +1049,12 @@ INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${RULESDIR})") LIST(LENGTH CONFFILES CONFLIST_COUNT) MATH(EXPR CONFLIST_MAX ${CONFLIST_COUNT}-1) -FILE(GLOB_RECURSE CONF_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/conf" +FILE(GLOB_RECURSE CONF_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/conf" "${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})") - INSTALL(FILES "${CMAKE_CURRENT_SOURCE_DIR}/conf/${CONF_FILE}" + INSTALL(FILES "${CMAKE_CURRENT_SOURCE_DIR}/conf/${CONF_FILE}" DESTINATION ${CONFDIR}/${_rp}) ENDFOREACH(CONF_FILE) @@ -1073,7 +1079,7 @@ ENDIF(INSTALL_EXAMPLES MATCHES "ON") # Lua plugins -FILE(GLOB LUA_PLUGINS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/lua" +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) @@ -1085,11 +1091,11 @@ ENDFOREACH(LUA_PLUGIN) INSTALL(FILES "contrib/lua-fun/fun.lua" DESTINATION ${PLUGINSDIR}/lua) # Install TLD list -INSTALL(FILES "contrib/publicsuffix/effective_tld_names.dat" DESTINATION +INSTALL(FILES "contrib/publicsuffix/effective_tld_names.dat" DESTINATION "${PLUGINSDIR}") # Lua config -FILE(GLOB_RECURSE LUA_CONFIGS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/rules" +FILE(GLOB_RECURSE LUA_CONFIGS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/rules" "${CMAKE_CURRENT_SOURCE_DIR}/rules/*.lua") FOREACH(LUA_CONF ${LUA_CONFIGS}) GET_FILENAME_COMPONENT(_rp ${LUA_CONF} PATH) @@ -1121,4 +1127,4 @@ ADD_CUSTOM_TARGET(dist ${CMAKE_SOURCE_DIR}/dist.sh 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)
\ No newline at end of file +ENDIF(NOT DEBIAN_BUILD) |