aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorcebka@lenovo-laptop <cebka@lenovo-laptop>2010-02-19 18:13:54 +0300
committercebka@lenovo-laptop <cebka@lenovo-laptop>2010-02-19 18:13:54 +0300
commit72e6f43d545d8d430aaeb26e9ef250fb94d0f674 (patch)
treea75bf88dcbecb74e09a0a380c3a6ca7494617c6c /CMakeLists.txt
parent94edb9f04b2144be4a78556653451456738ba767 (diff)
downloadrspamd-72e6f43d545d8d430aaeb26e9ef250fb94d0f674.tar.gz
rspamd-72e6f43d545d8d430aaeb26e9ef250fb94d0f674.zip
* Add ability to build rspamd static
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt67
1 files changed, 59 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index db420d556..270188dfb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,6 +24,7 @@ OPTION(SKIP_RELINK_RPATH "Skip relinking and full RPATH for the install tree"
OPTION(ENABLE_REDIRECTOR "Enable redirector install [default: OFF]" OFF)
OPTION(ENABLE_PROFILING "Enable profiling [default: OFF]" OFF)
OPTION(ENABLE_GPERF_TOOLS "Enable google perftools [default: OFF]" OFF)
+OPTION(ENABLE_STATIC "Enable static compiling [default: OFF]" OFF)
# Build optimized code for following CPU (default i386)
#SET(CPU_TUNE "i686")
@@ -93,7 +94,12 @@ IF(NOT LEX_EXECUTABLE OR NOT YACC_EXECUTABLE)
MESSAGE(FATAL_ERROR "Error: yacc and lex are required for build")
ENDIF(NOT LEX_EXECUTABLE OR NOT YACC_EXECUTABLE)
-pkg_check_modules(GLIB2 REQUIRED glib-2.0>=2.16 gmodule-2.0)
+IF(ENABLE_STATIC MATCHES "ON")
+ pkg_check_modules(GLIB2 REQUIRED glib-2.0>=2.16)
+ pkg_check_modules(PCRE REQUIRED libpcre)
+ELSE(ENABLE_STATIC MATCHES "ON")
+ pkg_check_modules(GLIB2 REQUIRED glib-2.0>=2.16 gmodule-2.0)
+ENDIF(ENABLE_STATIC MATCHES "ON")
pkg_check_modules(GMIME2 gmime-2.0)
# Try to link with gmime24
@@ -111,16 +117,30 @@ ENDIF(NOT GLIB2_FOUND OR NOT GMIME2_FOUND)
FOREACH(arg ${GLIB2_CFLAGS})
SET(GLIB_CFLAGS "${GLIB_CFLAGS} ${arg}")
ENDFOREACH(arg ${GLIB2_CFLAGS})
-FOREACH(arg ${GLIB2_LDFLAGS})
- SET(GLIB_LDFLAGS "${GLIB_LDFLAGS} ${arg}")
-ENDFOREACH(arg ${GLIB2_LDFLAGS})
+
+IF(ENABLE_STATIC MATCHES "ON")
+ FOREACH(arg ${GLIB2_STATIC_LDFLAGS})
+ SET(GLIB_LDFLAGS "${GLIB_LDFLAGS} ${arg}")
+ ENDFOREACH(arg ${GLIB2_LDFLAGS})
+ELSE(ENABLE_STATIC MATCHES "ON")
+ FOREACH(arg ${GLIB2_LDFLAGS})
+ SET(GLIB_LDFLAGS "${GLIB_LDFLAGS} ${arg}")
+ ENDFOREACH(arg ${GLIB2_LDFLAGS})
+ENDIF(ENABLE_STATIC MATCHES "ON")
# Gmime2
FOREACH(arg ${GMIME2_CFLAGS})
SET(GMIME_CFLAGS "${GMIME_CFLAGS} ${arg}")
ENDFOREACH(arg ${GMIME2_CFLAGS})
-FOREACH(arg ${GMIME2_LDFLAGS})
- SET(GMIME_LDFLAGS "${GMIME_LDFLAGS} ${arg}")
-ENDFOREACH(arg ${GMIME2_LDFLAGS})
+
+IF(ENABLE_STATIC MATCHES "ON")
+ FOREACH(arg ${GMIME2_STATIC_LDFLAGS})
+ SET(GMIME_LDFLAGS "${GMIME_LDFLAGS} ${arg}")
+ ENDFOREACH(arg ${GMIME2_LDFLAGS})
+ELSE(ENABLE_STATIC MATCHES "ON")
+ FOREACH(arg ${GMIME2_LDFLAGS})
+ SET(GMIME_LDFLAGS "${GMIME_LDFLAGS} ${arg}")
+ ENDFOREACH(arg ${GMIME2_LDFLAGS})
+ENDIF(ENABLE_STATIC MATCHES "ON")
INCLUDE_DIRECTORIES(${GLIB2_INCLUDE_DIRS})
@@ -146,6 +166,12 @@ IF(ENABLE_PROFILING MATCHES "ON")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
ENDIF(ENABLE_PROFILING MATCHES "ON")
+IF(ENABLE_STATIC MATCHES "ON")
+ SET(BUILD_STATIC 1)
+ SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
+ MESSAGE(STATUS "Static build of rspamd, no custom plugins support")
+ENDIF(ENABLE_STATIC MATCHES "ON")
+
IF(ENABLE_GPERF_TOOLS MATCHES "ON")
FIND_PATH(GPERF_INCLUDE google/profiler.h PATHS /opt/include
/usr/include
@@ -494,8 +520,8 @@ IF(ENABLE_PERL MATCHES "ON")
ENDIF(ENABLE_PERL MATCHES "ON")
IF(ENABLE_LUA MATCHES "ON")
- TARGET_LINK_LIBRARIES(rspamd "${LUA_LIBRARY}")
TARGET_LINK_LIBRARIES(rspamd rspamd_lua)
+ TARGET_LINK_LIBRARIES(rspamd "${LUA_LIBRARY}")
ENDIF(ENABLE_LUA MATCHES "ON")
TARGET_LINK_LIBRARIES(rspamd m)
@@ -507,6 +533,13 @@ TARGET_LINK_LIBRARIES(rspamd event)
TARGET_LINK_LIBRARIES(rspamd rspamd_json)
TARGET_LINK_LIBRARIES(rspamd ${GLIB2_LIBRARIES})
TARGET_LINK_LIBRARIES(rspamd ${GMIME2_LIBRARIES})
+IF(ENABLE_STATIC MATCHES "ON")
+ TARGET_LINK_LIBRARIES(rspamd ${PCRE_LIBRARIES})
+ENDIF(ENABLE_STATIC MATCHES "ON")
+IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ TARGET_LINK_LIBRARIES(rspamd rt)
+ TARGET_LINK_LIBRARIES(rspamd dl)
+ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
IF(ENABLE_GPERF_TOOLS MATCHES "ON")
TARGET_LINK_LIBRARIES(rspamd profiler)
@@ -521,6 +554,12 @@ ENDIF(LIBUTIL_LIBRARY)
TARGET_LINK_LIBRARIES(test/rspamd-test event)
TARGET_LINK_LIBRARIES(test/rspamd-test ${GLIB2_LIBRARIES})
TARGET_LINK_LIBRARIES(test/rspamd-test ${GMIME2_LIBRARIES})
+IF(ENABLE_STATIC MATCHES "ON")
+ TARGET_LINK_LIBRARIES(test/rspamd-test ${PCRE_LIBRARIES})
+ENDIF(ENABLE_STATIC MATCHES "ON")
+IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ TARGET_LINK_LIBRARIES(test/rspamd-test rt)
+ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
ADD_EXECUTABLE(utils/url-extracter ${UTILSDEPENDS} ${CONTRIBSRC} ${UTILSSRC})
SET_TARGET_PROPERTIES(utils/url-extracter PROPERTIES LINKER_LANGUAGE C)
@@ -530,6 +569,12 @@ IF(LIBUTIL_LIBRARY)
ENDIF(LIBUTIL_LIBRARY)
TARGET_LINK_LIBRARIES(utils/url-extracter ${GLIB2_LIBRARIES})
TARGET_LINK_LIBRARIES(utils/url-extracter ${GMIME2_LIBRARIES})
+IF(ENABLE_STATIC MATCHES "ON")
+ TARGET_LINK_LIBRARIES(utils/url-extracter ${PCRE_LIBRARIES})
+ENDIF(ENABLE_STATIC MATCHES "ON")
+IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ TARGET_LINK_LIBRARIES(utils/url-extracter rt)
+ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
ADD_EXECUTABLE(utils/expression-parser ${UTILSDEPENDS} ${CONTRIBSRC} ${EXPRSRC})
SET_TARGET_PROPERTIES(utils/expression-parser PROPERTIES LINKER_LANGUAGE C)
@@ -539,6 +584,12 @@ IF(LIBUTIL_LIBRARY)
ENDIF(LIBUTIL_LIBRARY)
TARGET_LINK_LIBRARIES(utils/expression-parser ${GLIB2_LIBRARIES})
TARGET_LINK_LIBRARIES(utils/expression-parser ${GMIME2_LIBRARIES})
+IF(ENABLE_STATIC MATCHES "ON")
+ TARGET_LINK_LIBRARIES(utils/expression-parser ${PCRE_LIBRARIES})
+ENDIF(ENABLE_STATIC MATCHES "ON")
+IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ TARGET_LINK_LIBRARIES(utils/expression-parser rt)
+ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
##################### INSTALLATION ##########################################