1
0
Fork 0
mirror of https://github.com/pavel-odintsov/fastnetmon synced 2024-06-09 05:16:17 +02:00
fastnetmon-rewritten/CMakeLists.txt

129 lines
3.6 KiB
CMake
Raw Normal View History

cmake_minimum_required (VERSION 2.8)
2014-11-28 15:58:12 +01:00
# cmake versions:
# Debian 6 - 2.8.2
# Debian 7 - 2.8.9
# CentOS 6 - 2.8.12
project(FastNetMon)
set (Tutorial_VERSION_MAJOR 1)
2014-11-28 15:58:12 +01:00
set (Tutorial_VERSION_MINOR 1)
# It's pretty safe and provide big speedup for our packet processor and patricia code
set(CMAKE_C_FLAGS "-O2")
set(CMAKE_CXX_FLAGS "-O2")
set(FASTNETMON_PROFILER OFF)
set(FASTNETMON_PROFILE_FLAGS "-g -pg")
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()
# 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")
message("You are running Linux and we can build PF_RING support")
set (ENABLE_PFRING_SUPPORT ON)
else()
message("You are running not an Linux and we can't build PF_RING support")
endif()
endif()
2014-11-28 15:58:12 +01:00
if (ENABLE_PFRING_SUPPORT)
# Set path to home compiled PF_RING
set(PFRING_INCLUDE_DIRS /opt/pf_ring/include)
set(PFRING_LIBRARIES /opt/pf_ring/lib/libpfring.so)
add_definitions(-DPF_RING)
include_directories(${PFRING_INCLUDE_DIRS})
endif()
if (WE_USE_CUSTOM_LOG4CPP)
set(LOG4CPP_INCLUDE_DIRS /opt/log4cpp1.1.1/include)
set(LOG4CPPLIBRARIES /opt/log4cpp1.1.1/lib/liblog4cpp.so)
endif()
# If you need hardware locking features
# add_definitions(-DHWFILTER_LOCKING)
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)
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)
2015-01-26 10:10:35 +01:00
# netflow plugin
add_library(netflow_plugin STATIC netflow_plugin/netflow_collector.cpp)
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
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)
target_link_libraries(pfring_plugin pthread)
endif()
2015-01-26 10:10:35 +01:00
# example plugin
add_library(example_plugin STATIC example_plugin/example_collector.cpp)
2014-11-28 15:58:12 +01:00
# Main tool
add_executable(fastnetmon fastnetmon.cpp)
# Client tool
add_executable(fastnetmon_client fastnetmon_client.cpp)
# Find boost: http://www.cmake.org/cmake/help/v3.0/module/FindBoost.html
2014-12-01 09:09:37 +01:00
# Disable cmake script from Boost package becaus it is broken: http://public.kitware.com/Bug/view.php?id=15270
set(Boost_NO_BOOST_CMAKE ON)
# 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-02-01 13:54:05 +01:00
find_package(Boost COMPONENTS thread regex system REQUIRED)
2014-11-28 15:58:12 +01:00
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(fastnetmon ${Boost_LIBRARIES})
endif()
2014-11-28 15:58:12 +01:00
# Try to find ncurses library
find_package(Curses REQUIRED)
if(CURSES_FOUND)
include_directories(${CURSES_INCLUDE_DIRS})
target_link_libraries(fastnetmon_client ${CURSES_LIBRARIES})
2014-11-28 15:58:12 +01:00
endif()
# External libs
if (WE_USE_CUSTOM_LOG4CPP)
include_directories(${LOG4CPP_INCLUDE_DIRS})
target_link_libraries(fastnetmon ${LOG4CPPLIBRARIES})
else()
target_link_libraries(fastnetmon log4cpp)
endif()
target_link_libraries(fastnetmon pthread)
2014-11-28 15:58:12 +01:00
# Our libs
2014-12-16 09:01:07 +01:00
target_link_libraries(fastnetmon patricia)
2014-12-01 22:08:38 +01:00
# Our plugins
target_link_libraries(fastnetmon sflow_plugin)
if (ENABLE_PFRING_SUPPORT)
target_link_libraries(fastnetmon pfring_plugin)
endif()
target_link_libraries(fastnetmon netflow_plugin)
2015-01-26 14:37:12 +01:00
target_link_libraries(fastnetmon pcap_plugin)
2015-01-26 10:10:35 +01:00
target_link_libraries(fastnetmon example_plugin)
2014-12-01 22:08:38 +01:00