]> source.dussan.org Git - rspamd.git/commitdiff
[Rework] Convert rspamd-server to a shared library
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 13 Feb 2019 18:09:43 +0000 (18:09 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 13 Feb 2019 18:09:43 +0000 (18:09 +0000)
src/CMakeLists.txt
src/client/CMakeLists.txt
src/rspamadm/CMakeLists.txt
test/CMakeLists.txt

index 6fbfa577dd187503caab33fe231e88fba007e049..fc2560ce620d76f175d6abe40ee72f488c881e21 100644 (file)
@@ -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})
index 29abfb2c02c317343ed08b29d11fd5bd355db0e0..0a92019d8c750d793d317a9c0c19b3020a053708 100644 (file)
@@ -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()
index 2105c16b3ce6e625cd576699ea9d397f6c26cc14..8e3f094355d621b68f964b917b5572453dc06838 100644 (file)
@@ -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()
index 226db80ef1c5137539db4a4e37ec55e84c8d29c6..822466779b20f06764de6fde5949b63249925dae 100644 (file)
@@ -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()