]> source.dussan.org Git - rspamd.git/commitdiff
Pre-compile config.h
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 29 Aug 2014 09:38:50 +0000 (10:38 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 29 Aug 2014 09:38:50 +0000 (10:38 +0100)
CMakeLists.txt
src/CMakeLists.txt
src/client/CMakeLists.txt
src/libmime/CMakeLists.txt
src/libserver/CMakeLists.txt
src/libutil/CMakeLists.txt
src/lua/CMakeLists.txt

index d59089a1650d46fe158993b653884f45634b6ea5..44a3f7e380ff9aa878cd6ed62289b6c242879055 100644 (file)
@@ -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
 
index 7b6ec0008f8f3b8863c5af3aaaae15f8994ff18f..ca5bc8779824e4738430ed338e412734f4cd855f 100644 (file)
@@ -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)
index aa4b8023d4063ff3e1a5c23dfa8c88e911347df8..979aa8607510a82902a5c143f79c75589b6852f9 100644 (file)
@@ -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")
index 08efdba095d3b8e01d274e0d945fe4a40700f457..0635bb3b00028a9b2f1cfedbe65c33325d052f36 100644 (file)
@@ -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 
index 515c359a8b2e88f868045cfcaa98aa28f5f94c80..ee0174ee429a764610cf241366d6147a24ad68fa 100644 (file)
@@ -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)
index 1475022f665cacb94044d45ec932cef1f703ef6a..7597a9f6ebe8c5b03321b597e3b6127803d37fe6 100644 (file)
@@ -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)
index fead8405c5953c85c0a690c5e53bd7021f3ec982..f05da4985e6bec9af1834e62581c6af0d6c788ed 100644 (file)
@@ -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)