• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2#  Copyright (c) 2020, The OpenThread Authors.
3#  All rights reserved.
4#
5#  Redistribution and use in source and binary forms, with or without
6#  modification, are permitted provided that the following conditions are met:
7#  1. Redistributions of source code must retain the above copyright
8#     notice, this list of conditions and the following disclaimer.
9#  2. Redistributions in binary form must reproduce the above copyright
10#     notice, this list of conditions and the following disclaimer in the
11#     documentation and/or other materials provided with the distribution.
12#  3. Neither the name of the copyright holder nor the
13#     names of its contributors may be used to endorse or promote products
14#     derived from this software without specific prior written permission.
15#
16#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26#  POSSIBILITY OF SUCH DAMAGE.
27#
28
29cmake_minimum_required(VERSION 3.10.2)
30project(openthread-br VERSION 0.3.0)
31
32add_compile_options(-Wall -Wextra -Werror -Wfatal-errors -Wuninitialized -Wno-missing-braces)
33
34add_library(otbr-config INTERFACE)
35
36set(OTBR_INFRA_IF_NAME "wlan0" CACHE STRING "The infrastructure interface name")
37set(OTBR_VENDOR_NAME "OpenThread" CACHE STRING "The vendor name")
38set(OTBR_PRODUCT_NAME "BorderRouter" CACHE STRING "The product name")
39set(OTBR_NAME "${OTBR_VENDOR_NAME}_${OTBR_PRODUCT_NAME}" CACHE STRING "The package name")
40set(OTBR_MESHCOP_SERVICE_INSTANCE_NAME "${OTBR_VENDOR_NAME} ${OTBR_PRODUCT_NAME}" CACHE STRING "The OTBR MeshCoP service instance name")
41set(OTBR_MDNS "avahi" CACHE STRING "mDNS publisher provider")
42set(OTBR_SYSLOG_FACILITY_ID LOG_USER CACHE STRING "Syslog logging facility")
43
44set_property(CACHE OTBR_MDNS PROPERTY STRINGS "avahi" "mDNSResponder")
45
46include("${PROJECT_SOURCE_DIR}/etc/cmake/options.cmake")
47
48if(NOT CMAKE_C_STANDARD)
49    set(CMAKE_C_STANDARD 99)
50    set(CMAKE_C_STANDARD_REQUIRED ON)
51endif()
52
53if(NOT CMAKE_CXX_STANDARD)
54    set(CMAKE_CXX_STANDARD 11)
55    set(CMAKE_CXX_STANDARD_REQUIRED ON)
56endif()
57
58set(CMAKE_CXX_EXTENSIONS OFF)
59
60if (OTBR_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
61    message(STATUS "Coverage: ON")
62    target_compile_options(otbr-config INTERFACE -g -O0 --coverage)
63    target_link_libraries(otbr-config INTERFACE --coverage)
64endif()
65
66message(STATUS "OTBR package name: ${OTBR_NAME}")
67
68if(NOT OTBR_VERSION)
69    execute_process(
70        COMMAND git describe --dirty --always
71        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
72        OUTPUT_VARIABLE OTBR_GIT_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE
73    )
74
75    if(OTBR_GIT_VERSION)
76        set(OTBR_VERSION "${PROJECT_VERSION}-${OTBR_GIT_VERSION}")
77    else()
78        set(OTBR_VERSION "${PROJECT_VERSION}")
79    endif()
80endif()
81
82message(STATUS "Version: ${OTBR_VERSION}")
83
84target_include_directories(otbr-config INTERFACE
85    ${PROJECT_SOURCE_DIR}/include
86    ${PROJECT_SOURCE_DIR}/src
87)
88target_compile_definitions(otbr-config INTERFACE
89    "OTBR_VENDOR_NAME=\"${OTBR_VENDOR_NAME}\""
90    "OTBR_PRODUCT_NAME=\"${OTBR_PRODUCT_NAME}\""
91    "OTBR_PACKAGE_NAME=\"${OTBR_NAME}\""
92    "OTBR_PACKAGE_VERSION=\"${OTBR_VERSION}\""
93    "OTBR_MESHCOP_SERVICE_INSTANCE_NAME=\"${OTBR_MESHCOP_SERVICE_INSTANCE_NAME}\""
94    "OTBR_SYSLOG_FACILITY_ID=${OTBR_SYSLOG_FACILITY_ID}"
95)
96
97if(BUILD_SHARED_LIBS)
98    target_link_libraries(otbr-config INTERFACE -Wl,--unresolved-symbols=ignore-in-shared-libs)
99endif()
100
101include(GNUInstallDirs)
102
103pkg_check_modules(SYSTEMD systemd)
104
105if(SYSTEMD_FOUND)
106    pkg_get_variable(OTBR_SYSTEMD_UNIT_DIR systemd systemdsystemunitdir)
107endif()
108
109
110add_subdirectory(third_party EXCLUDE_FROM_ALL)
111add_subdirectory(src)
112add_subdirectory(tools)
113
114
115if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
116    include(CTest)
117
118    if(BUILD_TESTING)
119        pkg_check_modules(CPPUTEST cpputest REQUIRED)
120        add_subdirectory(tests)
121    endif()
122
123    set(CPACK_GENERATOR "DEB")
124    set(CPACK_DEBIAN_PACKAGE_MAINTAINER "OpenThread Authors (https://github.com/openthread/openthread)")
125    set(CPACK_PACKAGE_CONTACT "OpenThread Authors (https://github.com/openthread/openthread)")
126    include(CPack)
127endif()
128
129if (OTBR_DOC)
130    add_subdirectory(doc)
131endif()
132