PROJECT(Qsmtp C) CMAKE_MINIMUM_REQUIRED(VERSION 2.8.6 FATAL_ERROR) OPTION(CHECK_MEMORY "Add memory access checks" OFF) SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules") INCLUDE(AddCCompilerFlag) INCLUDE(CheckCCompilerFlag) INCLUDE(CheckSymbolExists) INCLUDE(CheckFunctionExists) FIND_PACKAGE(owfat REQUIRED) IF (COMMAND cmake_policy) CMAKE_POLICY(SET CMP0003 NEW) ENDIF (COMMAND cmake_policy) IF (AUTOQMAIL) IF (NOT IS_ABSOLUTE "${AUTOQMAIL}") MESSAGE(SEND_ERROR "The value '${AUTOQMAIL}' given for the AUTOQMAIL variable does not name an absolute path") ENDIF () ELSE () SET(AUTOQMAIL /var/qmail) ENDIF () SET(AUTOQMAIL "${AUTOQMAIL}" CACHE PATH "Directory of qmail installation (usually /var/qmail)") SET(QSMTP_VERSION_MAJOR 0) SET(QSMTP_VERSION_MINOR 29) SET(QSMTP_VERSION_EXTRAVERSION svn) SET(QSMTP_VERSION "${QSMTP_VERSION_MAJOR}.${QSMTP_VERSION_MINOR}${QSMTP_VERSION_EXTRAVERSION}") FIND_PACKAGE(OpenSSL REQUIRED) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/include/version.h.tmpl ${CMAKE_BINARY_DIR}/version.h @ONLY) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/include/qmaildir.h.tmpl ${CMAKE_BINARY_DIR}/qmaildir.h @ONLY) ADD_SUPPORTED_C_COMPILER_FLAG(CFLAGS_NO_SIGN_COMPARE -Wno-sign-compare) ADD_SUPPORTED_C_COMPILER_FLAG(CFLAGS_NO_POINTER_SIGN -Wno-pointer-sign) ADD_SUPPORTED_C_COMPILER_FLAG(CFLAGS_SHADOW -Wshadow) IF (CHECK_MEMORY) ADD_SUPPORTED_C_COMPILER_FLAG(CFLAGS_STACK_PROTECTOR -fstack-protector-all) CHECK_C_COMPILER_FLAG(-fmudflap CFLAGS_MUDFLAP) IF (CFLAGS_MUDFLAP) FIND_PACKAGE(mudflap) IF (MUDFLAP_FOUND) ADD_C_COMPILER_FLAG(-fmudflap) ENDIF (MUDFLAP_FOUND) ENDIF (CFLAGS_MUDFLAP) FIND_PACKAGE(ElectricFence) IF (EFENCE_FOUND) SET(MEMCHECK_LIBRARIES ${EFENCE_LIBRARIES}) ENDIF (EFENCE_FOUND) ENDIF (CHECK_MEMORY) SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -fprofile-arcs -ftest-coverage") ADD_C_COMPILER_FLAG(-Wall -W -Wshadow) ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64) CHECK_SYMBOL_EXISTS(O_CLOEXEC "fcntl.h" HAS_O_CLOEXEC) IF (NOT HAS_O_CLOEXEC) ADD_DEFINITIONS(-DO_CLOEXEC=0) ENDIF () CHECK_SYMBOL_EXISTS(O_DIRECTORY "fcntl.h" HAS_O_DIRECTORY) IF (NOT HAS_O_DIRECTORY) ADD_DEFINITIONS(-DO_DIRECTORY=0) ENDIF () SET(CMAKE_REQUIRED_INCLUDES fcntl.h) CHECK_FUNCTION_EXISTS(openat HAS_OPENAT) UNSET(CMAKE_REQUIRED_INCLUDES) IF (NOT HAS_OPENAT) MESSAGE(SEND_ERROR "Support for openat() is missing") ENDIF () OPTION(NOSTDERR "Do not print error messages to stderr" ON) OPTION(USESYSLOG "Use syslog() for logging" ON) IF(USESYSLOG) ADD_DEFINITIONS(-DUSESYSLOG) ENDIF(USESYSLOG) OPTION(IPV4ONLY "Disable support for IPv6 connections" OFF) IF(IPV4ONLY) ADD_DEFINITIONS(-DIPV4ONLY) ENDIF(IPV4ONLY) OPTION(CHUNKING "Enable CHUNKING extension (RfC 3030)" OFF) IF(CHUNKING) ADD_DEFINITIONS(-DCHUNKING) ENDIF(CHUNKING) OPTION(DEBUG_IO "Log the SMTP session" OFF) IF(DEBUG_IO) ADD_DEFINITIONS(-DDEBUG_IO) ENDIF(DEBUG_IO) OPTION(AUTHCRAM "Support CRAMMD5 authentication method" OFF) IF(AUTHCRAM) ADD_DEFINITIONS(-DAUTHCRAM) ENDIF(AUTHCRAM) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/include ${OPENSSL_INCLUDE_DIR} ${CMAKE_BINARY_DIR} ) ADD_SUBDIRECTORY(lib) ADD_SUBDIRECTORY(qsmtpd) ADD_SUBDIRECTORY(qremote) ADD_SUBDIRECTORY(tools) INCLUDE(CTest) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake @ONLY) ENABLE_TESTING() ADD_SUBDIRECTORY(tests) OPTION(BUILD_DOC "Build documentation" ON) IF (BUILD_DOC) # API documentation FIND_PACKAGE(Doxygen REQUIRED) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) ADD_CUSTOM_TARGET(docu ALL COMMAND ${DOXYGEN_EXECUTABLE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) IF (NOT DOC_DESTINATION_DIRECTORY) SET(DOC_DESTINATION_DIRECTORY "doc/") ENDIF (NOT DOC_DESTINATION_DIRECTORY) INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION ${DOC_DESTINATION_DIRECTORY}) # general documentation INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/doc/CREDITS ${CMAKE_CURRENT_SOURCE_DIR}/doc/INSTALL ${CMAKE_CURRENT_SOURCE_DIR}/doc/THOUGHTS ${CMAKE_CURRENT_SOURCE_DIR}/doc/faq.html DESTINATION ${DOC_DESTINATION_DIRECTORY}) # man pages CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/doc/man/Qremote.8 ${CMAKE_CURRENT_BINARY_DIR}/Qremote.8 @ONLY) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/doc/man/Qsmtpd.8 ${CMAKE_CURRENT_BINARY_DIR}/Qsmtpd.8 @ONLY) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/doc/man/filterconf.5 ${CMAKE_CURRENT_BINARY_DIR}/filterconf.5 @ONLY) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/Qremote.8 ${CMAKE_CURRENT_BINARY_DIR}/Qsmtpd.8 DESTINATION man/man8) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/filterconf.5 DESTINATION man/man5) ENDIF (BUILD_DOC)