diff options
-rw-r--r-- | CMakeLists.txt | 124 | ||||
-rw-r--r-- | cmake/ArchDep.cmake | 5 | ||||
-rw-r--r-- | cmake/Hyperscan.cmake | 19 | ||||
-rw-r--r-- | cmake/Openblas.cmake | 26 | ||||
-rw-r--r-- | cmake/Sanitizer.cmake | 44 | ||||
-rw-r--r-- | cmake/Toolset.cmake | 162 | ||||
-rw-r--r-- | config.h.in | 3 | ||||
-rw-r--r-- | contrib/replxx/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/CMakeLists.txt | 2 |
9 files changed, 260 insertions, 126 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 00da0cbc6..49bc44742 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,11 +41,6 @@ SET(RSPAMD_WORKER_CONTROLLER "*:11334") SET_PROPERTY(GLOBAL PROPERTY ALLOW_DUPLICATE_CUSTOM_TARGETS 1) ############################# OPTIONS SECTION ############################################# - -OPTION(ENABLE_OPTIMIZATION "Enable extra optimizations [default: OFF]" OFF) -OPTION(SKIP_RELINK_RPATH "Skip relinking and full RPATH for the install tree" 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_URL_INCLUDE "Enable urls in ucl includes (requires libcurl or libfetch) [default: OFF]" OFF) OPTION(NO_SHARED "Build internal libs static [default: ON]" ON) @@ -53,11 +48,8 @@ OPTION(INSTALL_WEBUI "Install web interface [default: 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) -OPTION(ENABLE_HYPERSCAN "Enable hyperscan for fast regexp processing [default: OFF]" OFF) OPTION(ENABLE_PCRE2 "Enable pcre2 instead of pcre [default: OFF]" OFF) OPTION(ENABLE_JEMALLOC "Build rspamd with jemalloc allocator [default: OFF]" OFF) -OPTION(ENABLE_COVERAGE "Build rspamd with code coverage options [default: OFF]" OFF) -OPTION(ENABLE_FULL_DEBUG "Build rspamd with all possible debug [default: OFF]" OFF) OPTION(ENABLE_UTILS "Build rspamd internal utils [default: OFF]" OFF) OPTION(ENABLE_LIBUNWIND "Use libunwind to print crash traces [default: OFF]" OFF) OPTION(ENABLE_LUA_TRACE "Trace all Lua C API invocations [default: OFF]" OFF) @@ -87,34 +79,12 @@ ENDIF() FIND_PACKAGE(PkgConfig REQUIRED) FIND_PACKAGE(Perl REQUIRED) +INCLUDE(Toolset) +INCLUDE(Sanitizer) + INCLUDE(ArchDep) INCLUDE(Paths) -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) - SET(CMAKE_SKIP_INSTALL_RPATH ON) - 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") - # 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) -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") - IF(ENABLE_PCRE2 MATCHES "ON") SET(WITH_PCRE2 1) # For utf8 API @@ -221,91 +191,9 @@ ProcessPackage(SODIUM LIBRARY sodium INCLUDE sodium.h INCLUDE_SUFFIXES include/libsodium include/sodium ROOT ${LIBSODIUM_ROOT_DIR} MODULES libsodium>=1.0.0) -IF(ENABLE_BLAS MATCHES "ON") -ProcessPackage(BLAS OPTIONAL_INCLUDE LIBRARY openblas blas - INCLUDE cblas.h INCLUDE_SUFFIXES include/openblas - include/blas - ROOT ${BLAS_ROOT_DIR} - LIB_OUTPUT BLAS_REQUIRED_LIBRARIES) -ENDIF() - -IF(WITH_BLAS) - MESSAGE(STATUS "Use openblas to accelerate kann") - IF(NOT BLAS_INCLUDE) - FIND_FILE(HAVE_CBLAS_H HINTS "${RSPAMD_SEARCH_PATH}" - NAMES cblas.h - DOC "Path to cblas.h header") - IF(NOT HAVE_CBLAS_H) - MESSAGE(STATUS "Blas header cblas.h has not been found, use internal workaround") - ELSE() - ADD_DEFINITIONS(-DHAVE_CBLAS_H) - ENDIF() - ELSE() - ADD_DEFINITIONS(-DHAVE_CBLAS_H) - ENDIF() - ADD_DEFINITIONS(-DHAVE_CBLAS) -ENDIF(WITH_BLAS) - -IF(ENABLE_HYPERSCAN MATCHES "ON") - ProcessPackage(HYPERSCAN LIBRARY hs INCLUDE hs.h INCLUDE_SUFFIXES - hs include/hs - ROOT ${HYPERSCAN_ROOT_DIR} MODULES libhs) - SET(WITH_HYPERSCAN 1) - - # For static linking with Hyperscan we need to link using CXX - IF (ENABLE_HYPERSCAN MATCHES "ON") - IF(${HYPERSCAN_LIBRARY} MATCHES ".*[.]a$" OR STATIC_HYPERSCAN) - ENABLE_LANGUAGE(CXX) - SET(USE_CXX_LINKER 1) - ENDIF() - ENDIF() -ENDIF() - -#Check for openssl (required for dkim) -SET(HAVE_OPENSSL 1) - -# Google performance tools - -IF(ENABLE_GPERF_TOOLS MATCHES "ON") - ProcessPackage(GPERF LIBRARY profiler INCLUDE profiler.h INCLUDE_SUFFIXES include/google - ROOT ${GPERF_ROOT_DIR}) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-omit-frame-pointer") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer") - SET(WITH_GPERF_TOOLS 1) -ENDIF(ENABLE_GPERF_TOOLS MATCHES "ON") - -INCLUDE(CompilerWarnings) - - # Optimization flags -IF(NOT CMAKE_C_OPT_FLAGS) - IF(ENABLE_OPTIMIZATION MATCHES "ON") - SET(CMAKE_C_OPT_FLAGS "-g -O2") - IF(${CMAKE_VERSION} VERSION_GREATER "3.9.0") - CMAKE_POLICY(SET CMP0069 NEW) - INCLUDE(CheckIPOSupported) - check_ipo_supported(RESULT SUPPORT_LTO OUTPUT LTO_DIAG ) - if(SUPPORT_LTO) - SET(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) - else() - message(WARNING "IPO is not supported: ${LTO_DIAG}") - endif() - ENDIF() - ELSE(ENABLE_OPTIMIZATION MATCHES "ON") - IF(ENABLE_FULL_DEBUG MATCHES "ON") - ADD_DEFINITIONS(-DFULL_DEBUG) - SET(CMAKE_C_OPT_FLAGS "-g -Og") - ELSE(ENABLE_FULL_DEBUG MATCHES "ON") - SET(CMAKE_C_OPT_FLAGS "-g -O2") - ENDIF(ENABLE_FULL_DEBUG MATCHES "ON") - ENDIF(ENABLE_OPTIMIZATION MATCHES "ON") -ENDIF(NOT CMAKE_C_OPT_FLAGS) - -IF(ENABLE_COVERAGE) - SET(CMAKE_C_OPT_FLAGS "-g -Og") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") -ENDIF(ENABLE_COVERAGE) +include (CompilerWarnings) +include (Hyperscan) +include (Openblas) IF(ENABLE_LUA_TRACE) SET(WITH_LUA_TRACE 1) diff --git a/cmake/ArchDep.cmake b/cmake/ArchDep.cmake index e070da6b1..7b9a84491 100644 --- a/cmake/ArchDep.cmake +++ b/cmake/ArchDep.cmake @@ -89,11 +89,6 @@ int main(int argc, char** argv) { ASM_OP(HAVE_SSE42 "sse42") ENDIF() -IF (NOT "${ARCH}" STREQUAL "x86_64") - MESSAGE(STATUS "Hyperscan support is possible only for x86_64 architecture") - SET(ENABLE_HYPERSCAN "OFF") -ENDIF() - IF ("${ARCH}" STREQUAL "x86_64") MESSAGE(STATUS "Enable sse2 on x86_64 architecture") IF((CMAKE_C_COMPILER_ID MATCHES "GNU") OR (CMAKE_C_COMPILER_ID MATCHES "Clang")) diff --git a/cmake/Hyperscan.cmake b/cmake/Hyperscan.cmake new file mode 100644 index 000000000..3dd774511 --- /dev/null +++ b/cmake/Hyperscan.cmake @@ -0,0 +1,19 @@ +option (ENABLE_HYPERSCAN "Enable hyperscan for fast regexp processing [default: OFF]" OFF) + +if (ENABLE_HYPERSCAN MATCHES "ON") + if (NOT "${ARCH}" STREQUAL "x86_64") + MESSAGE(FATAL_ERROR "Hyperscan is supported only on x86_64 architecture") + endif () + ProcessPackage (HYPERSCAN LIBRARY hs INCLUDE hs.h INCLUDE_SUFFIXES + hs include/hs + ROOT ${HYPERSCAN_ROOT_DIR} MODULES libhs) + set (WITH_HYPERSCAN 1) + + # For static linking with Hyperscan we need to link using CXX + if (ENABLE_HYPERSCAN MATCHES "ON") + if (${HYPERSCAN_LIBRARY} MATCHES ".*[.]a$" OR STATIC_HYPERSCAN) + enable_language (CXX) + set (USE_CXX_LINKER 1) + endif () + endif () +endif ()
\ No newline at end of file diff --git a/cmake/Openblas.cmake b/cmake/Openblas.cmake new file mode 100644 index 000000000..6bf254042 --- /dev/null +++ b/cmake/Openblas.cmake @@ -0,0 +1,26 @@ +option (ENABLE_OPENBLAS "Enable openblas for fast neural network processing [default: OFF]" OFF) + +IF(ENABLE_BLAS MATCHES "ON") + ProcessPackage(BLAS OPTIONAL_INCLUDE LIBRARY openblas blas + INCLUDE cblas.h INCLUDE_SUFFIXES include/openblas + include/blas + ROOT ${BLAS_ROOT_DIR} + LIB_OUTPUT BLAS_REQUIRED_LIBRARIES) +ENDIF() + +IF(WITH_BLAS) + MESSAGE(STATUS "Use openblas to accelerate kann") + IF(NOT BLAS_INCLUDE) + FIND_FILE(HAVE_CBLAS_H HINTS "${RSPAMD_SEARCH_PATH}" + NAMES cblas.h + DOC "Path to cblas.h header") + IF(NOT HAVE_CBLAS_H) + MESSAGE(STATUS "Blas header cblas.h has not been found, use internal workaround") + ELSE() + ADD_DEFINITIONS(-DHAVE_CBLAS_H) + ENDIF() + ELSE() + ADD_DEFINITIONS(-DHAVE_CBLAS_H) + ENDIF() + ADD_DEFINITIONS(-DHAVE_CBLAS) +ENDIF(WITH_BLAS)
\ No newline at end of file diff --git a/cmake/Sanitizer.cmake b/cmake/Sanitizer.cmake new file mode 100644 index 000000000..723878d0d --- /dev/null +++ b/cmake/Sanitizer.cmake @@ -0,0 +1,44 @@ +# Ported from Clickhouse: https://github.com/ClickHouse/ClickHouse/blob/master/cmake/sanitize.cmake + +option (SANITIZE "Enable sanitizer: address, memory, undefined" "") +set (SAN_FLAGS "${SAN_FLAGS} -g -fno-omit-frame-pointer -DSANITIZER") +# O1 is normally set by clang, and -Og by gcc +if (COMPILER_GCC) + set (SAN_FLAGS "${SAN_FLAGS} -Og") +else () + set (SAN_FLAGS "${SAN_FLAGS} -O1") +endif () +if (SANITIZE) + if (SANITIZE STREQUAL "address") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SAN_FLAGS} -fsanitize=address -fsanitize-address-use-after-scope") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SAN_FLAGS} -fsanitize=address -fsanitize-address-use-after-scope") + if (COMPILER_GCC) + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address -fsanitize-address-use-after-scope") + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libasan") + endif () + + elseif (SANITIZE STREQUAL "memory") + set (MSAN_FLAGS "-fsanitize=memory -fsanitize-memory-track-origins -fno-optimize-sibling-calls") + + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SAN_FLAGS} ${MSAN_FLAGS}") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SAN_FLAGS} ${MSAN_FLAGS}") + + if (COMPILER_GCC) + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=memory") + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libmsan") + endif () + + elseif (SANITIZE STREQUAL "undefined") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SAN_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SAN_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all") + if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined") + endif() + if (CMAKE_C_COMPILER_ID STREQUAL "GNU") + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libubsan") + endif () + + message (FATAL_ERROR "Unknown sanitizer type: ${SANITIZE}") + endif () + message (STATUS "Add sanitizer: ${SANITIZE}") +endif()
\ No newline at end of file diff --git a/cmake/Toolset.cmake b/cmake/Toolset.cmake new file mode 100644 index 000000000..b6c863521 --- /dev/null +++ b/cmake/Toolset.cmake @@ -0,0 +1,162 @@ +if(CMAKE_C_COMPILER_ID STREQUAL "GNU") + SET (COMPILER_GCC 1) +elseif(CMAKE_C_COMPILER_ID MATCHES "Clang|AppleClang") + SET (COMPILER_CLANG 1) +endif() +if (CMAKE_GENERATOR STREQUAL "Ninja") + # Turn on colored output. https://github.com/ninja-build/ninja/wiki/FAQ + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always") +endif () + +if (COMPILER_GCC) + # Require minimum version of gcc + set (GCC_MINIMUM_VERSION 4) + if (CMAKE_C_COMPILER_VERSION VERSION_LESS ${GCC_MINIMUM_VERSION} AND NOT CMAKE_VERSION VERSION_LESS 2.8.9) + message (FATAL_ERROR "GCC version must be at least ${GCC_MINIMUM_VERSION}.") + endif () +elseif (COMPILER_CLANG) + # Require minimum version of clang + set (CLANG_MINIMUM_VERSION 4) + if (CMAKE_C_COMPILER_VERSION VERSION_LESS ${CLANG_MINIMUM_VERSION}) + message (FATAL_ERROR "Clang version must be at least ${CLANG_MINIMUM_VERSION}.") + endif () + ADD_COMPILE_OPTIONS(-Wno-unused-command-line-argument) +else () + message (WARNING "You are using an unsupported compiler ${CMAKE_C_COMPILER_ID}. Compilation has only been tested with Clang 4+ and GCC 4+.") +endif () + +option(LINKER_NAME "Linker name or full path") + +find_program(LLD_PATH NAMES "ld.lld" "lld") +find_program(GOLD_PATH NAMES "ld.gold" "gold") + +if(NOT LINKER_NAME) + if(LLD_PATH) + set(LINKER_NAME "lld") + elseif(GOLD_PATH) + set(LINKER_NAME "gold") + else() + message(STATUS "Use generic 'ld' as a linker") + endif() +endif() + +if(LINKER_NAME) + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=${LINKER_NAME}") + set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=${LINKER_NAME}") + + message(STATUS "Using custom linker by name: ${LINKER_NAME}") +endif () + +option (ENABLE_STATIC "Enable static compiling [default: OFF]" OFF) + +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) + SET(CMAKE_SKIP_INSTALL_RPATH ON) + 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") + # 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) +else () + if (NO_SHARED MATCHES "OFF") + SET(LINK_TYPE "SHARED") + else () + SET(LINK_TYPE "STATIC") + endif () +endif () + +# Google performance tools +option (ENABLE_GPERF_TOOLS "Enable google perftools [default: OFF]" OFF) +if (ENABLE_GPERF_TOOLS MATCHES "ON") + ProcessPackage(GPERF LIBRARY profiler INCLUDE profiler.h INCLUDE_SUFFIXES include/google + ROOT ${GPERF_ROOT_DIR}) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-omit-frame-pointer") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer") + set (WITH_GPERF_TOOLS 1) +endif (ENABLE_GPERF_TOOLS MATCHES "ON") + +# Legacy options support +option (ENABLE_COVERAGE "Build rspamd with code coverage options [default: OFF]" OFF) +option (ENABLE_OPTIMIZATION "Enable extra optimizations [default: OFF]" OFF) +option (SKIP_RELINK_RPATH "Skip relinking and full RPATH for the install tree" OFF) +option (ENABLE_FULL_DEBUG "Build rspamd with all possible debug [default: OFF]" OFF) + +if(NOT CMAKE_BUILD_TYPE) + if (ENABLE_FULL_DEBUG MATCHES "ON") + set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE) + endif() + if (ENABLE_COVERAGE MATCHES "ON") + set(CMAKE_BUILD_TYPE Coverage CACHE STRING "" FORCE) + endif() + if (ENABLE_OPTIMIZATION MATCHES "ON") + set(CMAKE_BUILD_TYPE Release CACHE STRING "" FORCE) + endif() +endif() + +if (CMAKE_CONFIGURATION_TYPES) # multiconfig generator? + set (CMAKE_CONFIGURATION_TYPES "Debug;RelWithDebInfo;Release;Coverage" CACHE STRING "" FORCE) +else() + if (NOT CMAKE_BUILD_TYPE) + if (NOT SANITIZE) + message(STATUS "Defaulting to release build.") + set(CMAKE_BUILD_TYPE Release CACHE STRING "" FORCE) + else () + message(STATUS "Defaulting to debug build due to sanitizers being enabled.") + set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE) + endif () + endif() + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY HELPSTRING "Choose the type of build") + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug;Release;Coverage") +endif() + +string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UC) +message (STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE_UC}") +set(CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS} -O1 --coverage -fno-inline -fno-default-inline -fno-inline-small-functions") +set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS} -O1 --coverage -fno-inline -fno-default-inline -fno-inline-small-functions") +if (COMPILER_GCC) + set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Og -g -ggdb -g3 -ggdb3") + set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og -g -ggdb -g3 -ggdb3") +else () + set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O1 -g -gdwarf-aranges") + set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O1 -g -gdwarf-aranges") +endif() + +if (COMPILER_GCC) + set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -fomit-frame-pointer") + set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -fomit-frame-pointer") +else () + set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2 -fomit-frame-pointer") + set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -fomit-frame-pointer") + +endif() +set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} -O2") +set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -O2") + +if (CMAKE_BUILD_TYPE_UC MATCHES "COVERAGE") + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") +elseif (CMAKE_BUILD_TYPE_UC MATCHES "RELEASE") + if (${CMAKE_VERSION} VERSION_GREATER "3.9.0") + cmake_policy (SET CMP0069 NEW) + include (CheckIPOSupported) + check_ipo_supported (RESULT SUPPORT_LTO OUTPUT LTO_DIAG ) + if (SUPPORT_LTO) + set (CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) + message (STATUS "Enable IPO for the ${CMAKE_BUILD_TYPE} build") + else () + message(WARNING "IPO is not supported: ${LTO_DIAG}") + endif () + endif () +endif () + +message (STATUS "Final CFLAGS: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UC}}") +message (STATUS "Final CXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
\ No newline at end of file diff --git a/config.h.in b/config.h.in index 1ab588506..04a5a8010 100644 --- a/config.h.in +++ b/config.h.in @@ -66,7 +66,6 @@ #cmakedefine HAVE_OCLOEXEC 1 #cmakedefine HAVE_ONOFOLLOW 1 #cmakedefine HAVE_OPENMEMSTREAM 1 -#cmakedefine HAVE_OPENSSL 1 #cmakedefine HAVE_O_DIRECT 1 #cmakedefine HAVE_PATH_MAX 1 @@ -432,4 +431,6 @@ extern uint64_t ottery_rand_uint64(void); #error incompatible compiler found, need gcc > 2.7 or clang #endif +#define HAVE_OPENSSL 1 + #endif diff --git a/contrib/replxx/CMakeLists.txt b/contrib/replxx/CMakeLists.txt index a1b40dfdb..b391639f5 100644 --- a/contrib/replxx/CMakeLists.txt +++ b/contrib/replxx/CMakeLists.txt @@ -1,6 +1,5 @@ # -*- mode: CMAKE; -*- project( replxx VERSION 0.0.2 LANGUAGES CXX C ) -message(STATUS "Build mode: ${CMAKE_BUILD_TYPE}") # INFO set(REPLXX_DISPLAY_NAME "replxx") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c4f0c53ba..480578831 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -207,7 +207,7 @@ IF (ENABLE_HYPERSCAN MATCHES "ON") TARGET_LINK_LIBRARIES(rspamd-server hs) ENDIF() -IF (WITH_BLAS) +IF(WITH_BLAS) TARGET_LINK_LIBRARIES(rspamd-server ${BLAS_REQUIRED_LIBRARIES}) ENDIF() |