forked from openthread/ot-br-posix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
173 lines (139 loc) · 5.61 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
#
# Copyright (c) 2020, The OpenThread Authors.
# All rights reserved.
#
# 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.
#
cmake_minimum_required(VERSION 3.10.2)
project(openthread-br VERSION 0.2.0)
add_library(otbr-config INTERFACE)
option(OTBR_BACKBONE_ROUTER "Build Backbone Router" OFF)
option(OTBR_DBUS "Build DBus support" OFF)
option(OTBR_OPENWRT "Build OpenWrt support" OFF)
option(OTBR_UNSECURE_JOIN "Enable unsecure joining" OFF)
option(OTBR_WEB "Build Web GUI" OFF)
option(OTBR_REST "Build Rest Server" OFF)
option(OTBR_DOC "Build documentation" OFF)
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
endif()
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
set(CMAKE_CXX_EXTENSIONS OFF)
if (OTBR_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
message(STATUS "Coverage: ON")
target_compile_options(otbr-config INTERFACE -g -O0 --coverage)
target_link_libraries(otbr-config INTERFACE --coverage)
endif()
add_compile_options(-Wall -Wextra -Werror -Wfatal-errors -Wno-missing-braces)
execute_process(
COMMAND git describe --dirty --always
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE OTBR_GIT_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(OTBR_GIT_VERSION)
set(OTBR_VERSION "${PROJECT_VERSION}-${OTBR_GIT_VERSION}")
else()
set(OTBR_VERSION "${PROJECT_VERSION}")
endif()
message(STATUS "Version: ${OTBR_VERSION}")
target_include_directories(otbr-config INTERFACE
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src
)
target_compile_definitions(otbr-config INTERFACE
"OTBR_PACKAGE_NAME=\"OPENTHREAD_BR\""
"OTBR_PACKAGE_VERSION=\"${OTBR_VERSION}\""
)
if(BUILD_SHARED_LIBS)
target_link_libraries(otbr-config INTERFACE -Wl,--unresolved-symbols=ignore-in-shared-libs)
endif()
find_package(PkgConfig)
include(GNUInstallDirs)
if (OTBR_BACKBONE_ROUTER)
target_compile_definitions(otbr-config INTERFACE
OTBR_ENABLE_BACKBONE_ROUTER=1
)
set(OT_BACKBONE_ROUTER_DUA_NDPROXYING ON CACHE BOOL "Enable Backbone Router DUA ND Proxying in OpenThread" FORCE)
set(OT_THREAD_VERSION 1.2 CACHE STRING "Backbone Router requires Thread 1.2 or higher" FORCE)
set(OT_BACKBONE_ROUTER ON CACHE BOOL "Enable Backbone Router feature in OpenThread" FORCE)
set(OT_SERVICE ON CACHE BOOL "Backbone Router requires Thread network service" FORCE)
endif()
if(OTBR_DBUS)
pkg_check_modules(DBUS REQUIRED dbus-1)
pkg_get_variable(OTBR_DBUS_SYSTEM_BUS_SERVICES_DIR dbus-1 system_bus_services_dir)
target_compile_definitions(otbr-config INTERFACE
OTBR_ENABLE_DBUS_SERVER=1
)
endif()
if(OTBR_REST)
target_compile_definitions(otbr-config INTERFACE
OTBR_ENABLE_REST_SERVER=1
)
endif()
if(OTBR_WEB)
pkg_check_modules(JSONCPP jsoncpp REQUIRED)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost REQUIRED
COMPONENTS filesystem system)
set(OTBR_WEB_DATADIR ${CMAKE_INSTALL_FULL_DATADIR}/otbr-web)
endif()
if(OTBR_OPENWRT)
target_compile_definitions(otbr-config INTERFACE
OTBR_ENABLE_OPENWRT=1
)
endif()
if(OTBR_UNSECURE_JOIN)
target_compile_definitions(otbr-config INTERFACE
OTBR_ENABLE_UNSECURE_JOIN=1
)
endif()
set(OTBR_MDNS "avahi" CACHE STRING "MDNS service provider")
set_property(CACHE OTBR_MDNS PROPERTY STRINGS "avahi" "mDNSResponder")
pkg_check_modules(SYSTEMD systemd)
if(SYSTEMD_FOUND)
pkg_get_variable(OTBR_SYSTEMD_UNIT_DIR systemd systemdsystemunitdir)
endif()
add_subdirectory(third_party EXCLUDE_FROM_ALL)
add_subdirectory(src)
add_subdirectory(tools)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
if(BUILD_TESTING)
pkg_check_modules(CPPUTEST cpputest REQUIRED)
add_subdirectory(tests)
endif()
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "OpenThread Authors <[email protected]")
set(CPACK_PACKAGE_CONTACT "OpenThread Authors <[email protected]")
include(CPack)
endif()
if (OTBR_DOC)
add_subdirectory(doc)
endif()