logswan

Fast Web log analyzer using probabilistic data structures
Log | Files | Refs | README | LICENSE

CMakeLists.txt (2399B)


      1 #
      2 # Logswan 2.1.6
      3 # Copyright (c) 2015-2020, Frederic Cambus
      4 # https://www.logswan.org
      5 #
      6 # Created:      2015-05-31
      7 # Last Updated: 2020-06-09
      8 #
      9 # Logswan is released under the BSD 2-Clause license
     10 # See LICENSE file for details
     11 #
     12 
     13 cmake_minimum_required (VERSION 2.6)
     14 
     15 project(logswan C)
     16 
     17 include(CheckFunctionExists)
     18 include(GNUInstallDirs)
     19 
     20 # Conditional build options
     21 set(ENABLE_SECCOMP 0
     22     CACHE BOOL "Enable building with seccomp")
     23 
     24 # Check if system has pledge and strtonum
     25 list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_OPENBSD_SOURCE)
     26 check_function_exists(pledge HAVE_PLEDGE)
     27 check_function_exists(strtonum HAVE_STRTONUM)
     28 
     29 if(ENABLE_SECCOMP)
     30   # Check if system has seccomp
     31   message(STATUS "Looking for seccomp")
     32   find_path(SECCOMP NAMES "linux/seccomp.h")
     33   if(SECCOMP)
     34     message(STATUS "Looking for seccomp - found")
     35     add_definitions(-DHAVE_SECCOMP)
     36   else()
     37     message(STATUS "Looking for seccomp - not found")
     38   endif()
     39 endif(ENABLE_SECCOMP)
     40 
     41 # Additional include directories for compat functions + dependencies
     42 include_directories("compat")
     43 include_directories("deps/hll")
     44 
     45 # libmaxminddb
     46 find_path(GEOIP2_INCLUDE_DIRS maxminddb.h)
     47 find_library(GEOIP2_LIBRARIES NAMES maxminddb REQUIRED)
     48 include_directories(${GEOIP2_INCLUDE_DIRS})
     49 
     50 # Jansson
     51 find_path(JANSSON_INCLUDE_DIRS jansson.h)
     52 find_library(JANSSON_LIBRARIES NAMES jansson REQUIRED)
     53 include_directories(${JANSSON_INCLUDE_DIRS})
     54 
     55 set(CMAKE_BUILD_TYPE Release)
     56 set(DEPS deps/hll/hll.c deps/MurmurHash3/MurmurHash3.c)
     57 set(SRC src/logswan.c src/config.c src/continents.c src/countries.c
     58     src/output.c src/parse.c)
     59 
     60 if(NOT HAVE_PLEDGE)
     61   set (SRC ${SRC} compat/pledge.c)
     62 endif()
     63 
     64 if(NOT HAVE_STRTONUM)
     65   set (SRC ${SRC} compat/strtonum.c)
     66 endif()
     67 
     68 set(GEOIP2DIR ${CMAKE_INSTALL_PREFIX}/share/dbip
     69     CACHE PATH "Path to GeoIP2 databases")
     70 set(GEOIP2DB "dbip-country-lite.mmdb" CACHE PATH "GeoIP2 database file")
     71 
     72 add_definitions(-D_GNU_SOURCE -Wall -Wextra -std=c11 -pedantic)
     73 add_definitions(-DGEOIP2DIR="${GEOIP2DIR}/")
     74 add_definitions(-DGEOIP2DB="${GEOIP2DB}")
     75 add_executable(logswan ${SRC} ${DEPS})
     76 
     77 target_link_libraries(logswan ${GEOIP2_LIBRARIES} ${JANSSON_LIBRARIES} m)
     78 
     79 install(TARGETS logswan DESTINATION ${CMAKE_INSTALL_BINDIR})
     80 install(FILES logswan.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1/)
     81 
     82 enable_testing()
     83 add_test(logswan logswan)
     84 add_test(processing logswan ${PROJECT_SOURCE_DIR}/examples/logswan.log)