forked from BroadbandForum/obuspa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
64 lines (53 loc) · 2.15 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
cmake_minimum_required(VERSION 3.18...3.24)
# Read the AGENT_SOFTWARE_VERSION from version.h file
set(VERSION_REGEX "^#define AGENT_SOFTWARE_VERSION[ ]+\"([0-9.]+)\"$")
file(STRINGS "src/core/version.h" VERSION_STRING REGEX ${VERSION_REGEX})
string(REGEX REPLACE ${VERSION_REGEX} "\\1" VERSION_STRING "${VERSION_STRING}")
project(obuspa
DESCRIPTION "OB-USP Agent"
VERSION ${VERSION_STRING}
HOMEPAGE_URL "https://github.com/BroadbandForum/obuspa/"
LANGUAGES C)
include(GNUInstallDirs)
set(OBUSPA_LOCAL_STATE_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LOCALSTATEDIR}/obuspa)
message(STATUS "OBUSPA_LOCAL_STATE_DIR: ${OBUSPA_LOCAL_STATE_DIR}")
option(ENABLE_STOMP "enable STOMP Message support" ON)
option(ENABLE_MQTT "enable MQTT Message support" ON)
option(ENABLE_COAP "enable CoAP Message support" ON)
option(ENABLE_WEBSOCKETS "enable WebSockets Message support" ON)
message(STATUS "MTP to support: STOMP:${ENABLE_STOMP} MQTT:${ENABLE_MQTT} COAP:${ENABLE_COAP} WEBSOCKETS:${ENABLE_WEBSOCKETS}")
add_executable(obuspa
src/core/main.c)
target_include_directories(obuspa
PRIVATE
src
src/include
src/protobuf-c
src/core
src/n4
src/vendor)
# These definitions are needed because core/main.c requires these definitions.
target_compile_definitions(obuspa
PRIVATE
OBUSPA_LOCAL_STATE_DIR="${OBUSPA_LOCAL_STATE_DIR}"
$<IF:$<BOOL:${ENABLE_STOMP}>,ENABLE_STOMP,DISABLE_STOMP> # DISABLE_STOMP is the define used in core
$<$<BOOL:${ENABLE_MQTT}>:ENABLE_MQTT>
$<$<BOOL:${ENABLE_COAP}>:ENABLE_COAP>
$<$<BOOL:${ENABLE_WEBSOCKETS}>:ENABLE_WEBSOCKETS>
_GNU_SOURCE=1)
target_link_libraries(obuspa
PRIVATE
core
vendor
n4)
add_subdirectory(src/libjson)
add_subdirectory(src/protobuf-c)
add_subdirectory(src/vendor)
add_subdirectory(src/n4)
add_subdirectory(src/core)
# Install executable and create working directory.
# This depends on your prefix setting (default CMAKE_INSTALL_PREFIX=/usr/local/)
# - Default executable path: /usr/local/bin/obuspa
# - Default database path: /usr/local/var/obuspa/usp.db
install(TARGETS obuspa RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY DESTINATION ${OBUSPA_LOCAL_STATE_DIR})