2014-11-28 15:22:27 +01:00
|
|
|
cmake_minimum_required (VERSION 2.8)
|
|
|
|
|
2014-11-28 15:58:12 +01:00
|
|
|
# cmake versions:
|
2014-11-28 15:22:27 +01:00
|
|
|
# Debian 6 - 2.8.2
|
|
|
|
# Debian 7 - 2.8.9
|
|
|
|
# CentOS 6 - 2.8.12
|
|
|
|
|
2015-10-03 21:17:58 +02:00
|
|
|
### set(ENABLE_GOBGP_SUPPORT "yes")
|
|
|
|
|
2015-08-17 15:02:19 +02:00
|
|
|
# We should set compiler before project() call
|
|
|
|
if (ENABLE_BUILD_IN_CPP_11_CUSTOM_ENVIRONMENT)
|
|
|
|
# We use custom compiler too
|
|
|
|
set(CMAKE_C_COMPILER "/opt/gcc520/bin/gcc")
|
|
|
|
set(CMAKE_CXX_COMPILER "/opt/gcc520/bin/g++")
|
|
|
|
endif()
|
|
|
|
|
2014-11-28 15:22:27 +01:00
|
|
|
project(FastNetMon)
|
|
|
|
|
2015-06-04 22:54:29 +02:00
|
|
|
# Unfortunately, Debian Squeeze haven't support for this feature
|
|
|
|
# It added in 2.8.5 release: http://www.cmake.org/cmake/help/v2.8.5/cmake.html
|
2015-06-04 15:13:22 +02:00
|
|
|
# Get convinient paths for all system folders: http://www.cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a262fe09
|
2015-06-04 22:54:29 +02:00
|
|
|
# include(GNUInstallDirs)
|
2015-06-04 15:13:22 +02:00
|
|
|
|
2015-03-22 22:30:51 +01:00
|
|
|
# Enable it and fix all warnigns!
|
|
|
|
# add_definitions ("-Wall")
|
|
|
|
|
2015-08-12 17:24:13 +02:00
|
|
|
set (FASTNETMON_VERSION_MAJOR 1)
|
|
|
|
set (FASTNETMON_VERSION_MINOR 1)
|
|
|
|
|
2015-10-03 21:17:58 +02:00
|
|
|
if (ENABLE_GOBGP_SUPPORT)
|
|
|
|
# We could not compile gRPC without C++ 11
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11")
|
|
|
|
endif()
|
|
|
|
|
2015-08-12 17:24:13 +02:00
|
|
|
# cmake -DENABLE_BUILD_IN_CPP_11_CUSTOM_ENVIRONMENT=ON ..
|
|
|
|
if (ENABLE_BUILD_IN_CPP_11_CUSTOM_ENVIRONMENT)
|
|
|
|
set(BOOST_INCLUDEDIR "/opt/boost_1_58_0")
|
|
|
|
set(BOOST_LIBRARYDIR "/opt/boost_1_58_0/stage/lib/")
|
|
|
|
|
2015-08-13 17:34:28 +02:00
|
|
|
# It's really nice part of this custom build process :)
|
2015-08-12 17:24:13 +02:00
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11")
|
2015-08-13 17:34:28 +02:00
|
|
|
|
2015-08-12 17:24:13 +02:00
|
|
|
# Disable warning from Boost when compiling with gcc 5.2
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-deprecated-declarations")
|
2015-08-13 17:34:28 +02:00
|
|
|
|
|
|
|
# Specify full RPATH for build tree
|
|
|
|
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
|
|
|
|
|
|
|
|
# Create builds in current folder with install RPATH
|
|
|
|
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
|
|
|
|
2015-09-30 16:54:57 +02:00
|
|
|
SET(CMAKE_INSTALL_RPATH "/opt/gcc520/lib64;/opt/boost_1_58_0/stage/lib;/opt/libhiredis_0_13/lib;/opt/log4cpp1.1.1/lib;/opt/luajit_2.0.4/lib;/opt/ndpi/lib;/opt/pf_ring_6.0.3/lib;/opt/json-c-0.12/lib;/opt/mongo_c_driver_1_1_9/lib")
|
2015-08-12 17:24:13 +02:00
|
|
|
endif()
|
2014-11-28 15:22:27 +01:00
|
|
|
|
2015-10-03 21:17:58 +02:00
|
|
|
message(STATUS "C++ compilation flags: ${CMAKE_CXX_FLAGS_RELEASE}")
|
2014-12-18 11:23:56 +01:00
|
|
|
|
2015-08-11 08:18:17 +02:00
|
|
|
set(HIREDIS_CUSTOM_INSTALL_PATH "/opt/libhiredis_0_13")
|
2015-08-11 10:24:08 +02:00
|
|
|
set(LOG4CPP_CUSTOM_INSTALL_PATH "/opt/log4cpp1.1.1")
|
2015-08-12 19:27:29 +02:00
|
|
|
set(JSONC_CUSTOM_INSTALL_PATH "/opt/json-c-0.12")
|
2015-08-17 15:02:19 +02:00
|
|
|
set(PFRING_CUSTOM_INSTALL_PATH "/opt/pf_ring_6.0.3")
|
2015-08-30 19:34:13 +02:00
|
|
|
set(LIBPCAP_CUSTOM_INSTALL_PATH "/opt/libpcap_1.7.4")
|
2015-09-30 16:54:57 +02:00
|
|
|
set(MONGO_C_CUSTOM_INSTALL_PATH "/opt/mongo_c_driver_1_1_9")
|
2015-08-11 08:18:17 +02:00
|
|
|
|
2014-12-19 09:42:10 +01:00
|
|
|
set(FASTNETMON_PROFILER OFF)
|
|
|
|
|
|
|
|
set(FASTNETMON_PROFILE_FLAGS "-g -pg")
|
|
|
|
|
2015-06-03 11:27:17 +02:00
|
|
|
if (NOT CMAKE_BUILD_TYPE)
|
|
|
|
message(STATUS "Setting build type to Release as none was specified.")
|
|
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
|
|
endif()
|
|
|
|
|
2014-12-19 09:42:10 +01:00
|
|
|
if (FASTNETMON_PROFILER)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FASTNETMON_PROFILE_FLAGS}")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FASTNETMON_PROFILE_FLAGS}")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FASTNETMON_PROFILE_FLAGS}")
|
|
|
|
endif()
|
|
|
|
|
2015-09-30 13:00:09 +02:00
|
|
|
# Get last commit hash
|
|
|
|
execute_process(COMMAND git rev-list HEAD COMMAND head -n 1 OUTPUT_VARIABLE GIT_LAST_COMMIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
|
|
|
|
set(FASTNETMON_APPLICATION_VERSION "1.1.3 master git-${GIT_LAST_COMMIT_HASH}")
|
2015-06-04 13:08:25 +02:00
|
|
|
configure_file(fast_platform.h.template "${PROJECT_SOURCE_DIR}/fast_platform.h")
|
|
|
|
|
2015-01-24 16:23:08 +01:00
|
|
|
# With this flag we can diable PF_RING build via console: cmake .. -DDISABLE_PF_RING_SUPPORT=ON
|
|
|
|
if (NOT DISABLE_PF_RING_SUPPORT)
|
|
|
|
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
2015-06-03 11:27:17 +02:00
|
|
|
message(STATUS "You are running Linux and we can build PF_RING support")
|
2015-01-24 16:23:08 +01:00
|
|
|
set (ENABLE_PFRING_SUPPORT ON)
|
|
|
|
else()
|
2015-06-03 11:27:17 +02:00
|
|
|
message(WARNING "You are running not an Linux and we can't build PF_RING support")
|
2015-01-24 16:23:08 +01:00
|
|
|
endif()
|
|
|
|
endif()
|
2014-11-28 15:58:12 +01:00
|
|
|
|
2015-01-24 16:23:08 +01:00
|
|
|
if (ENABLE_PFRING_SUPPORT)
|
2015-03-24 12:04:18 +01:00
|
|
|
# work around for broken 6.0.3 (which in reality very old 6.0.3) from ntop packages
|
2015-03-24 13:27:45 +01:00
|
|
|
#if (WE_USE_PFRING_FROM_NTOP)
|
|
|
|
# add_definitions(-DWE_USE_PFRING_FROM_NTOP)
|
|
|
|
#endif()
|
2015-03-24 12:04:18 +01:00
|
|
|
|
|
|
|
if (WE_USE_PFRING_FROM_NTOP)
|
|
|
|
# Because ntop will add libs and headers to global paths
|
2015-03-24 12:31:11 +01:00
|
|
|
set(PFRING_LIBRARIES pfring)
|
2015-03-24 12:04:18 +01:00
|
|
|
else()
|
|
|
|
# Set path to manually compiled PF_RING
|
2015-08-17 15:02:19 +02:00
|
|
|
set(PFRING_INCLUDE_DIRS "${PFRING_CUSTOM_INSTALL_PATH}/include")
|
2015-07-27 08:29:59 +02:00
|
|
|
set(PFRING_LIBRARIES pfring)
|
2015-08-17 15:02:19 +02:00
|
|
|
link_directories("${PFRING_CUSTOM_INSTALL_PATH}/lib")
|
2015-03-24 12:04:18 +01:00
|
|
|
endif()
|
|
|
|
|
2015-01-09 23:43:23 +01:00
|
|
|
add_definitions(-DPF_RING)
|
2015-02-03 20:55:44 +01:00
|
|
|
|
2015-08-17 15:02:19 +02:00
|
|
|
if (EXISTS "${PFRING_CUSTOM_INSTALL_PATH}/include/pfring_zc.h" OR EXISTS "/usr/local/include/pfring_zc.h")
|
2015-06-03 11:27:17 +02:00
|
|
|
message(STATUS "We found PF_RING ZC headers and will build PF_RING ZC support")
|
2015-02-24 17:53:41 +01:00
|
|
|
# Enable ZC support
|
|
|
|
add_definitions(-DPF_RING_ZC)
|
|
|
|
else()
|
2015-06-03 11:27:17 +02:00
|
|
|
message(WARNING "We can't find PF_RING ZC header pfring_zc.h in folder /opt/pf_ring/include. Will not compile ZC support")
|
2015-02-24 17:53:41 +01:00
|
|
|
endif()
|
|
|
|
|
2015-02-03 20:55:44 +01:00
|
|
|
include_directories(${PFRING_INCLUDE_DIRS})
|
2015-01-09 23:43:23 +01:00
|
|
|
|
2015-09-03 13:09:16 +02:00
|
|
|
message(STATUS "We have enabled PF_RING's hardware filtering option")
|
|
|
|
endif()
|
2014-12-03 15:56:08 +01:00
|
|
|
|
2014-11-28 15:58:12 +01:00
|
|
|
# Our LPM library
|
2014-12-16 09:01:07 +01:00
|
|
|
add_library(patricia STATIC libpatricia/patricia.c)
|
2014-11-28 15:22:27 +01:00
|
|
|
|
2015-07-22 14:16:13 +02:00
|
|
|
add_library(fastnetmon_pcap_format STATIC fastnetmon_pcap_format.cpp)
|
|
|
|
|
2015-03-21 11:47:25 +01:00
|
|
|
# Our tools library
|
|
|
|
add_library(fast_library STATIC fast_library.cpp)
|
|
|
|
|
2015-03-22 17:00:16 +01:00
|
|
|
# Our ipfix database library
|
|
|
|
add_library(ipfix_rfc STATIC ipfix_rfc.cpp)
|
|
|
|
|
2015-03-10 15:18:52 +01:00
|
|
|
# Our packet parser
|
2015-03-21 12:56:44 +01:00
|
|
|
add_library(fastnetmon_packet_parser STATIC fastnetmon_packet_parser.c)
|
2015-03-10 15:18:52 +01:00
|
|
|
|
2015-08-31 12:25:57 +02:00
|
|
|
# -DENABLE_SNABBSWITCH_SUPPORT=ON ..
|
2015-08-31 14:15:16 +02:00
|
|
|
# Please also comment out line: set(ENABLE_LUA_SUPPORT yes) if you want SnabbSwitch support
|
2015-08-31 12:25:57 +02:00
|
|
|
if (ENABLE_SNABBSWITCH_SUPPORT)
|
|
|
|
add_definitions(-DSNABB_SWITCH)
|
|
|
|
add_library(snabbswitch_plugin STATIC snabbswitch_plugin/snabbswitch_collector.cpp)
|
|
|
|
|
|
|
|
link_directories(/usr/src/snabbswitch/src)
|
|
|
|
target_link_libraries(snabbswitch_plugin snabb)
|
|
|
|
endif()
|
|
|
|
|
2015-09-01 14:37:50 +02:00
|
|
|
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
2015-10-03 18:09:37 +02:00
|
|
|
execute_process(COMMAND uname -r OUTPUT_VARIABLE LINUX_KERNEL_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
|
|
|
|
# Extract major version number from Linux Kernel Version
|
|
|
|
string(REGEX MATCH "^[0-9]+\\.[0-9]+" KERNEL_VERSION_MATCHES ${LINUX_KERNEL_VERSION})
|
|
|
|
|
|
|
|
# For tests
|
|
|
|
# set(KERNEL_VERSION_MATCHES "2.6.32")
|
|
|
|
|
|
|
|
# We need 3.7 or more recent kernel here because older kernels are buggy
|
|
|
|
# VERSION_GREATER comparator available from cmake 2.6.2
|
|
|
|
if (${KERNEL_VERSION_MATCHES} VERSION_GREATER "3.7")
|
|
|
|
message(STATUS "You are running Linux with enough recent kernel and we can build AF_PACKET support")
|
|
|
|
set (ENABLE_AFPACKET_SUPPORT ON)
|
|
|
|
else()
|
|
|
|
message(STATUS "You are running old Linux kernel and we can't build AF_PACKET support")
|
|
|
|
endif()
|
2015-09-01 14:37:50 +02:00
|
|
|
endif()
|
|
|
|
|
2015-09-01 10:41:55 +02:00
|
|
|
# -DENABLE_AFPACKET_SUPPORT=ON ..
|
|
|
|
if (ENABLE_AFPACKET_SUPPORT)
|
|
|
|
add_definitions(-DFASTNETMON_ENABLE_AFPACKET)
|
2015-10-03 18:09:37 +02:00
|
|
|
add_library(afpacket_plugin STATIC afpacket_plugin/afpacket_collector.cpp)
|
2015-09-01 10:41:55 +02:00
|
|
|
endif()
|
|
|
|
|
2015-01-26 10:10:35 +01:00
|
|
|
# sFLOW plugin
|
2014-12-01 22:08:38 +01:00
|
|
|
add_library(sflow_plugin STATIC sflow_plugin/sflow_collector.cpp)
|
2014-12-01 21:26:08 +01:00
|
|
|
|
2015-01-26 10:10:35 +01:00
|
|
|
# netflow plugin
|
2015-01-23 17:49:37 +01:00
|
|
|
add_library(netflow_plugin STATIC netflow_plugin/netflow_collector.cpp)
|
2015-03-22 17:00:16 +01:00
|
|
|
target_link_libraries(netflow_plugin ipfix_rfc)
|
2015-01-23 17:49:37 +01:00
|
|
|
|
2015-07-30 20:22:09 +02:00
|
|
|
set(ENABLE_DPI_SUPPORT YES)
|
2015-07-24 14:45:15 +02:00
|
|
|
if (ENABLE_DPI_SUPPORT)
|
2015-08-02 23:27:22 +02:00
|
|
|
message(STATUS "We will enable nDPI support")
|
|
|
|
|
2015-07-24 14:45:15 +02:00
|
|
|
add_library(fast_dpi STATIC fast_dpi.cpp)
|
|
|
|
|
|
|
|
set(NDPI_INCLUDE_DIRS "/opt/ndpi/include/libndpi-1.7.0")
|
|
|
|
set(NDPI_LIBRARIES "ndpi")
|
|
|
|
|
|
|
|
link_directories("/opt/ndpi/lib")
|
|
|
|
include_directories(${NDPI_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
add_definitions(-DENABLE_DPI)
|
|
|
|
|
|
|
|
target_link_libraries(fast_dpi ${NDPI_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
2015-06-22 10:19:04 +02:00
|
|
|
# We do not enable it by default, it's testing feature
|
|
|
|
# If you want it please build with:
|
|
|
|
# cmake -DENABLE_LUA_SUPPORT=ON ..
|
2015-08-02 23:11:20 +02:00
|
|
|
set(ENABLE_LUA_SUPPORT yes)
|
2015-06-22 10:19:04 +02:00
|
|
|
if (ENABLE_LUA_SUPPORT)
|
2015-07-03 17:01:18 +02:00
|
|
|
message(STATUS "We will enable LuaJIT support")
|
|
|
|
|
2015-06-22 10:19:04 +02:00
|
|
|
add_definitions(-DENABLE_LUA_HOOKS)
|
2015-08-02 22:38:37 +02:00
|
|
|
|
|
|
|
link_directories("/opt/luajit_2.0.4/lib")
|
|
|
|
include_directories("/opt/luajit_2.0.4/include")
|
2015-06-22 10:19:04 +02:00
|
|
|
|
|
|
|
target_link_libraries(netflow_plugin luajit-5.1)
|
2015-07-03 17:01:18 +02:00
|
|
|
target_link_libraries(sflow_plugin luajit-5.1)
|
|
|
|
target_link_libraries(fast_library luajit-5.1)
|
2015-06-22 10:19:04 +02:00
|
|
|
endif()
|
|
|
|
|
2015-01-26 14:37:12 +01:00
|
|
|
# pcap plugin
|
|
|
|
add_library(pcap_plugin STATIC pcap_plugin/pcap_collector.cpp)
|
2015-02-01 14:02:16 +01:00
|
|
|
target_link_libraries(pcap_plugin pcap)
|
2015-01-26 14:37:12 +01:00
|
|
|
|
2015-06-02 22:27:49 +02:00
|
|
|
find_package(Threads)
|
|
|
|
|
2015-02-03 20:55:44 +01:00
|
|
|
if (ENABLE_PFRING_SUPPORT)
|
|
|
|
add_library(pfring_plugin STATIC pfring_plugin/pfring_collector.cpp)
|
|
|
|
target_link_libraries(pfring_plugin ${PFRING_LIBRARIES})
|
|
|
|
target_link_libraries(pfring_plugin numa)
|
2015-06-02 22:27:49 +02:00
|
|
|
target_link_libraries(pfring_plugin ${CMAKE_THREAD_LIBS_INIT})
|
2015-09-03 13:09:16 +02:00
|
|
|
|
|
|
|
# Add action for hardware filetring
|
|
|
|
add_library(pfring_hardware_filter_action STATIC actions/pfring_hardware_filter_action.cpp)
|
2015-02-03 20:55:44 +01:00
|
|
|
endif()
|
|
|
|
|
2015-10-03 21:17:58 +02:00
|
|
|
if (ENABLE_GOBGP_SUPPORT)
|
|
|
|
set(GOBGP_CUSTOM_INSTALL_PATH "/opt/libgobgp_1_0_0")
|
|
|
|
|
|
|
|
find_path(GOBGP_INCLUDES_FOLDER NAMES libgobgp.h PATHS "${GOBGP_CUSTOM_INSTALL_PATH}/include" NO_DEFAULT_PATH)
|
|
|
|
find_library(GOBGP_LIBRARY_PATH NAMES gobgp PATHS "${GOBGP_CUSTOM_INSTALL_PATH}/lib" NO_DEFAULT_PATH)
|
|
|
|
|
|
|
|
set(GRPC_CUSTOM_INSTALL_PATH "/opt/grpc_0_11_1_7a94236d698477636dd06282f12f706cad527029")
|
|
|
|
|
|
|
|
find_path(GRPC_INCLUDES_FOLDER NAMES grpc/grpc.h PATHS "${GRPC_CUSTOM_INSTALL_PATH}/include" NO_DEFAULT_PATH)
|
|
|
|
find_library(GRPC_LIBRARY_GRPC_PATH NAMES grpc PATHS "${GRPC_CUSTOM_INSTALL_PATH}/lib" NO_DEFAULT_PATH)
|
|
|
|
find_library(GRPC_LIBRARY_GPR_PATH NAMES gpr PATHS "${GRPC_CUSTOM_INSTALL_PATH}/lib" NO_DEFAULT_PATH)
|
|
|
|
|
|
|
|
if (GRPC_INCLUDES_FOLDER AND GRPC_LIBRARY_GRPC_PATH AND GRPC_LIBRARY_GPR_PATH)
|
|
|
|
include_directories(${GRPC_INCLUDES_FOLDER})
|
|
|
|
endif()
|
|
|
|
message(STATUS "grpc: ${GRPC_INCLUDES_FOLDER} ${GRPC_LIBRARY_GRPC_PATH} ${GRPC_LIBRARY_GPR_PATH}")
|
|
|
|
|
|
|
|
if (GOBGP_INCLUDES_FOLDER AND GOBGP_LIBRARY_PATH)
|
|
|
|
message(STATUS "We found libgobgp and will link it")
|
|
|
|
include_directories(${GOBGP_INCLUDES_FOLDER})
|
|
|
|
add_library(gobgp_action STATIC actions/gobgp_action.cpp)
|
|
|
|
else()
|
|
|
|
message(STATUS "Could not find libgobgp")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2015-01-26 10:10:35 +01:00
|
|
|
# example plugin
|
|
|
|
add_library(example_plugin STATIC example_plugin/example_collector.cpp)
|
|
|
|
|
2015-03-10 15:18:52 +01:00
|
|
|
# Netmap plugin
|
|
|
|
set(NETMAP_INCLUDE_DIRS "netmap_plugin/netmap_includes")
|
|
|
|
include_directories(${NETMAP_INCLUDE_DIRS})
|
|
|
|
add_library(netmap_plugin STATIC netmap_plugin/netmap_collector.cpp)
|
2015-03-10 15:22:24 +01:00
|
|
|
target_link_libraries(netmap_plugin fastnetmon_packet_parser)
|
2015-03-10 15:18:52 +01:00
|
|
|
|
2014-11-28 15:58:12 +01:00
|
|
|
# Main tool
|
2014-11-28 15:22:27 +01:00
|
|
|
add_executable(fastnetmon fastnetmon.cpp)
|
|
|
|
|
2014-12-22 16:39:46 +01:00
|
|
|
# Client tool
|
|
|
|
add_executable(fastnetmon_client fastnetmon_client.cpp)
|
|
|
|
|
2014-11-28 15:22:27 +01:00
|
|
|
# Find boost: http://www.cmake.org/cmake/help/v3.0/module/FindBoost.html
|
2014-12-01 09:09:37 +01:00
|
|
|
|
|
|
|
# Enable detailed errors
|
2014-11-28 15:58:12 +01:00
|
|
|
set(Boost_DETAILED_FAILURE_MSG ON)
|
2014-12-01 09:09:37 +01:00
|
|
|
|
2015-09-29 15:40:57 +02:00
|
|
|
find_package(Boost COMPONENTS thread regex program_options system REQUIRED)
|
2014-11-28 15:58:12 +01:00
|
|
|
|
2014-11-28 15:22:27 +01:00
|
|
|
if(Boost_FOUND)
|
|
|
|
include_directories(${Boost_INCLUDE_DIRS})
|
|
|
|
target_link_libraries(fastnetmon ${Boost_LIBRARIES})
|
2015-03-21 13:15:35 +01:00
|
|
|
target_link_libraries(fast_library ${Boost_LIBRARIES})
|
2014-11-28 15:22:27 +01:00
|
|
|
endif()
|
|
|
|
|
2015-05-29 14:45:02 +02:00
|
|
|
target_link_libraries(fast_library patricia)
|
2015-07-22 14:16:13 +02:00
|
|
|
target_link_libraries(fast_library fastnetmon_pcap_format)
|
2015-05-29 14:45:02 +02:00
|
|
|
|
2015-05-07 09:13:05 +02:00
|
|
|
# Try to find ncurses librreary
|
2014-11-28 15:58:12 +01:00
|
|
|
find_package(Curses REQUIRED)
|
|
|
|
|
|
|
|
if(CURSES_FOUND)
|
|
|
|
include_directories(${CURSES_INCLUDE_DIRS})
|
2014-12-22 16:39:46 +01:00
|
|
|
target_link_libraries(fastnetmon_client ${CURSES_LIBRARIES})
|
2014-11-28 15:58:12 +01:00
|
|
|
endif()
|
|
|
|
|
2015-08-11 08:18:17 +02:00
|
|
|
### Move this code to cmake module
|
|
|
|
|
|
|
|
# Try to find hiredis in a specific folder
|
|
|
|
find_path(HIREDIS_INCLUDES_FOLDER NAMES hiredis/hiredis.h PATHS "${HIREDIS_CUSTOM_INSTALL_PATH}/include" NO_DEFAULT_PATH)
|
|
|
|
|
|
|
|
# Try to find hiredis library path
|
|
|
|
find_library(HIREDIS_LIBRARY_PATH NAMES hiredis PATHS "${HIREDIS_CUSTOM_INSTALL_PATH}/lib" NO_DEFAULT_PATH)
|
|
|
|
|
|
|
|
if (HIREDIS_INCLUDES_FOLDER AND HIREDIS_LIBRARY_PATH)
|
|
|
|
message(STATUS "We found hiredis library and will build Redis support ${HIREDIS_INCLUDES_FOLDER} ${HIREDIS_LIBRARY_PATH}")
|
|
|
|
|
|
|
|
add_definitions(-DREDIS)
|
|
|
|
include_directories(${HIREDIS_INCLUDES_FOLDER})
|
|
|
|
target_link_libraries (fastnetmon ${HIREDIS_LIBRARY_PATH})
|
|
|
|
else()
|
|
|
|
message(STATUS "We can't find hiredis library and will disable Redis support")
|
|
|
|
endif()
|
2015-03-19 10:40:58 +01:00
|
|
|
|
2015-09-30 16:54:57 +02:00
|
|
|
### Find mongo-c
|
|
|
|
find_path(MONGOC_INCLUDES_FOLDER NAMES libmongoc-1.0/mongoc.h PATHS "${MONGO_C_CUSTOM_INSTALL_PATH}/include" NO_DEFAULT_PATH)
|
|
|
|
find_library(MONGOC_LIBRARY_PATH NAMES mongoc-1.0 PATHS "${MONGO_C_CUSTOM_INSTALL_PATH}/lib" NO_DEFAULT_PATH)
|
|
|
|
|
|
|
|
### find bson
|
|
|
|
find_path(BSON_INCLUDES_FOLDER NAMES libbson-1.0/bson.h PATHS "${MONGO_C_CUSTOM_INSTALL_PATH}/include" NO_DEFAULT_PATH)
|
|
|
|
find_library(BSON_LIBRARY_PATH NAMES bson-1.0 PATHS "${MONGO_C_CUSTOM_INSTALL_PATH}/lib" NO_DEFAULT_PATH)
|
|
|
|
|
|
|
|
if (MONGOC_INCLUDES_FOLDER AND MONGOC_LIBRARY_PATH AND BSON_INCLUDES_FOLDER AND BSON_LIBRARY_PATH)
|
|
|
|
message(STATUS "We found mongo-c library ${MONGOC_INCLUDES_FOLDER} ${MONGOC_LIBRARY_PATH} ${BSON_INCLUDES_FOLDER} ${BSON_LIBRARY_PATH}")
|
|
|
|
add_definitions(-DMONGO)
|
|
|
|
|
|
|
|
# We add suffix name because cmake could not detect it correctly...
|
|
|
|
include_directories("${MONGOC_INCLUDES_FOLDER}/libmongoc-1.0")
|
|
|
|
include_directories("${BSON_INCLUDES_FOLDER}/libbson-1.0")
|
|
|
|
|
|
|
|
target_link_libraries(fastnetmon ${MONGOC_LIBRARY_PATH} ${BSON_LIBRARY_PATH})
|
|
|
|
else()
|
|
|
|
message(WARNING "We can't find Mongo C library")
|
|
|
|
endif()
|
|
|
|
|
2015-08-17 18:36:35 +02:00
|
|
|
### Look for libpcap
|
|
|
|
|
2015-08-30 19:44:46 +02:00
|
|
|
#find_path(LIBPCAP_INCLUDES_FOLDER NAMES pcap.h PATHS "${LIBPCAP_CUSTOM_INSTALL_PATH}/include" NO_DEFAULT_PATH)
|
2015-08-30 19:34:13 +02:00
|
|
|
|
2015-08-30 19:44:46 +02:00
|
|
|
#find_library(LIBPCAP_LIBRARY_PATH NAMES pcap PATHS "${LIBPCAP_CUSTOM_INSTALL_PATH}/lib" NO_DEFAULT_PATH)
|
2015-08-30 19:34:13 +02:00
|
|
|
|
2015-08-30 19:44:46 +02:00
|
|
|
#if (LIBPCAP_INCLUDES_FOLDER AND LIBPCAP_LIBRARY_PATH)
|
|
|
|
# message(STATUS "We found pcap library ${LIBPCAP_LIBRARY_PATH}")
|
2015-08-30 19:34:13 +02:00
|
|
|
|
2015-08-30 19:44:46 +02:00
|
|
|
# include_directories(${LIBPCAP_INCLUDES_FOLDER})
|
|
|
|
#else()
|
|
|
|
# message(FATAL_ERROR "We can't find pcap library")
|
|
|
|
#endif()
|
2015-08-17 18:36:35 +02:00
|
|
|
|
2015-08-12 19:27:29 +02:00
|
|
|
### Look for log4cpp
|
|
|
|
|
2015-08-11 10:24:08 +02:00
|
|
|
# Try to find log4cpp includes path
|
|
|
|
find_path(LOG4CPP_INCLUDES_FOLDER NAMES log4cpp/Appender.hh PATHS "${LOG4CPP_CUSTOM_INSTALL_PATH}/include" NO_DEFAULT_PATH)
|
2015-02-10 11:42:48 +01:00
|
|
|
|
2015-08-11 10:24:08 +02:00
|
|
|
# Try to find log4cpp library path
|
|
|
|
find_library(LOG4CPP_LIBRARY_PATH NAMES log4cpp PATHS "${LOG4CPP_CUSTOM_INSTALL_PATH}/lib" NO_DEFAULT_PATH)
|
2015-01-29 11:27:55 +01:00
|
|
|
|
2015-08-11 10:24:08 +02:00
|
|
|
if (LOG4CPP_INCLUDES_FOLDER AND LOG4CPP_LIBRARY_PATH)
|
|
|
|
include_directories(${LOG4CPP_INCLUDES_FOLDER})
|
|
|
|
message(STATUS "We have found log4cpp and will build project")
|
|
|
|
else()
|
2015-08-17 18:36:35 +02:00
|
|
|
message(FATAL_ERROR "We can't find log4cpp. We can't build project")
|
2015-02-10 14:07:53 +01:00
|
|
|
endif()
|
|
|
|
|
2015-08-12 19:27:29 +02:00
|
|
|
### Look for jsonc
|
|
|
|
|
|
|
|
find_path(JSONC_INCLUDES_FOLDER NAMES json-c/json.h PATHS "${JSONC_CUSTOM_INSTALL_PATH}/include" NO_DEFAULT_PATH)
|
|
|
|
find_library(JSONC_LIBRARY_PATH NAMES json-c PATHS "${JSONC_CUSTOM_INSTALL_PATH}/lib" NO_DEFAULT_PATH)
|
|
|
|
|
|
|
|
if (JSONC_INCLUDES_FOLDER AND JSONC_LIBRARY_PATH)
|
|
|
|
include_directories(${JSONC_INCLUDES_FOLDER})
|
|
|
|
message(STATUS "We have found json-c library correctly: ${JSONC_LIBRARY_PATH}")
|
|
|
|
else()
|
2015-08-17 18:36:35 +02:00
|
|
|
message(FATAL_ERROR "We can't find json-c library! Can't build project")
|
2015-08-12 19:27:29 +02:00
|
|
|
endif()
|
|
|
|
|
2015-08-13 15:59:06 +02:00
|
|
|
target_link_libraries(fast_library ${JSONC_LIBRARY_PATH})
|
|
|
|
|
2015-07-29 15:49:34 +02:00
|
|
|
if (ENABLE_DPI_SUPPORT)
|
|
|
|
target_link_libraries(fastnetmon fast_dpi)
|
|
|
|
endif()
|
|
|
|
|
2015-02-10 11:42:48 +01:00
|
|
|
target_link_libraries(fastnetmon ${LOG4CPP_LIBRARY_PATH})
|
|
|
|
|
2015-06-02 22:27:49 +02:00
|
|
|
target_link_libraries(fastnetmon ${CMAKE_THREAD_LIBS_INIT})
|
2014-11-28 15:22:27 +01:00
|
|
|
|
2015-07-03 17:01:18 +02:00
|
|
|
if (ENABLE_LUA_SUPPORT)
|
|
|
|
target_link_libraries(fast_library luajit-5.1)
|
|
|
|
target_link_libraries(fastnetmon luajit-5.1)
|
|
|
|
endif()
|
|
|
|
|
2014-11-28 15:58:12 +01:00
|
|
|
# Our libs
|
2014-12-16 09:01:07 +01:00
|
|
|
target_link_libraries(fastnetmon patricia)
|
2015-07-22 14:16:13 +02:00
|
|
|
target_link_libraries(fastnetmon fastnetmon_pcap_format)
|
2014-11-28 15:22:27 +01:00
|
|
|
|
2015-03-22 17:00:16 +01:00
|
|
|
target_link_libraries(fastnetmon ipfix_rfc)
|
|
|
|
|
2015-03-21 11:47:25 +01:00
|
|
|
# Link to our functions
|
|
|
|
target_link_libraries(fastnetmon fast_library)
|
|
|
|
|
2015-02-03 20:55:44 +01:00
|
|
|
if (ENABLE_PFRING_SUPPORT)
|
2015-08-31 14:15:16 +02:00
|
|
|
target_link_libraries(fastnetmon pfring_plugin)
|
2015-09-03 13:09:16 +02:00
|
|
|
# Link hardware filter too
|
|
|
|
target_link_libraries(fastnetmon pfring_hardware_filter_action)
|
2015-08-31 14:15:16 +02:00
|
|
|
endif()
|
|
|
|
|
2015-10-03 21:17:58 +02:00
|
|
|
if (ENABLE_GOBGP_SUPPORT)
|
|
|
|
target_link_libraries(fastnetmon gobgp_action)
|
|
|
|
endif()
|
|
|
|
|
2015-08-31 14:15:16 +02:00
|
|
|
if (ENABLE_SNABBSWITCH_SUPPORT)
|
|
|
|
target_link_libraries(fastnetmon snabbswitch_plugin)
|
2015-02-03 20:55:44 +01:00
|
|
|
endif()
|
|
|
|
|
2015-09-01 10:41:55 +02:00
|
|
|
if (ENABLE_AFPACKET_SUPPORT)
|
|
|
|
target_link_libraries(fastnetmon afpacket_plugin)
|
|
|
|
endif()
|
|
|
|
|
2015-05-29 13:42:01 +02:00
|
|
|
target_link_libraries(fastnetmon sflow_plugin netflow_plugin pcap_plugin example_plugin netmap_plugin)
|
|
|
|
|
|
|
|
# cmake .. -DBUILD_PLUGIN_RUNNER=ON
|
|
|
|
if (BUILD_PLUGIN_RUNNER)
|
|
|
|
add_executable(fastnetmon_plugin_runner plugin_runner.cpp)
|
|
|
|
|
2015-08-31 12:25:57 +02:00
|
|
|
if (ENABLE_SNABBSWITCH_SUPPORT)
|
|
|
|
target_link_libraries(fastnetmon_plugin_runner snabbswitch_plugin)
|
|
|
|
endif()
|
|
|
|
|
2015-09-01 10:41:55 +02:00
|
|
|
if (ENABLE_AFPACKET_SUPPORT)
|
|
|
|
target_link_libraries(fastnetmon_plugin_runner afpacket_plugin)
|
|
|
|
endif()
|
|
|
|
|
2015-06-16 17:00:10 +02:00
|
|
|
target_link_libraries(fastnetmon_plugin_runner ${CMAKE_THREAD_LIBS_INIT})
|
2015-05-29 13:42:01 +02:00
|
|
|
target_link_libraries(fastnetmon_plugin_runner patricia)
|
2015-07-22 14:16:13 +02:00
|
|
|
target_link_libraries(fastnetmon_plugin_runner fastnetmon_pcap_format)
|
2015-05-29 13:42:01 +02:00
|
|
|
target_link_libraries(fastnetmon_plugin_runner ${LOG4CPP_LIBRARY_PATH})
|
|
|
|
target_link_libraries(fastnetmon_plugin_runner fast_library)
|
|
|
|
|
|
|
|
# Add all plugins
|
|
|
|
target_link_libraries(fastnetmon_plugin_runner sflow_plugin netflow_plugin pcap_plugin example_plugin netmap_plugin)
|
|
|
|
|
|
|
|
if (ENABLE_PFRING_SUPPORT)
|
|
|
|
target_link_libraries(fastnetmon_plugin_runner ${PFRING_LIBRARIES})
|
|
|
|
target_link_libraries(fastnetmon_plugin_runner pfring_plugin)
|
|
|
|
endif()
|
|
|
|
endif()
|
2015-03-23 17:39:44 +01:00
|
|
|
|
2015-05-29 14:08:12 +02:00
|
|
|
# cmake .. -DBUILD_PCAP_READER=ON
|
|
|
|
if (BUILD_PCAP_READER)
|
|
|
|
add_executable(fastnetmon_pcap_reader pcap_reader.cpp)
|
|
|
|
|
2015-05-29 14:45:02 +02:00
|
|
|
target_link_libraries(fastnetmon_pcap_reader fastnetmon_packet_parser)
|
2015-05-29 14:08:12 +02:00
|
|
|
target_link_libraries(fastnetmon_pcap_reader patricia)
|
2015-07-22 14:16:13 +02:00
|
|
|
target_link_libraries(fastnetmon_pcap_reader fastnetmon_pcap_format)
|
|
|
|
|
2015-05-29 14:08:12 +02:00
|
|
|
target_link_libraries(fastnetmon_pcap_reader fast_library)
|
|
|
|
target_link_libraries(fastnetmon_pcap_reader ${LOG4CPP_LIBRARY_PATH})
|
2015-06-17 12:35:42 +02:00
|
|
|
target_link_libraries(fastnetmon_pcap_reader netflow_plugin)
|
|
|
|
target_link_libraries(fastnetmon_pcap_reader sflow_plugin)
|
2015-09-10 14:52:26 +02:00
|
|
|
target_link_libraries(fastnetmon_pcap_reader netmap_plugin)
|
2015-07-24 14:45:15 +02:00
|
|
|
|
|
|
|
if (ENABLE_DPI_SUPPORT)
|
|
|
|
target_link_libraries(fastnetmon_pcap_reader fast_dpi)
|
|
|
|
endif()
|
2015-05-29 14:08:12 +02:00
|
|
|
endif()
|
2015-03-23 17:39:44 +01:00
|
|
|
|
2015-07-12 17:34:00 +02:00
|
|
|
# cmake -DBUILD_TESTS=ON ..
|
|
|
|
if (BUILD_TESTS)
|
|
|
|
add_executable(fastnetmon_tests fastnetmon_tests.cpp)
|
|
|
|
target_link_libraries(fastnetmon_tests fast_library)
|
|
|
|
target_link_libraries(fastnetmon_tests ${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
target_link_libraries(fastnetmon_tests ${Boost_LIBRARIES})
|
2015-07-13 10:05:26 +02:00
|
|
|
target_link_libraries(fastnetmon_tests ${LOG4CPP_LIBRARY_PATH})
|
|
|
|
|
|
|
|
set(GOOGLE_TEST_INCLUDE_DIRS /opt/gtest/include)
|
|
|
|
set(GOOGLE_TEST_LIBRARIES /opt/gtest/lib/libgtest.a /opt/gtest/lib/libgtest_main.a)
|
2015-07-12 17:34:00 +02:00
|
|
|
|
|
|
|
# Compiled Google Library
|
2015-07-13 10:05:26 +02:00
|
|
|
include_directories(${GOOGLE_TEST_INCLUDE_DIRS})
|
|
|
|
target_link_libraries(fastnetmon_tests ${GOOGLE_TEST_LIBRARIES})
|
2015-07-12 17:34:00 +02:00
|
|
|
endif()
|
|
|
|
|
2015-06-04 17:13:43 +02:00
|
|
|
if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "DragonFly")
|
|
|
|
install(TARGETS fastnetmon DESTINATION bin)
|
|
|
|
install(TARGETS fastnetmon_client DESTINATION bin)
|
|
|
|
|
|
|
|
install(FILES fastnetmon.conf DESTINATION etc)
|
2015-05-30 20:45:28 +02:00
|
|
|
|
2015-06-04 17:13:43 +02:00
|
|
|
# Install blank files for networks list and whitelist
|
|
|
|
install(FILES networks_list DESTINATION etc)
|
|
|
|
install(FILES networks_whitelist DESTINATION etc)
|
|
|
|
else()
|
|
|
|
# Linux
|
|
|
|
install(TARGETS fastnetmon DESTINATION /usr/sbin)
|
|
|
|
install(TARGETS fastnetmon_client DESTINATION /usr/bin)
|
2015-06-02 22:26:04 +02:00
|
|
|
|
2015-06-04 17:13:43 +02:00
|
|
|
install(FILES fastnetmon.conf DESTINATION /etc)
|
|
|
|
|
|
|
|
# Install blank files for networks list and whitelist
|
|
|
|
install(FILES networks_list DESTINATION /etc)
|
|
|
|
install(FILES networks_whitelist DESTINATION /etc)
|
|
|
|
endif()
|
2015-06-04 10:15:32 +02:00
|
|
|
|
2015-06-04 15:13:22 +02:00
|
|
|
# man pages
|
2015-06-04 22:54:29 +02:00
|
|
|
install(FILES man/fastnetmon.1 DESTINATION /usr/share/man/man1)
|
|
|
|
install(FILES man/fastnetmon_client.1 DESTINATION /usr/share/man/man1)
|
2015-06-04 15:13:22 +02:00
|
|
|
|
2015-05-30 20:45:28 +02:00
|
|
|
# Configure cpack package builder
|
|
|
|
# Run it with: cd build; cpack -G DEB ..
|
|
|
|
set(CPACK_PACKAGE_NAME "fastnetmon")
|
|
|
|
set(CPACK_PACKAGE_VENDOR "vps2fast.com")
|
|
|
|
set(CPACK_PACKAGE_CONTACT "pavel.odintsov@gmail.com")
|
|
|
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "FastNetMon - very fast DDoS analyzer with sflow/netflow/mirror support")
|
|
|
|
set(CPACK_PACKAGE_VERSION "1.1.2")
|
|
|
|
set(CPACK_PACKAGE_VERSION_MAJOR "1")
|
|
|
|
set(CPACK_PACKAGE_VERSION_MINOR "1")
|
|
|
|
set(CPACK_PACKAGE_VERSION_PATCH "2")
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_DEPENDS "")
|
|
|
|
# set(CPACK_PACKAGE_INSTALL_DIRECTORY "CPack Component Example")
|
|
|
|
|
|
|
|
# Specify config for deb package
|
|
|
|
# http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#DEB_.28UNIX_only.29
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libboost-thread-dev, libboost-system-dev, libboost-regex-dev, libpcap-dev, libnuma-dev, liblog4cpp5-dev")
|
|
|
|
|
|
|
|
# This must always be last!
|
|
|
|
include(CPack)
|