aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-08-29 10:38:50 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-08-29 10:38:50 +0100
commite4358b2b8eee5dec84d88a917f7fde76dd03af93 (patch)
tree1806ed4eeb8856e3ac06f145a458c09a032cf803
parente2bc2b887fcc7b139eaf74566dfd199bad2791e2 (diff)
downloadrspamd-e4358b2b8eee5dec84d88a917f7fde76dd03af93.tar.gz
rspamd-e4358b2b8eee5dec84d88a917f7fde76dd03af93.zip
Pre-compile config.h
-rw-r--r--CMakeLists.txt28
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/client/CMakeLists.txt4
-rw-r--r--src/libmime/CMakeLists.txt3
-rw-r--r--src/libserver/CMakeLists.txt3
-rw-r--r--src/libutil/CMakeLists.txt2
-rw-r--r--src/lua/CMakeLists.txt1
7 files changed, 39 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d59089a16..44a3f7e38 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -244,6 +244,34 @@ MACRO(ProcessPackage var _name0)
ENDIF(${var}_FOUND)
ENDMACRO(ProcessPackage name)
+MACRO(ADD_PRECOMPILED_HEADER _target _input)
+ GET_FILENAME_COMPONENT(_name ${_input} NAME)
+ SET(_outdir "${CMAKE_BINARY_DIR}/${_name}.pch")
+ MAKE_DIRECTORY(${_outdir})
+ SET(_output "${_outdir}/${_name}.pch")
+ STRING(TOUPPER "CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}" _flags_var_name)
+ SET(_compiler_FLAGS ${${_flags_var_name}})
+ GET_DIRECTORY_PROPERTY(_directory_flags INCLUDE_DIRECTORIES)
+ FOREACH(item ${_directory_flags})
+ LIST(APPEND _compiler_FLAGS "-I${item}")
+ ENDFOREACH(item)
+
+ INCLUDE_DIRECTORIES(${_outdir})
+ IF("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
+ IF(NOT TARGET ${_name}_pch)
+ MESSAGE("${CMAKE_C_COMPILER} -DPCHCOMPILE ${CMAKE_C_FLAGS} -x c-header -o ${_output} ${_input}")
+ ADD_CUSTOM_COMMAND(OUTPUT ${_output}
+ COMMAND ${CMAKE_C_COMPILER} -DPCHCOMPILE ${_compiler_FLAGS} -x c-header -o ${_output} ${_input}
+ DEPENDS ${_input})
+ ADD_CUSTOM_TARGET(${_name}_pch DEPENDS ${_output})
+ ENDIF()
+
+ ADD_CUSTOM_TARGET(${_target}_pch DEPENDS ${_name}_pch)
+ ADD_DEPENDENCIES(${_target} ${_target}_pch)
+ SET_TARGET_PROPERTIES(${_target} PROPERTIES COMPILE_FLAGS "-include ${_name} -Winvalid-pch")
+ ENDIF()
+ENDMACRO()
+
############################# CONFIG SECTION #############################################
# Initial set
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7b6ec0008..ca5bc8779 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -90,20 +90,20 @@ SET(WORKERS_LIST normal controller smtp_proxy fuzzy lua)
AddModules(MODULES_LIST WORKERS_LIST)
LIST(LENGTH PLUGINSSRC RSPAMD_MODULES_NUM)
-
######################### LINK SECTION ###############################
ADD_EXECUTABLE(rspamd ${RSPAMDSRC} ${PLUGINSSRC})
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})
+ SET_TARGET_PROPERTIES(rspamd PROPERTIES VERSION ${RSPAMD_VERSION})
ENDIF(NOT DEBIAN_BUILD)
TARGET_LINK_LIBRARIES(rspamd rspamd-mime)
TARGET_LINK_LIBRARIES(rspamd rspamd-server)
TARGET_LINK_LIBRARIES(rspamd rspamd-util)
TARGET_LINK_LIBRARIES(rspamd rspamd-lua)
+ADD_PRECOMPILED_HEADER(rspamd "${CMAKE_BINARY_DIR}/src/config.h")
TARGET_LINK_LIBRARIES(rspamd event)
IF(HAVE_LIBEVENT2)
diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt
index aa4b8023d..979aa8607 100644
--- a/src/client/CMakeLists.txt
+++ b/src/client/CMakeLists.txt
@@ -7,7 +7,8 @@ ELSE(NO_SHARED MATCHES "OFF")
ADD_LIBRARY(rspamdclient STATIC ${LIBRSPAMDCLIENTSRC})
ENDIF(NO_SHARED MATCHES "OFF")
ADD_LIBRARY(rspamdclient_static STATIC ${LIBRSPAMDCLIENTSRC})
-
+ADD_PRECOMPILED_HEADER(rspamdclient_static "${CMAKE_BINARY_DIR}/src/config.h")
+ADD_PRECOMPILED_HEADER(rspamdclient "${CMAKE_BINARY_DIR}/src/config.h")
SET_TARGET_PROPERTIES(rspamdclient PROPERTIES COMPILE_FLAGS "-fPIC")
SET_TARGET_PROPERTIES(rspamdclient_static PROPERTIES COMPILE_FLAGS "-fPIC")
@@ -30,6 +31,7 @@ ENDIF(NO_SHARED MATCHES "OFF")
SET(RSPAMCSRC rspamc.c)
ADD_EXECUTABLE(rspamc ${RSPAMCSRC})
+ADD_PRECOMPILED_HEADER(rspamc "${CMAKE_BINARY_DIR}/src/config.h")
SET_TARGET_PROPERTIES(rspamc PROPERTIES COMPILE_FLAGS "-I${CMAKE_SOURCE_DIR}/lib")
TARGET_LINK_LIBRARIES(rspamc rspamd-util)
IF(ENABLE_STATIC MATCHES "ON")
diff --git a/src/libmime/CMakeLists.txt b/src/libmime/CMakeLists.txt
index 08efdba09..0635bb3b0 100644
--- a/src/libmime/CMakeLists.txt
+++ b/src/libmime/CMakeLists.txt
@@ -17,8 +17,9 @@ SET_TARGET_PROPERTIES(rspamd-mime PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB")
TARGET_LINK_LIBRARIES(rspamd-mime rspamd-server)
TARGET_LINK_LIBRARIES(rspamd-mime rspamd-util)
IF(CMAKE_COMPILER_IS_GNUCC)
-SET_TARGET_PROPERTIES(rspamd-mime PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB -fno-strict-aliasing")
+ SET_TARGET_PROPERTIES(rspamd-mime PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB -fno-strict-aliasing")
ENDIF(CMAKE_COMPILER_IS_GNUCC)
+ADD_PRECOMPILED_HEADER(rspamd-mime "${CMAKE_BINARY_DIR}/src/config.h")
IF(NO_SHARED MATCHES "OFF")
INSTALL(TARGETS rspamd-mime
diff --git a/src/libserver/CMakeLists.txt b/src/libserver/CMakeLists.txt
index 515c359a8..ee0174ee4 100644
--- a/src/libserver/CMakeLists.txt
+++ b/src/libserver/CMakeLists.txt
@@ -37,8 +37,9 @@ SET(CLASSIFIERSSRC ../classifiers/classifiers.c
#ENDIF(WITH_SQLITE)
ADD_LIBRARY(rspamd-server ${LINK_TYPE} ${LIBRSPAMDSERVERSRC} ${TOKENIZERSSRC} ${CLASSIFIERSSRC})
+ADD_PRECOMPILED_HEADER(rspamd-server "${CMAKE_BINARY_DIR}/src/config.h")
IF(NOT DEBIAN_BUILD)
-SET_TARGET_PROPERTIES(rspamd-server PROPERTIES VERSION ${RSPAMD_VERSION})
+ SET_TARGET_PROPERTIES(rspamd-server PROPERTIES VERSION ${RSPAMD_VERSION})
ENDIF(NOT DEBIAN_BUILD)
SET_TARGET_PROPERTIES(rspamd-server PROPERTIES LINKER_LANGUAGE C COMPILE_FLAGS "-DRSPAMD_LIB")
TARGET_LINK_LIBRARIES(rspamd-server rspamd-lua)
diff --git a/src/libutil/CMakeLists.txt b/src/libutil/CMakeLists.txt
index 1475022f6..7597a9f6e 100644
--- a/src/libutil/CMakeLists.txt
+++ b/src/libutil/CMakeLists.txt
@@ -21,7 +21,7 @@ IF(CMAKE_COMPILER_IS_GNUCC)
SET_TARGET_PROPERTIES(rspamd-util PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing")
ENDIF(CMAKE_COMPILER_IS_GNUCC)
-
+ADD_PRECOMPILED_HEADER(rspamd-util "${CMAKE_BINARY_DIR}/src/config.h")
TARGET_LINK_LIBRARIES(rspamd-util ${RSPAMD_REQUIRED_LIBRARIES})
TARGET_LINK_LIBRARIES(rspamd-util pcre)
TARGET_LINK_LIBRARIES(rspamd-util ucl)
diff --git a/src/lua/CMakeLists.txt b/src/lua/CMakeLists.txt
index fead8405c..f05da4985 100644
--- a/src/lua/CMakeLists.txt
+++ b/src/lua/CMakeLists.txt
@@ -19,6 +19,7 @@ SET(LUASRC lua_common.c
lua_ip.c)
ADD_LIBRARY(rspamd-lua ${LINK_TYPE} ${LUASRC})
+ADD_PRECOMPILED_HEADER(rspamd-lua "${CMAKE_BINARY_DIR}/src/config.h")
SET_TARGET_PROPERTIES(rspamd-lua PROPERTIES VERSION ${RSPAMD_VERSION})
TARGET_LINK_LIBRARIES(rspamd-lua rspamd-util)
TARGET_LINK_LIBRARIES(rspamd-lua hiredis)