1#
2#  Copyright (c) 2024, 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
29set(COMMON_INCLUDES
30    ${PROJECT_SOURCE_DIR}/include
31    ${PROJECT_SOURCE_DIR}/src
32    ${PROJECT_SOURCE_DIR}/src/core
33    ${PROJECT_SOURCE_DIR}/tests/nexus/platform
34)
35
36set(COMMON_COMPILE_OPTIONS
37    -DOPENTHREAD_FTD=1
38    -DOPENTHREAD_MTD=0
39    -DOPENTHREAD_RADIO=0
40)
41
42add_library(ot-nexus-platform
43    platform/nexus_alarm.cpp
44    platform/nexus_core.cpp
45    platform/nexus_misc.cpp
46    platform/nexus_node.cpp
47    platform/nexus_radio.cpp
48    platform/nexus_settings.cpp
49)
50
51target_include_directories(ot-nexus-platform
52    PRIVATE
53        ${COMMON_INCLUDES}
54)
55
56target_compile_options(ot-nexus-platform
57    PRIVATE
58        ${COMMON_COMPILE_OPTIONS}
59)
60
61target_link_libraries(ot-nexus-platform
62    PRIVATE
63        ot-config
64        ${OT_MBEDTLS}
65)
66
67set(COMMON_LIBS
68    ot-nexus-platform
69    openthread-ftd
70    ot-nexus-platform
71    ${OT_MBEDTLS}
72    ot-config
73    openthread-ftd
74)
75
76#----------------------------------------------------------------------------------------------------------------------
77
78macro(ot_nexus_test name)
79
80    # Macro to add an OpenThread nexus test.
81    #
82    #   Nexus test name will be `nexus_{name}`. Test source file of
83    #   `test_{name}.cpp` is used. Optional extra arguments can be
84    #   passed to provide additional source files.
85
86    add_executable(nexus_${name}
87        test_${name}.cpp ${ARGN}
88    )
89
90    target_include_directories(nexus_${name}
91    PRIVATE
92        ${COMMON_INCLUDES}
93    )
94
95    target_link_libraries(nexus_${name}
96    PRIVATE
97        ${COMMON_LIBS}
98    )
99
100    target_compile_options(nexus_${name}
101    PRIVATE
102        ${COMMON_COMPILE_OPTIONS}
103    )
104
105    add_test(NAME nexus_${name} COMMAND nexus_${name})
106endmacro()
107
108
109#----------------------------------------------------------------------------------------------------------------------
110
111ot_nexus_test(border_agent)
112ot_nexus_test(dtls)
113ot_nexus_test(form_join)
114ot_nexus_test(large_network)
115