-
Notifications
You must be signed in to change notification settings - Fork 14
/
CMakeLists.txt
104 lines (92 loc) · 4.66 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
104
# Copyright (c) 2020, Broadband Forum
# Copyright (c) 2020, Axiros GmbH
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
project(OB-UDPST)
cmake_minimum_required(VERSION 3.0)
if(${CMAKE_VERSION} VERSION_GREATER "3.3.0")
cmake_policy(SET CMP0057 NEW)
endif()
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(SOFTWARE_VER "8.2.0")
INCLUDE (CheckIncludeFiles)
INCLUDE (CheckFunctionExists)
INCLUDE (CheckSymbolExists)
INCLUDE (FindPackageHandleStandardArgs)
find_package(PkgConfig)
find_package(OpenSSL)
if(OPENSSL_FOUND)
set(HAVE_OPENSSL TRUE)
link_directories(${OPENSSL_LIBRARY_DIRS})
include_directories(${OPENSSL_INCLUDE_DIR})
add_definitions(-DAUTH_KEY_ENABLE)
set(libraries ${libraries} ${OPENSSL_LIBRARIES})
endif()
include_directories(${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_BINARY_DIR})
include_directories(${CMAKE_BINARY_DIR})
CHECK_INCLUDE_FILES (malloc.h HAVE_MALLOC_H)
CHECK_INCLUDE_FILES (stdlib.h HAVE_STDLIB_H)
CHECK_INCLUDE_FILES (string.h HAVE_STRING_H)
CHECK_INCLUDE_FILES (unistd.h HAVE_UNISTD_H)
CHECK_INCLUDE_FILES (memory.h HAVE_MEMORY_H)
CHECK_INCLUDE_FILES (sys/sysinfo.h HAVE_SYSINFO_H)
CHECK_INCLUDE_FILES (sys/sysctl.h HAVE_SYSCTL_H)
CHECK_INCLUDE_FILES (linux/socket.h HAVE_SIOCGIFHWADDR)
CHECK_SYMBOL_EXISTS (LLADDR "sys/socket.h;net/if_dl.h" HAVE_NET_IF_DL_H)
CHECK_SYMBOL_EXISTS (UDP_SEGMENT "netinet/udp.h" HAVE_GSO)
CHECK_FUNCTION_EXISTS (sendmmsg HAVE_SENDMMSG)
CHECK_FUNCTION_EXISTS (recvmmsg HAVE_RECVMMSG)
CHECK_FUNCTION_EXISTS (timegm HAVE_TIMEGM)
CHECK_FUNCTION_EXISTS (mkfifo HAVE_MKFIFO)
CHECK_FUNCTION_EXISTS (getifaddrs HAVE_GETIFADDRS)
CHECK_FUNCTION_EXISTS (fork HAVE_WORKING_FORK)
OPTION(DISABLE_INT_TIMER "Disable interval timer on systems without required timer resolution (increases CPU util.)" OFF)
OPTION(HAVE_SENDMMSG "Enable/Disable use of SendMMsg()" ON)
OPTION(HAVE_RECVMMSG "Enable/Disable use of RecvMMsg()" ON)
OPTION(HAVE_GSO "Enable/Disable use of Generic Segmentation Offload (GSO)" ON)
OPTION(RATE_LIMITING "Enable/Disable rate limiting via bandwidth management" OFF)
OPTION(AUTH_IS_OPTIONAL "Make authentication optional (considered low security and should be temporary)" OFF)
OPTION(SUPP_INVPDU_ALERT "Suppress alert when invalid control PDU is received (silently ignore)" OFF)
OPTION(SUPP_INVPDU_WARN "Suppress warning when invalid data PDU is received (silently ignore)" OFF)
OPTION(ADD_HEADER_CSUM "Add checksum to PDU headers (needed when the UDP checksum is not being utilized)" OFF)
add_definitions(-DSYSCONFDIR=\"${CMAKE_INSTALL_PREFIX}/etc\")
add_definitions(-DLOCALSTATEDIR=\"${CMAKE_INSTALL_PREFIX}/var/lib\")
add_definitions(-DLOGDIR=\"${CMAKE_INSTALL_PREFIX}/var/log\")
add_definitions(-DRUNDIR=\"${CMAKE_INSTALL_PREFIX}/run\")
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
# Define a library called udpst_core containing all core functionality
add_library(udpst_core udpst_control.c udpst_data.c udpst_srates.c cJSON.c)
set(libraries udpst_core ${libraries})
add_executable(udpst udpst.c)
target_link_libraries(udpst ${libraries} m)
# For some reason Ninja sometimes faces a stupid error which is fixed by
# the following
if (CMAKE_GENERATOR MATCHES "Ninja")
set(CMAKE_PLATFORM_HAS_INSTALLNAME 1)
endif()