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
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)
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")
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")
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
#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)
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)
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)