[cmake] allow just build NCP/CLI/RCP (#4953)

This commit is contained in:
Yakun Xu
2020-05-14 14:26:21 +08:00
committed by Jonathan Hui
parent c3e7fdc83e
commit 31e600f227
9 changed files with 193 additions and 85 deletions
+4
View File
@@ -26,6 +26,10 @@
# POSSIBILITY OF SUCH DAMAGE.
#
option(OT_APP_CLI "enable CLI app" ON)
option(OT_APP_NCP "enable NCP app" ON)
option(OT_APP_RCP "enable RCP app" ON)
option(OT_BACKBONE_ROUTER "enable backbone router functionality")
if(OT_BACKBONE_ROUTER)
list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE=1")
+4 -1
View File
@@ -26,5 +26,8 @@
# POSSIBILITY OF SUCH DAMAGE.
#
add_subdirectory(cli)
if(OT_APP_CLI)
add_subdirectory(cli)
endif()
add_subdirectory(ncp)
+6 -44
View File
@@ -26,18 +26,6 @@
# POSSIBILITY OF SUCH DAMAGE.
#
add_executable(ot-ncp-ftd
main.c
)
add_executable(ot-ncp-mtd
main.c
)
add_executable(ot-rcp
main.c
)
set(COMMON_INCLUDES
${OT_PUBLIC_INCLUDES}
${OT_PRIVATE_INCLUDES}
@@ -45,36 +33,10 @@ set(COMMON_INCLUDES
${PROJECT_SOURCE_DIR}/src/core
)
target_include_directories(ot-ncp-ftd PRIVATE ${COMMON_INCLUDES})
target_include_directories(ot-ncp-mtd PRIVATE ${COMMON_INCLUDES})
target_include_directories(ot-rcp PRIVATE ${COMMON_INCLUDES})
if(OT_APP_NCP)
include(ncp.cmake)
endif()
target_compile_definitions(ot-ncp-ftd PRIVATE ${OT_PRIVATE_DEFINES})
target_compile_definitions(ot-ncp-mtd PRIVATE ${OT_PRIVATE_DEFINES})
target_compile_definitions(ot-rcp PRIVATE ${OT_PRIVATE_DEFINES})
target_link_libraries(ot-ncp-ftd
openthread-ncp-ftd
${OT_PLATFORM_LIB}
openthread-ftd
${OT_PLATFORM_LIB}
mbedcrypto
)
target_link_libraries(ot-ncp-mtd
openthread-ncp-mtd
${OT_PLATFORM_LIB}
openthread-mtd
${OT_PLATFORM_LIB}
mbedcrypto
)
target_link_libraries(ot-rcp
openthread-rcp
${OT_PLATFORM_LIB}
openthread-radio
${OT_PLATFORM_LIB}
)
install(TARGETS ot-rcp ot-ncp-ftd ot-ncp-mtd
DESTINATION bin)
if(OT_APP_RCP)
include(rcp.cmake)
endif()
+59
View File
@@ -0,0 +1,59 @@
#
# Copyright (c) 2020, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
add_executable(ot-ncp-ftd
main.c
)
add_executable(ot-ncp-mtd
main.c
)
target_include_directories(ot-ncp-ftd PRIVATE ${COMMON_INCLUDES})
target_include_directories(ot-ncp-mtd PRIVATE ${COMMON_INCLUDES})
target_compile_definitions(ot-ncp-ftd PRIVATE ${OT_PRIVATE_DEFINES})
target_compile_definitions(ot-ncp-mtd PRIVATE ${OT_PRIVATE_DEFINES})
target_link_libraries(ot-ncp-ftd
openthread-ncp-ftd
${OT_PLATFORM_LIB}
openthread-ftd
${OT_PLATFORM_LIB}
mbedcrypto
)
target_link_libraries(ot-ncp-mtd
openthread-ncp-mtd
${OT_PLATFORM_LIB}
openthread-mtd
${OT_PLATFORM_LIB}
mbedcrypto
)
install(TARGETS ot-ncp-ftd ot-ncp-mtd DESTINATION bin)
+44
View File
@@ -0,0 +1,44 @@
#
# Copyright (c) 2020, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
add_executable(ot-rcp
main.c
)
target_include_directories(ot-rcp PRIVATE ${COMMON_INCLUDES})
target_compile_definitions(ot-rcp PRIVATE ${OT_PRIVATE_DEFINES})
target_link_libraries(ot-rcp
openthread-rcp
${OT_PLATFORM_LIB}
openthread-radio
${OT_PLATFORM_LIB}
)
install(TARGETS ot-rcp DESTINATION bin)
+15 -1
View File
@@ -54,8 +54,22 @@ endif()
if(OT_DAEMON)
include(daemon.cmake)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(CPACK_PACKAGE_NAME "openthread-daemon")
endif()
else()
include(standalone.cmake)
if(OT_APP_CLI)
include(cli.cmake)
endif()
if(OT_APP_NCP)
include(ncp.cmake)
endif()
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(CPACK_PACKAGE_NAME "openthread-standalone")
endif()
endif()
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
@@ -60,40 +60,6 @@ target_link_libraries(ot-cli
${READLINE_LINK_LIBRARIES}
)
add_executable(ot-ncp
main.c
)
set_target_properties(
ot-ncp
PROPERTIES
C_STANDARD 99
CXX_STANDARD 11
)
install(TARGETS ot-cli DESTINATION bin)
target_include_directories(ot-ncp PRIVATE ${COMMON_INCLUDES})
target_compile_definitions(ot-ncp PRIVATE
OPENTHREAD_POSIX_APP_TYPE=OT_POSIX_APP_TYPE_NCP
${OT_PLATFORM_DEFINES}
)
target_compile_options(ot-ncp PRIVATE
${OT_CFLAGS}
)
target_link_libraries(ot-ncp
openthread-ncp-ftd
${OT_PLATFORM_LIB}
openthread-ftd
${OT_PLATFORM_LIB}
mbedcrypto
openthread-ncp-ftd
)
install(TARGETS ot-cli ot-ncp
DESTINATION bin)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(CPACK_PACKAGE_NAME "openthread-standalone")
endif()
-4
View File
@@ -88,7 +88,3 @@ install(TARGETS ot-daemon
DESTINATION sbin)
install(TARGETS ot-ctl
DESTINATION bin)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(CPACK_PACKAGE_NAME "openthread-daemon")
endif()
+60
View File
@@ -0,0 +1,60 @@
#
# Copyright (c) 2020, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
add_executable(ot-ncp
main.c
)
set_target_properties(
ot-ncp
PROPERTIES
C_STANDARD 99
CXX_STANDARD 11
)
target_include_directories(ot-ncp PRIVATE ${COMMON_INCLUDES})
target_compile_definitions(ot-ncp PRIVATE
OPENTHREAD_POSIX_APP_TYPE=OT_POSIX_APP_TYPE_NCP
${OT_PLATFORM_DEFINES}
)
target_compile_options(ot-ncp PRIVATE
${OT_CFLAGS}
)
target_link_libraries(ot-ncp
openthread-ncp-ftd
${OT_PLATFORM_LIB}
openthread-ftd
${OT_PLATFORM_LIB}
mbedcrypto
openthread-ncp-ftd
)
install(TARGETS ot-ncp DESTINATION bin)