commit 43b6f8a: [Fix] fix static building

Duncan Bellamy dunk at denkimushi.com
Tue Sep 28 11:35:04 UTC 2021


Author: Duncan Bellamy
Date: 2021-09-27 11:16:47 +0100
URL: https://github.com/rspamd/rspamd/commit/43b6f8aeb9d8b5bb138627eb1915f1d5e0fa87aa (refs/pull/3915/head)

[Fix] fix static building

---
 cmake/Toolset.cmake           | 2 +-
 contrib/kann/CMakeLists.txt   | 6 +++++-
 contrib/libev/CMakeLists.txt  | 6 +++++-
 contrib/replxx/CMakeLists.txt | 6 +++++-
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/cmake/Toolset.cmake b/cmake/Toolset.cmake
index 6ba290f96..361456c9b 100644
--- a/cmake/Toolset.cmake
+++ b/cmake/Toolset.cmake
@@ -80,7 +80,7 @@ if (ENABLE_STATIC MATCHES "ON")
     SET(CMAKE_SKIP_INSTALL_RPATH ON)
     SET(BUILD_STATIC 1)
     SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
-    SET(BUILD_SHARED_LIBRARIES OFF)
+    SET(BUILD_SHARED_LIBS OFF)
     SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
     SET(LINK_TYPE "STATIC")
     SET(NO_SHARED "ON")
diff --git a/contrib/kann/CMakeLists.txt b/contrib/kann/CMakeLists.txt
index b3a1d547c..ba16d5e9f 100644
--- a/contrib/kann/CMakeLists.txt
+++ b/contrib/kann/CMakeLists.txt
@@ -1,6 +1,10 @@
 SET(LIBKANNSRC	kautodiff.c kann.c)
 
-ADD_LIBRARY(rspamd-kann SHARED ${LIBKANNSRC})
+IF(ENABLE_STATIC MATCHES "ON")
+	ADD_LIBRARY(rspamd-kann STATIC ${LIBKANNSRC})
+ELSE()
+	ADD_LIBRARY(rspamd-kann SHARED ${LIBKANNSRC})
+ENDIF()
 
 IF(WITH_BLAS)
     MESSAGE(STATUS "Use openblas to accelerate kann")
diff --git a/contrib/libev/CMakeLists.txt b/contrib/libev/CMakeLists.txt
index 53ab6c362..03d9df254 100644
--- a/contrib/libev/CMakeLists.txt
+++ b/contrib/libev/CMakeLists.txt
@@ -58,7 +58,11 @@ CHECK_LIBRARY_EXISTS(m ceil "" HAVE_LIBM)
 
 CONFIGURE_FILE(config.h.in libev-config.h)
 
-ADD_LIBRARY(rspamd-ev SHARED ${LIBEVSRC})
+IF(ENABLE_STATIC MATCHES "ON")
+	ADD_LIBRARY(rspamd-ev STATIC ${LIBEVSRC})
+ELSE()
+	ADD_LIBRARY(rspamd-ev SHARED ${LIBEVSRC})
+ENDIF()
 include_directories("${CMAKE_CURRENT_BINARY_DIR}")
 ADD_DEFINITIONS("-DEV_CONFIG_H=\"libev-config.h\""
 		-DEV_MULTIPLICITY=1
diff --git a/contrib/replxx/CMakeLists.txt b/contrib/replxx/CMakeLists.txt
index da6e8d865..f48a0688d 100644
--- a/contrib/replxx/CMakeLists.txt
+++ b/contrib/replxx/CMakeLists.txt
@@ -64,7 +64,11 @@ set(
 )
 
 set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
-add_library(rspamd-replxx SHARED ${REPLXX_SOURCES})
+if(ENABLE_STATIC MATCHES "ON")
+	add_library(rspamd-replxx STATIC ${REPLXX_SOURCES})
+else()
+	add_library(rspamd-replxx SHARED ${REPLXX_SOURCES})
+endif()
 
 target_include_directories(
 	rspamd-replxx


More information about the Commits mailing list