commit 0436aa5: [Rework] Convert rspamd-server to a shared library
Vsevolod Stakhov
vsevolod at highsecure.ru
Wed Feb 13 18:14:05 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-02-13 18:09:43 +0000
URL: https://github.com/rspamd/rspamd/commit/0436aa53c30e43fc520d6c2ae03a40ff8752a409 (HEAD -> master)
[Rework] Convert rspamd-server to a shared library
---
src/CMakeLists.txt | 83 +++++++++++++++++++++++++++++----------------
src/client/CMakeLists.txt | 1 -
src/rspamadm/CMakeLists.txt | 7 ----
test/CMakeLists.txt | 18 ----------
4 files changed, 53 insertions(+), 56 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6fbfa577d..fc2560ce6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -146,22 +146,42 @@ RAGEL_TARGET(ragel_smtp_ip
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ip_parser.rl.c)
######################### LINK SECTION ###############################
-ADD_LIBRARY(rspamd-server STATIC
- ${RSPAMD_CRYPTOBOX}
- ${RSPAMD_UTIL}
- ${RSPAMD_LUA}
- ${RSPAMD_SERVER}
- ${RSPAMD_STAT}
- ${RSPAMD_MIME}
- ${CMAKE_CURRENT_BINARY_DIR}/modules.c
- ${PLUGINSSRC}
- "${RAGEL_ragel_smtp_addr_OUTPUTS}"
- "${RAGEL_ragel_newlines_strip_OUTPUTS}"
- "${RAGEL_ragel_content_type_OUTPUTS}"
- "${RAGEL_ragel_content_disposition_OUTPUTS}"
- "${RAGEL_ragel_rfc2047_OUTPUTS}"
- "${RAGEL_ragel_smtp_date_OUTPUTS}"
- "${RAGEL_ragel_smtp_ip_OUTPUTS}")
+IF(ENABLE_STATIC MATCHES "ON")
+ ADD_LIBRARY(rspamd-server STATIC
+ ${RSPAMD_CRYPTOBOX}
+ ${RSPAMD_UTIL}
+ ${RSPAMD_LUA}
+ ${RSPAMD_SERVER}
+ ${RSPAMD_STAT}
+ ${RSPAMD_MIME}
+ ${CMAKE_CURRENT_BINARY_DIR}/modules.c
+ ${PLUGINSSRC}
+ "${RAGEL_ragel_smtp_addr_OUTPUTS}"
+ "${RAGEL_ragel_newlines_strip_OUTPUTS}"
+ "${RAGEL_ragel_content_type_OUTPUTS}"
+ "${RAGEL_ragel_content_disposition_OUTPUTS}"
+ "${RAGEL_ragel_rfc2047_OUTPUTS}"
+ "${RAGEL_ragel_smtp_date_OUTPUTS}"
+ "${RAGEL_ragel_smtp_ip_OUTPUTS}")
+ELSE()
+ ADD_LIBRARY(rspamd-server SHARED
+ ${RSPAMD_CRYPTOBOX}
+ ${RSPAMD_UTIL}
+ ${RSPAMD_LUA}
+ ${RSPAMD_SERVER}
+ ${RSPAMD_STAT}
+ ${RSPAMD_MIME}
+ ${CMAKE_CURRENT_BINARY_DIR}/modules.c
+ ${PLUGINSSRC}
+ "${RAGEL_ragel_smtp_addr_OUTPUTS}"
+ "${RAGEL_ragel_newlines_strip_OUTPUTS}"
+ "${RAGEL_ragel_content_type_OUTPUTS}"
+ "${RAGEL_ragel_content_disposition_OUTPUTS}"
+ "${RAGEL_ragel_rfc2047_OUTPUTS}"
+ "${RAGEL_ragel_smtp_date_OUTPUTS}"
+ "${RAGEL_ragel_smtp_ip_OUTPUTS}")
+ENDIF()
+
TARGET_LINK_LIBRARIES(rspamd-server rspamd-http-parser)
TARGET_LINK_LIBRARIES(rspamd-server rspamd-cdb)
TARGET_LINK_LIBRARIES(rspamd-server rspamd-lpeg)
@@ -172,33 +192,36 @@ IF (ENABLE_CLANG_PLUGIN MATCHES "ON")
ADD_DEPENDENCIES(rspamd-server rspamd-clang)
ENDIF()
-ADD_EXECUTABLE(rspamd ${RSPAMDSRC} ${CMAKE_CURRENT_BINARY_DIR}/workers.c)
-SET_TARGET_PROPERTIES(rspamd PROPERTIES LINKER_LANGUAGE C)
-SET_TARGET_PROPERTIES(rspamd PROPERTIES COMPILE_FLAGS "-DRSPAMD_MAIN")
-IF(NOT DEBIAN_BUILD)
- SET_TARGET_PROPERTIES(rspamd PROPERTIES VERSION ${RSPAMD_VERSION})
-ENDIF(NOT DEBIAN_BUILD)
-
-TARGET_LINK_LIBRARIES(rspamd rspamd-server)
IF (ENABLE_SNOWBALL MATCHES "ON")
- TARGET_LINK_LIBRARIES(rspamd stemmer)
+ TARGET_LINK_LIBRARIES(rspamd-server stemmer)
ENDIF()
-TARGET_LINK_LIBRARIES(rspamd rspamd-hiredis)
+TARGET_LINK_LIBRARIES(rspamd-server rspamd-hiredis)
IF (ENABLE_FANN MATCHES "ON")
- TARGET_LINK_LIBRARIES(rspamd fann)
+ TARGET_LINK_LIBRARIES(rspamd-server fann)
ENDIF ()
IF (ENABLE_HYPERSCAN MATCHES "ON")
- TARGET_LINK_LIBRARIES(rspamd hs)
+ TARGET_LINK_LIBRARIES(rspamd-server hs)
ENDIF()
-TARGET_LINK_LIBRARIES(rspamd rspamd-linenoise)
+TARGET_LINK_LIBRARIES(rspamd-server rspamd-linenoise)
IF(USE_CXX_LINKER)
SET_TARGET_PROPERTIES(rspamd PROPERTIES LINKER_LANGUAGE CXX)
+ SET_TARGET_PROPERTIES(rspamd-server PROPERTIES LINKER_LANGUAGE CXX)
ENDIF()
-TARGET_LINK_LIBRARIES(rspamd ${RSPAMD_REQUIRED_LIBRARIES})
+TARGET_LINK_LIBRARIES(rspamd-server ${RSPAMD_REQUIRED_LIBRARIES})
+
+ADD_EXECUTABLE(rspamd ${RSPAMDSRC} ${CMAKE_CURRENT_BINARY_DIR}/workers.c)
+SET_TARGET_PROPERTIES(rspamd PROPERTIES LINKER_LANGUAGE C)
+SET_TARGET_PROPERTIES(rspamd PROPERTIES COMPILE_FLAGS "-DRSPAMD_MAIN")
+IF(NOT DEBIAN_BUILD)
+ SET_TARGET_PROPERTIES(rspamd PROPERTIES VERSION ${RSPAMD_VERSION})
+ENDIF(NOT DEBIAN_BUILD)
+
+TARGET_LINK_LIBRARIES(rspamd rspamd-server)
INSTALL(TARGETS rspamd RUNTIME DESTINATION bin)
+INSTALL(TARGETS rspamd-server LIBRARY DESTINATION ${RSPAMD_LIBDIR})
diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt
index 29abfb2c0..0a92019d8 100644
--- a/src/client/CMakeLists.txt
+++ b/src/client/CMakeLists.txt
@@ -8,7 +8,6 @@ ADD_EXECUTABLE(rspamc ${RSPAMCSRC} ${LIBRSPAMDCLIENTSRC})
SET_TARGET_PROPERTIES(rspamc PROPERTIES COMPILE_FLAGS "-I${CMAKE_SOURCE_DIR}/lib")
TARGET_LINK_LIBRARIES(rspamc rspamd-server)
TARGET_LINK_LIBRARIES(rspamc ${RSPAMD_REQUIRED_LIBRARIES})
-TARGET_LINK_LIBRARIES(rspamc rspamd-linenoise)
IF(USE_CXX_LINKER)
SET_TARGET_PROPERTIES(rspamc PROPERTIES LINKER_LANGUAGE CXX)
ENDIF()
diff --git a/src/rspamadm/CMakeLists.txt b/src/rspamadm/CMakeLists.txt
index 2105c16b3..8e3f09435 100644
--- a/src/rspamadm/CMakeLists.txt
+++ b/src/rspamadm/CMakeLists.txt
@@ -26,18 +26,11 @@ ENDIF()
ADD_EXECUTABLE(rspamadm ${RSPAMADMSRC})
TARGET_LINK_LIBRARIES(rspamadm rspamd-server)
TARGET_LINK_LIBRARIES(rspamadm ${RSPAMD_REQUIRED_LIBRARIES})
-TARGET_LINK_LIBRARIES(rspamadm rspamd-linenoise)
IF (NOT DEBIAN_BUILD)
SET_TARGET_PROPERTIES(rspamadm PROPERTIES VERSION ${RSPAMD_VERSION})
ENDIF (NOT DEBIAN_BUILD)
-IF (ENABLE_FANN MATCHES "ON")
- TARGET_LINK_LIBRARIES(rspamadm fann)
-ENDIF ()
-IF (ENABLE_HYPERSCAN MATCHES "ON")
- TARGET_LINK_LIBRARIES(rspamadm hs)
-ENDIF ()
IF(USE_CXX_LINKER)
SET_TARGET_PROPERTIES(rspamadm PROPERTIES LINKER_LANGUAGE CXX)
ENDIF()
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 226db80ef..822466779 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -19,25 +19,7 @@ ADD_EXECUTABLE(rspamd-test EXCLUDE_FROM_ALL ${TESTSRC})
SET_TARGET_PROPERTIES(rspamd-test PROPERTIES LINKER_LANGUAGE C)
SET_TARGET_PROPERTIES(rspamd-test PROPERTIES COMPILE_FLAGS "-DRSPAMD_TEST")
ADD_DEPENDENCIES(rspamd-test rspamd-server)
-IF(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
- TARGET_LINK_LIBRARIES(rspamd-test "-Wl,-whole-archive ${CMAKE_BINARY_DIR}/src/librspamd-server.a -Wl,-no-whole-archive")
-ELSE(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
- TARGET_LINK_LIBRARIES(rspamd-test "-Wl,-force_load ${CMAKE_BINARY_DIR}/src/librspamd-server.a")
-ENDIF(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
-TARGET_LINK_LIBRARIES(rspamd-test rspamd-cdb)
-TARGET_LINK_LIBRARIES(rspamd-test lcbtrie)
-TARGET_LINK_LIBRARIES(rspamd-test rspamd-http-parser)
-TARGET_LINK_LIBRARIES(rspamd-test rspamd-lpeg)
-TARGET_LINK_LIBRARIES(rspamd-test rspamd-linenoise)
-TARGET_LINK_LIBRARIES(rspamd-test rspamd-zstd)
TARGET_LINK_LIBRARIES(rspamd-test ${RSPAMD_REQUIRED_LIBRARIES})
-IF (ENABLE_SNOWBALL MATCHES "ON")
- TARGET_LINK_LIBRARIES(rspamd-test stemmer)
-ENDIF()
-TARGET_LINK_LIBRARIES(rspamd-test rspamd-hiredis)
-IF (ENABLE_HYPERSCAN MATCHES "ON")
- TARGET_LINK_LIBRARIES(rspamd-test hs)
-ENDIF()
IF(USE_CXX_LINKER)
SET_TARGET_PROPERTIES(rspamd-test PROPERTIES LINKER_LANGUAGE CXX)
ENDIF()
More information about the Commits
mailing list