-
Notifications
You must be signed in to change notification settings - Fork 11
/
CMakeLists.txt
176 lines (146 loc) · 5.97 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
cmake_minimum_required(VERSION 2.6)
project(nodewatcher-agent C)
add_definitions(-Os -Wall -Werror --std=gnu99 -Wmissing-declarations)
option(GENERAL_MODULE "General module support" ON)
option(RESOURCES_MODULE "Resources module support" ON)
option(INTERFACES_MODULE "Interfaces module support" ON)
option(WIRELESS_MODULE "Wireless module support" ON)
option(KEYS_SSH_MODULE "SSH keys module support" ON)
option(PACKAGES_MODULE "Packages module support" ON)
option(CLIENTS_MODULE "Clients module support" ON)
option(HTTP_PUSH_MODULE "HTTP push module support" ON)
option(ROUTING_BABEL_MODULE "Babel routing module support" ON)
option(ROUTING_OLSR_MODULE "OLSR routing module support" ON)
option(MESHPOINT_MODULE "Meshpoint sensors module support" ON)
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
include(FindPkgConfig)
pkg_search_module(JSONC json-c)
if(JSONC_FOUND)
include_directories(${JSONC_INCLUDE_DIRS})
endif()
find_path(ubus_include_dir libubus.h)
include_directories(${ubus_include_dir})
find_path(ubox_include_dir libubox/blobmsg_json.h)
include_directories(${ubox_include_dir})
find_path(uci_include_dir uci.h)
include_directories(${uci_include_dir})
find_library(json_library NAMES json-c json)
find_library(ubus_library NAMES ubus)
find_library(ubox_library NAMES ubox)
find_library(uci_library NAMES uci)
find_library(blobmsg_json_library NAMES blobmsg_json)
set(SOURCES
main.c
)
set(LIBS
${ubox_library}
${ubus_library}
${uci_library}
${json_library}
${blobmsg_json_library}
dl
m
)
include_directories(include)
# Nodewatcher agent common library
set(COMMON_SOURCES
common/module.c
common/scheduler.c
common/json.c
common/utils.c
common/output.c
)
add_library(nodewatcher-agent-common SHARED ${COMMON_SOURCES})
target_link_libraries(nodewatcher-agent-common ${LIBS})
# Nodewatcher agent binary
add_executable(nodewatcher-agent ${SOURCES})
target_link_libraries(nodewatcher-agent ${LIBS} nodewatcher-agent-common)
# Modules
set(MODULES "")
# General module
if(GENERAL_MODULE)
set(MODULES ${MODULES} general_module)
add_library(general_module MODULE modules/general.c)
target_link_libraries(general_module ${ubox_library} ${uci_library} nodewatcher-agent-common)
set_target_properties(general_module PROPERTIES OUTPUT_NAME general PREFIX "")
endif()
# Resources module
if(RESOURCES_MODULE)
set(MODULES ${MODULES} resources_module)
add_library(resources_module MODULE modules/resources.c)
target_link_libraries(resources_module ${ubox_library} ${uci_library} nodewatcher-agent-common)
set_target_properties(resources_module PROPERTIES OUTPUT_NAME resources PREFIX "")
endif()
# Interfaces module
if(INTERFACES_MODULE)
set(MODULES ${MODULES} interfaces_module)
add_library(interfaces_module MODULE modules/interfaces.c)
target_link_libraries(interfaces_module ${ubox_library} ${uci_library} nodewatcher-agent-common)
set_target_properties(interfaces_module PROPERTIES OUTPUT_NAME interfaces PREFIX "")
endif()
# Wireless module
if(WIRELESS_MODULE)
set(MODULES ${MODULES} wireless_module)
add_library(wireless_module MODULE modules/wireless.c)
target_link_libraries(wireless_module ${ubox_library} ${uci_library} iwinfo nodewatcher-agent-common)
set_target_properties(wireless_module PROPERTIES OUTPUT_NAME wireless PREFIX "")
endif()
# SSH keys module
if(KEYS_SSH_MODULE)
set(MODULES ${MODULES} keys_ssh_module)
add_library(keys_ssh_module MODULE modules/keys_ssh.c)
target_link_libraries(keys_ssh_module ${ubox_library} ${uci_library} nodewatcher-agent-common)
set_target_properties(keys_ssh_module PROPERTIES OUTPUT_NAME keys_ssh PREFIX "")
endif()
# Packages module
if(PACKAGES_MODULE)
set(MODULES ${MODULES} packages_module)
add_library(packages_module MODULE modules/packages.c)
target_link_libraries(packages_module ${ubox_library} ${uci_library} nodewatcher-agent-common)
set_target_properties(packages_module PROPERTIES OUTPUT_NAME packages PREFIX "")
endif()
# Clients module
if(CLIENTS_MODULE)
set(MODULES ${MODULES} clients_module)
add_library(clients_module MODULE modules/clients.c)
target_link_libraries(clients_module ${ubox_library} ${uci_library} nodewatcher-agent-common)
set_target_properties(clients_module PROPERTIES OUTPUT_NAME clients PREFIX "")
endif()
# HTTP push module
if(HTTP_PUSH_MODULE)
find_path(curl_include_dir curl.h PATH_SUFFIXES curl)
include_directories(${curl_include_dir})
find_library(curl_library NAMES curl)
set(MODULES ${MODULES} http_push_module)
add_library(http_push_module MODULE modules/http_push.c)
target_link_libraries(http_push_module ${curl_library} ${ubox_library} ${uci_library} nodewatcher-agent-common)
set_target_properties(http_push_module PROPERTIES OUTPUT_NAME http_push PREFIX "")
endif()
# Babel routing module
if(ROUTING_BABEL_MODULE)
set(MODULES ${MODULES} routing_babel_module)
add_library(routing_babel_module MODULE modules/routing_babel.c)
target_link_libraries(routing_babel_module ${ubox_library} ${uci_library} nodewatcher-agent-common)
set_target_properties(routing_babel_module PROPERTIES OUTPUT_NAME routing_babel PREFIX "")
endif()
# OLSR routing module
if(ROUTING_OLSR_MODULE)
set(MODULES ${MODULES} routing_olsr_module)
add_library(routing_olsr_module MODULE modules/routing_olsr.c)
target_link_libraries(routing_olsr_module ${ubox_library} ${uci_library} nodewatcher-agent-common)
set_target_properties(routing_olsr_module PROPERTIES OUTPUT_NAME routing_olsr PREFIX "")
endif()
# Meshpoint sensors module
if(MESHPOINT_MODULE)
set(MODULES ${MODULES} meshpoint_module)
add_library(meshpoint_module MODULE modules/meshpoint.c)
target_link_libraries(meshpoint_module nodewatcher-agent-common)
set_target_properties(meshpoint_module PROPERTIES OUTPUT_NAME meshpoint PREFIX "")
endif()
install(TARGETS nodewatcher-agent nodewatcher-agent-common
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
)
install(TARGETS ${MODULES} LIBRARY DESTINATION lib/nodewatcher-agent)
file(GLOB headers include/nodewatcher-agent/*.h)
install(FILES ${headers} DESTINATION include/nodewatcher-agent)