You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.7 KiB

9 years ago
set(CNAME "f2b")
9 years ago
set(VERSION 0.2)
9 years ago
9 years ago
project(${CNAME} C)
cmake_minimum_required(VERSION 2.6)
9 years ago
9 years ago
include(CTest)
9 years ago
option(WITH_CLIENT "Simple client for configuring daemon" ON)
option(WITH_CSOCKET "Unix control socket support for daemon" ON)
option(WITH_HARDENING "Enable hardening options" OFF)
option(WITH_PCRE "Build pcre-compatible filter" ON)
option(WITH_REDIS "Build redis backend" ON)
9 years ago
if (NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "/usr")
endif ()
# HACK: cmake >= 3.4 fixes this
if (CMAKE_INSTALL_PREFIX MATCHES "^/usr/?$")
set(CMAKE_INSTALL_SYSCONFDIR "/etc")
endif ()
include(GNUInstallDirs)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic -std=c99")
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
add_definitions("-D_XOPEN_SOURCE=600")
else ()
include_directories(AFTER SYSTEM "/usr/local/include")
link_directories("/usr/local/lib")
endif ()
9 years ago
9 years ago
if (WITH_HARDENING)
9 years ago
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wformat -Wformat-security -Werror=format-security" )
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector --param ssp-buffer-size=4" )
add_definitions("-D_FORTIFY_SOURCE=2")
endif ()
message(STATUS "Compiler : ${CMAKE_C_COMPILER} (${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION})")
message(STATUS "- CFLAGS : ${CMAKE_C_FLAGS}")
message(STATUS "Paths:")
message(STATUS "- prefix : ${CMAKE_INSTALL_PREFIX}")
message(STATUS "- configs : ${CMAKE_INSTALL_FULL_SYSCONFDIR}")
message(STATUS "- binary : ${CMAKE_INSTALL_FULL_BINDIR}")
message(STATUS "- binary : ${CMAKE_INSTALL_FULL_SBINDIR}")
message(STATUS "- data : ${CMAKE_INSTALL_FULL_DATAROOTDIR}")
9 years ago
message(STATUS "Build type : ${CMAKE_BUILD_TYPE}")
message(STATUS "Options:")
9 years ago
message(STATUS "- WITH_CLIENT : ${WITH_CLIENT}")
message(STATUS "- WITH_CSOCKET : ${WITH_CSOCKET}")
message(STATUS "- WITH_HARDENING : ${WITH_HARDENING}")
message(STATUS "- WITH_PCRE : ${WITH_PCRE}")
message(STATUS "- WITH_REDIS : ${WITH_REDIS}")
9 years ago
message(STATUS "Components:")
9 years ago
add_subdirectory(src)
add_subdirectory(t)
set_property(DIRECTORY "t" PROPERTY COMPILE_FLAGS "-g;-ggdb;-Wall;-Wextra;-pedantic;-O0")
9 years ago
install(DIRECTORY "filters" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/f2b")
install(DIRECTORY "configs/" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/f2b")
install(FILES "configs/f2b.conf.sample" DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/f2b/" RENAME "f2b.conf")
add_custom_target("dist" COMMAND
"git" "archive" "--format=tar.gz"
"--output=${CNAME}_v${VERSION}.tar.gz"
"--prefix=${CNAME}_v${VERSION}/" "v${VERSION}")
add_custom_target("dist-latest" COMMAND
"git" "archive" "--format=tar.gz"
"--output=${CNAME}_latest.tar.gz"
"--prefix=${CNAME}_latest/" "master")
add_custom_target("lint" COMMAND "cppcheck" "src/")