-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathCMakeLists.txt
103 lines (87 loc) · 3.11 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
cmake_minimum_required(VERSION 2.8.8)
project(ipfixcol2-unirec-output)
# Description of the project
set(UNIREC_DESCRIPTION
"Output plugin for IPFIXcol2 that sends flow records in UniRec format into NEMEA modules."
)
set(UNIREC_VERSION_MAJOR 2)
set(UNIREC_VERSION_MINOR 4)
set(UNIREC_VERSION_PATCH 0)
set(UNIREC_VERSION
${UNIREC_VERSION_MAJOR}.${UNIREC_VERSION_MINOR}.${UNIREC_VERSION_PATCH})
include(CMakeModules/install_dirs.cmake)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
# Include custom FindXXX modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules")
# Find IPFIXcol and libnf
find_package(IPFIXcol2 2.1.0 REQUIRED) # support for basicList is required
find_package(LibTrap 1.13.1 REQUIRED)
find_package(LibUnirec 2.8.0 REQUIRED)
# Set default build type if not specified by user
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Release
CACHE STRING "Choose type of build (Release/Debug)." FORCE)
endif()
option(ENABLE_DOC_MANPAGE "Enable manual page building" ON)
# Hard coded definitions
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -std=gnu11")
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
set(CMAKE_C_FLAGS_DEBUG "-g -O0 -Wall -Wextra -pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -std=gnu++11")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wextra -pedantic")
# Prepare SPEC file
configure_file(
"${PROJECT_SOURCE_DIR}/ipfixcol2-unirec-output.spec.in"
"${PROJECT_BINARY_DIR}/ipfixcol2-unirec-output.spec"
)
# Header files for source code building
include_directories(
"${IPFIXCOL2_INCLUDE_DIRS}" # IPFIXcol2 header files
"${LIBTRAP_INCLUDE_DIRS}" # libtrap header files
"${LIBUNIREC_INCLUDE_DIRS}" # unirec header files
)
# Create a linkable module
add_library(unirec-output MODULE
src/configuration.c
src/configuration.h
src/unirecplugin.c
src/translator.c
src/translator.h
src/fields.c
src/fields.h
src/map.c
src/map.h
)
target_link_libraries(unirec-output
${LIBTRAP_LIBRARIES} # libtrap
${LIBUNIREC_LIBRARIES} # unirec
m # standard math library
)
install(
TARGETS unirec-output
LIBRARY DESTINATION "${INSTALL_DIR_LIB}/ipfixcol2/"
)
install(
FILES config/unirec-elements.txt
DESTINATION "${INSTALL_DIR_SYSCONF}/ipfixcol2/"
)
if (ENABLE_DOC_MANPAGE)
find_package(Rst2Man)
if (NOT RST2MAN_FOUND)
message(FATAL_ERROR "rst2man is not available. Install python-docutils or disable manual page generation (-DENABLE_DOC_MANPAGE=False)")
endif()
# Build a manual page
set(SRC_FILE "${CMAKE_CURRENT_SOURCE_DIR}/doc/ipfixcol2-unirec-output.7.rst")
set(DST_FILE "${CMAKE_CURRENT_BINARY_DIR}/ipfixcol2-unirec-output.7")
add_custom_command(TARGET unirec-output PRE_BUILD
COMMAND ${RST2MAN_EXECUTABLE} --syntax-highlight=none ${SRC_FILE} ${DST_FILE}
DEPENDS ${SRC_FILE}
VERBATIM
)
install(
FILES "${DST_FILE}"
DESTINATION "${INSTALL_DIR_MAN}/man7"
)
endif()