summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2012-06-07 19:48:27 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2012-06-07 19:48:27 +0400
commitb1cb2de69abe29bf984483479ad54947ffe675d3 (patch)
tree136b4f04e8f3011fd96edfe4742b1c81c43185a5
parent6cea7f1cd0a1b504f841a37ff40ce481b8332481 (diff)
downloadrspamd-b1cb2de69abe29bf984483479ad54947ffe675d3.tar.gz
rspamd-b1cb2de69abe29bf984483479ad54947ffe675d3.zip
Allow NO_SHARED build to use static archives for internal libraries.
Check for -fPIC/-fpic support.
-rw-r--r--CMakeLists.txt16
-rw-r--r--lib/CMakeLists.txt39
-rw-r--r--src/cdb/CMakeLists.txt9
-rw-r--r--src/json/CMakeLists.txt9
-rw-r--r--src/lua/CMakeLists.txt9
5 files changed, 49 insertions, 33 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cde158b15..fa5fff1d6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,6 +30,7 @@ OPTION(ENABLE_PROFILING "Enable profiling [default: 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: OFF]" OFF)
+OPTION(NO_SHARED "Build internal libs static [default: OFF]" OFF)
OPTION(FORCE_GMIME24 "Link with gmime2.4 [default: OFF]" OFF)
# Build optimized code for following CPU (default i386)
@@ -420,7 +421,11 @@ IF(ENABLE_STATIC MATCHES "ON")
SET(LINK_TYPE "STATIC")
ELSE(ENABLE_STATIC MATCHES "ON")
pkg_check_modules(GLIB2 REQUIRED glib-2.0>=2.12 gmodule-2.0)
- SET(LINK_TYPE "SHARED")
+ 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")
SET(GLIB2_VERSION "${GLIB2_glib-2.0_VERSION}")
@@ -697,6 +702,15 @@ 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)
+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")
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 4e30a70a8..b496d4dab 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -75,13 +75,14 @@ IF(GLIB_COMPAT)
TARGET_LINK_LIBRARIES(rspamd-util glibadditions)
ENDIF(GLIB_COMPAT)
-INSTALL(TARGETS rspamd-util
- LIBRARY DESTINATION ${LIBDIR}
- PUBLIC_HEADER DESTINATION include
- ARCHIVE DESTINATION ${LIBDIR})
+IF(NO_SHARED MATCHES "OFF")
+ INSTALL(TARGETS rspamd-util
+ LIBRARY DESTINATION ${LIBDIR}
+ PUBLIC_HEADER DESTINATION include)
+ENDIF(NO_SHARED MATCHES "OFF")
# Rspamd client
-ADD_LIBRARY(rspamdclient ${LINK_TYPE} ${LIBRSPAMDCLIENTSRC})
+ADD_LIBRARY(rspamdclient SHARED ${LIBRSPAMDCLIENTSRC})
ADD_LIBRARY(rspamdclient_static STATIC ${LIBRSPAMDCLIENTSRC})
SET_TARGET_PROPERTIES(rspamdclient PROPERTIES PUBLIC_HEADER "client/librspamdclient.h")
@@ -139,10 +140,12 @@ ENDIF(SQLITE_LIBRARIES)
IF(OPENSSL_FOUND)
TARGET_LINK_LIBRARIES(rspamd-server ${OPENSSL_LIBRARIES})
ENDIF(OPENSSL_FOUND)
-INSTALL(TARGETS rspamd-server
- LIBRARY DESTINATION ${LIBDIR}
- PUBLIC_HEADER DESTINATION ${INCLUDEDIR}
- ARCHIVE DESTINATION ${LIBDIR})
+
+IF(NO_SHARED MATCHES "OFF")
+ INSTALL(TARGETS rspamd-server
+ LIBRARY DESTINATION ${LIBDIR}
+ PUBLIC_HEADER DESTINATION ${INCLUDEDIR})
+ENDIF(NO_SHARED MATCHES "OFF")
# Librspamdmime
ADD_LIBRARY(rspamd-mime ${LINK_TYPE} ${LIBRSPAMDMIMESRC})
@@ -161,14 +164,15 @@ ELSE(GMIME24)
TARGET_LINK_LIBRARIES(rspamd-mime ${GMIME2_LIBRARIES})
ENDIF(GMIME24)
-INSTALL(TARGETS rspamd-mime
- LIBRARY DESTINATION ${LIBDIR}
- PUBLIC_HEADER DESTINATION ${INCLUDEDIR}
- ARCHIVE DESTINATION ${LIBDIR})
+IF(NO_SHARED MATCHES "OFF")
+ INSTALL(TARGETS rspamd-mime
+ LIBRARY DESTINATION ${LIBDIR}
+ PUBLIC_HEADER DESTINATION ${INCLUDEDIR})
+ENDIF(NO_SHARED MATCHES "OFF")
# Libkvstorageclient
-ADD_LIBRARY(kvstorageclient ${LINK_TYPE} ${LIBRKVSTORAGESRC})
+ADD_LIBRARY(kvstorageclient SHARED ${LIBRKVSTORAGESRC})
ADD_LIBRARY(kvstorageclient_static STATIC ${LIBRKVSTORAGESRC})
SET_TARGET_PROPERTIES(kvstorageclient PROPERTIES PUBLIC_HEADER "kvstorage/libkvstorageclient.h")
@@ -189,9 +193,4 @@ IF(GLIB_COMPAT)
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/contrib/lgpl")
TARGET_LINK_LIBRARIES(kvstorageclient glibadditions)
ENDIF(GLIB_COMPAT)
-INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/src")
-
-INSTALL(TARGETS rspamdclient rspamdclient_static LIBRARY PUBLIC_HEADER
- LIBRARY DESTINATION ${LIBDIR}
- PUBLIC_HEADER DESTINATION ${INCLUDEDIR}
- ARCHIVE DESTINATION ${LIBDIR})
+INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/src") \ No newline at end of file
diff --git a/src/cdb/CMakeLists.txt b/src/cdb/CMakeLists.txt
index 8c7f6b3be..7c6e1257d 100644
--- a/src/cdb/CMakeLists.txt
+++ b/src/cdb/CMakeLists.txt
@@ -7,7 +7,8 @@ ADD_LIBRARY(rspamd-cdb ${LINK_TYPE} ${CDBSRC})
TARGET_LINK_LIBRARIES(rspamd-cdb rspamd-util)
SET_TARGET_PROPERTIES(rspamd-cdb PROPERTIES VERSION ${RSPAMD_VERSION})
SET_TARGET_PROPERTIES(rspamd-cdb PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB")
-INSTALL(TARGETS rspamd-cdb
- LIBRARY DESTINATION ${LIBDIR}
- PUBLIC_HEADER DESTINATION ${INCLUDEDIR}
- ARCHIVE DESTINATION ${LIBDIR}) \ No newline at end of file
+IF(NO_SHARED MATCHES "OFF")
+ INSTALL(TARGETS rspamd-cdb
+ LIBRARY DESTINATION ${LIBDIR}
+ PUBLIC_HEADER DESTINATION ${INCLUDEDIR})
+ENDIF(NO_SHARED MATCHES "OFF") \ No newline at end of file
diff --git a/src/json/CMakeLists.txt b/src/json/CMakeLists.txt
index 9b37384bb..fd15ae773 100644
--- a/src/json/CMakeLists.txt
+++ b/src/json/CMakeLists.txt
@@ -10,7 +10,8 @@ ADD_LIBRARY(rspamd-json ${LINK_TYPE} ${JSONSRC})
TARGET_LINK_LIBRARIES(rspamd-json rspamd-util)
SET_TARGET_PROPERTIES(rspamd-json PROPERTIES VERSION ${RSPAMD_VERSION})
SET_TARGET_PROPERTIES(rspamd-json PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB")
-INSTALL(TARGETS rspamd-json
- LIBRARY DESTINATION ${LIBDIR}
- PUBLIC_HEADER DESTINATION ${INCLUDEDIR}
- ARCHIVE DESTINATION ${LIBDIR})
+IF(NO_SHARED MATCHES "OFF")
+ INSTALL(TARGETS rspamd-json
+ LIBRARY DESTINATION ${LIBDIR}
+ PUBLIC_HEADER DESTINATION ${INCLUDEDIR})
+ENDIF(NO_SHARED MATCHES "OFF")
diff --git a/src/lua/CMakeLists.txt b/src/lua/CMakeLists.txt
index 0c9d93621..a2823ad7b 100644
--- a/src/lua/CMakeLists.txt
+++ b/src/lua/CMakeLists.txt
@@ -21,7 +21,8 @@ ELSE(ENABLE_LUAJIT MATCHES "ON")
TARGET_LINK_LIBRARIES(rspamd-lua "${LUA_LIBRARY}")
ENDIF(ENABLE_LUAJIT MATCHES "ON")
SET_TARGET_PROPERTIES(rspamd-lua PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB")
-INSTALL(TARGETS rspamd-lua
- LIBRARY DESTINATION ${LIBDIR}
- PUBLIC_HEADER DESTINATION ${INCLUDEDIR}
- ARCHIVE DESTINATION ${LIBDIR})
+IF(NO_SHARED MATCHES "OFF")
+ INSTALL(TARGETS rspamd-lua
+ LIBRARY DESTINATION ${LIBDIR}
+ PUBLIC_HEADER DESTINATION ${INCLUDEDIR})
+ENDIF(NO_SHARED MATCHES "OFF") \ No newline at end of file