diff --git a/etc/cmake/options.cmake b/etc/cmake/options.cmake index 4e497d49b..3bcf7ca42 100644 --- a/etc/cmake/options.cmake +++ b/etc/cmake/options.cmake @@ -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") diff --git a/examples/apps/CMakeLists.txt b/examples/apps/CMakeLists.txt index 8200d57a1..03da6f0a0 100644 --- a/examples/apps/CMakeLists.txt +++ b/examples/apps/CMakeLists.txt @@ -26,5 +26,8 @@ # POSSIBILITY OF SUCH DAMAGE. # -add_subdirectory(cli) +if(OT_APP_CLI) + add_subdirectory(cli) +endif() + add_subdirectory(ncp) diff --git a/examples/apps/ncp/CMakeLists.txt b/examples/apps/ncp/CMakeLists.txt index 1ff7f1729..3d67effce 100644 --- a/examples/apps/ncp/CMakeLists.txt +++ b/examples/apps/ncp/CMakeLists.txt @@ -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() diff --git a/examples/apps/ncp/ncp.cmake b/examples/apps/ncp/ncp.cmake new file mode 100644 index 000000000..25b6d5e26 --- /dev/null +++ b/examples/apps/ncp/ncp.cmake @@ -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) diff --git a/examples/apps/ncp/rcp.cmake b/examples/apps/ncp/rcp.cmake new file mode 100644 index 000000000..c415d3ab3 --- /dev/null +++ b/examples/apps/ncp/rcp.cmake @@ -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) diff --git a/src/posix/CMakeLists.txt b/src/posix/CMakeLists.txt index 6b0ca1219..259ab8baf 100644 --- a/src/posix/CMakeLists.txt +++ b/src/posix/CMakeLists.txt @@ -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) diff --git a/src/posix/standalone.cmake b/src/posix/cli.cmake similarity index 76% rename from src/posix/standalone.cmake rename to src/posix/cli.cmake index 9ea77fdd1..34036ba6c 100644 --- a/src/posix/standalone.cmake +++ b/src/posix/cli.cmake @@ -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() diff --git a/src/posix/daemon.cmake b/src/posix/daemon.cmake index 3c4b5a94c..ae41e5877 100644 --- a/src/posix/daemon.cmake +++ b/src/posix/daemon.cmake @@ -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() diff --git a/src/posix/ncp.cmake b/src/posix/ncp.cmake new file mode 100644 index 000000000..b18563103 --- /dev/null +++ b/src/posix/ncp.cmake @@ -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)