• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2#  Copyright (c) 2019, 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(OT_PLATFORM_LIB "openthread-simulation" PARENT_SCOPE)
30
31add_library(ot-simulation-config INTERFACE)
32
33option(OT_SIMULATION_VIRTUAL_TIME "enable virtual time")
34if(OT_SIMULATION_VIRTUAL_TIME)
35    target_compile_definitions(ot-simulation-config INTERFACE "OPENTHREAD_SIMULATION_VIRTUAL_TIME=1")
36endif()
37
38option(OT_SIMULATION_VIRTUAL_TIME_UART "enable virtual time for UART")
39if(OT_SIMULATION_VIRTUAL_TIME_UART)
40    target_compile_definitions(ot-simulation-config INTERFACE "OPENTHREAD_SIMULATION_VIRTUAL_TIME_UART=1")
41endif()
42
43option(OT_SIMULATION_MAX_NETWORK_SIZE "set maximum network size (default: 33)")
44if(OT_SIMULATION_MAX_NETWORK_SIZE)
45    target_compile_definitions(ot-simulation-config INTERFACE "OPENTHREAD_SIMULATION_MAX_NETWORK_SIZE=${OT_SIMULATION_MAX_NETWORK_SIZE}")
46endif()
47
48if(NOT OT_CONFIG)
49    set(OT_CONFIG "openthread-core-simulation-config.h" PARENT_SCOPE)
50endif()
51
52list(APPEND OT_PLATFORM_DEFINES
53    "_BSD_SOURCE=1"
54    "_DEFAULT_SOURCE=1"
55    "OPENTHREAD_EXAMPLES_SIMULATION=1"
56    "OPENTHREAD_CONFIG_NCP_HDLC_ENABLE=1"
57)
58set(OT_PLATFORM_DEFINES ${OT_PLATFORM_DEFINES} PARENT_SCOPE)
59
60add_library(openthread-simulation
61    alarm.c
62    crypto.c
63    diag.c
64    dso_transport.c
65    entropy.c
66    flash.c
67    infra_if.c
68    logging.c
69    misc.c
70    radio.c
71    spi-stubs.c
72    system.c
73    trel.c
74    uart.c
75    virtual_time/alarm-sim.c
76    virtual_time/platform-sim.c
77    $<TARGET_OBJECTS:openthread-platform-utils>
78)
79
80find_library(LIBRT rt)
81if(LIBRT)
82    target_link_libraries(openthread-simulation PRIVATE ${LIBRT})
83endif()
84
85target_link_libraries(openthread-simulation PRIVATE
86    openthread-platform
87    ot-simulation-config
88    ot-config
89)
90
91target_compile_options(openthread-simulation PRIVATE
92    ${OT_CFLAGS}
93)
94
95target_include_directories(openthread-simulation PRIVATE
96    ${OT_PUBLIC_INCLUDES}
97    ${PROJECT_SOURCE_DIR}/examples/platforms
98    ${PROJECT_SOURCE_DIR}/src
99    ${PROJECT_SOURCE_DIR}/src/core
100)
101
102if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
103    set(CPACK_PACKAGE_NAME "openthread-simulation")
104    set(CPACK_GENERATOR "DEB")
105    set(CPACK_DEBIAN_PACKAGE_MAINTAINER "OpenThread Authors (https://github.com/openthread/openthread)")
106    set(CPACK_PACKAGE_CONTACT "OpenThread Authors (https://github.com/openthread/openthread)")
107    include(CPack)
108endif()
109