• 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
29add_library(openthread-radio-spinel)
30add_library(openthread-spinel-ncp)
31add_library(openthread-spinel-rcp)
32
33target_compile_definitions(openthread-radio-spinel PRIVATE
34    OPENTHREAD_FTD=0
35    OPENTHREAD_MTD=0
36    OPENTHREAD_RADIO=0
37)
38
39target_compile_definitions(openthread-spinel-ncp PRIVATE
40    OPENTHREAD_FTD=0
41    OPENTHREAD_MTD=0
42    OPENTHREAD_RADIO=0
43    PUBLIC OPENTHREAD_SPINEL_CONFIG_OPENTHREAD_MESSAGE_ENABLE=1
44)
45
46target_compile_definitions(openthread-spinel-rcp PRIVATE
47    OPENTHREAD_FTD=0
48    OPENTHREAD_MTD=0
49    OPENTHREAD_RADIO=0
50    PUBLIC OPENTHREAD_SPINEL_CONFIG_OPENTHREAD_MESSAGE_ENABLE=0
51)
52
53target_compile_options(openthread-radio-spinel PRIVATE
54    ${OT_CFLAGS}
55)
56
57target_compile_options(openthread-spinel-ncp PRIVATE
58    ${OT_CFLAGS}
59)
60
61target_compile_options(openthread-spinel-rcp PRIVATE
62    ${OT_CFLAGS}
63)
64
65set(COMMON_INCLUDES
66    ${PROJECT_SOURCE_DIR}/src
67    ${PROJECT_SOURCE_DIR}/src/core
68)
69
70set(COMMON_SOURCES
71    spinel.c
72    spinel_buffer.cpp
73    spinel_decoder.cpp
74    spinel_encoder.cpp
75)
76
77set(OT_SPINEL_VENDOR_HOOK_SOURCE "" CACHE STRING "set vendor hook source file for Spinel")
78set(OT_SPINEL_VENDOR_HOOK_HEADER "" CACHE STRING "set vendor hook header file for Spinel")
79if(OT_SPINEL_VENDOR_HOOK_SOURCE)
80    target_compile_definitions(openthread-spinel-rcp PUBLIC "OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE=1")
81    target_compile_definitions(openthread-spinel-ncp PUBLIC "OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE=1")
82    target_compile_definitions(openthread-spinel-rcp PUBLIC "OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_HEADER=\"${OT_SPINEL_VENDOR_HOOK_HEADER}\"")
83    target_compile_definitions(openthread-spinel-ncp PUBLIC "OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_HEADER=\"${OT_SPINEL_VENDOR_HOOK_HEADER}\"")
84    list(APPEND COMMON_SOURCES ${OT_SPINEL_VENDOR_HOOK_SOURCE_DIR}${OT_SPINEL_VENDOR_HOOK_SOURCE})
85    list(APPEND COMMON_INCLUDES ${OT_SPINEL_VENDOR_HOOK_SOURCE_DIR})
86endif()
87
88target_include_directories(openthread-radio-spinel PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES})
89target_include_directories(openthread-spinel-ncp PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES})
90target_include_directories(openthread-spinel-rcp PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES})
91
92target_sources(openthread-radio-spinel
93    PRIVATE
94        logger.cpp
95        radio_spinel.cpp
96)
97target_sources(openthread-spinel-ncp PRIVATE ${COMMON_SOURCES})
98target_sources(openthread-spinel-rcp PRIVATE ${COMMON_SOURCES})
99
100target_link_libraries(openthread-radio-spinel
101    PRIVATE
102        ot-config
103)
104
105target_link_libraries(openthread-spinel-ncp
106    PRIVATE
107        ot-config-ftd
108        ot-config
109)
110
111target_link_libraries(openthread-spinel-rcp
112    PRIVATE
113        ot-config-radio
114        ot-config
115)
116
117if(BUILD_TESTING)
118    add_executable(ot-test-spinel
119        spinel.c
120    )
121    target_compile_definitions(ot-test-spinel
122        PRIVATE -DSPINEL_SELF_TEST=1 -D_GNU_SOURCE
123    )
124    add_test(NAME ot-test-spinel COMMAND ot-test-spinel)
125endif()
126