• 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_PLATFORM_CONFIG)
49    set(OT_PLATFORM_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    ble.c
63    crypto.c
64    diag.c
65    dns.c
66    dnssd.c
67    dso_transport.c
68    entropy.c
69    flash.c
70    infra_if.c
71    logging.c
72    misc.c
73    multipan.c
74    radio.c
75    simul_utils.c
76    spi-stubs.c
77    system.c
78    trel.c
79    uart.c
80    virtual_time/alarm-sim.c
81    virtual_time/platform-sim.c
82    $<TARGET_OBJECTS:openthread-platform-utils>
83)
84
85find_library(LIBRT rt)
86if(LIBRT)
87    target_link_libraries(openthread-simulation PRIVATE ${LIBRT})
88endif()
89
90target_link_libraries(openthread-simulation PRIVATE
91    openthread-platform
92    ot-simulation-config
93    ot-config
94)
95
96target_compile_options(openthread-simulation PRIVATE
97    ${OT_CFLAGS}
98)
99
100target_include_directories(openthread-simulation PRIVATE
101    ${OT_PUBLIC_INCLUDES}
102    ${PROJECT_SOURCE_DIR}/examples/platforms
103    ${PROJECT_SOURCE_DIR}/src
104    ${PROJECT_SOURCE_DIR}/src/core
105)
106
107if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
108    set(CPACK_PACKAGE_NAME "openthread-simulation")
109    set(CPACK_GENERATOR "DEB")
110    set(CPACK_DEBIAN_PACKAGE_MAINTAINER "OpenThread Authors (https://github.com/openthread/openthread)")
111    set(CPACK_PACKAGE_CONTACT "OpenThread Authors (https://github.com/openthread/openthread)")
112    include(CPack)
113endif()
114