From 7d1934202f193c48511f174b32749d26be4457dc Mon Sep 17 00:00:00 2001 From: Yakun Xu Date: Tue, 19 May 2020 00:36:55 +0800 Subject: [PATCH] [cmake] add ncurses dependency (#4971) This is required on OpenWRT. --- .github/workflows/build.yml | 6 ++++-- .github/workflows/simulation.yml | 4 ++-- src/posix/CMakeLists.txt | 11 +++++++++++ src/posix/daemon.cmake | 2 +- src/posix/standalone.cmake | 2 +- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a4e7e7ce4..f2268259f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -76,7 +76,7 @@ jobs: - name: Bootstrap run: | sudo apt update - sudo apt --no-install-recommends install -y ninja-build + sudo apt --no-install-recommends install -y ninja-build libreadline-dev libncurses-dev - name: Package run: | script/test package @@ -147,7 +147,7 @@ jobs: - name: Bootstrap run: | sudo apt update - sudo apt --no-install-recommends install -y gcc-${{ matrix.gcc_ver }} g++-${{ matrix.gcc_ver }} ninja-build + sudo apt --no-install-recommends install -y gcc-${{ matrix.gcc_ver }} g++-${{ matrix.gcc_ver }} ninja-build libreadline-dev libncurses-dev - name: Build run: | script/check-simulation-build @@ -169,8 +169,10 @@ jobs: - uses: actions/checkout@v2 - name: Bootstrap run: | + sudo dpkg --add-architecture i386 sudo apt update sudo apt --no-install-recommends install -y clang-${{ matrix.clang_ver }} clang++-${{ matrix.clang_ver }} g++-multilib ninja-build + sudo apt --no-install-recommends install -y libreadline-dev:i386 libncurses-dev:i386 - name: Build run: | script/check-posix-build diff --git a/.github/workflows/simulation.yml b/.github/workflows/simulation.yml index 5c7b9170a..b9679e7de 100644 --- a/.github/workflows/simulation.yml +++ b/.github/workflows/simulation.yml @@ -148,7 +148,7 @@ jobs: - uses: actions/checkout@v2 - name: Bootstrap run: | - sudo apt --no-install-recommends install -y expect ninja-build + OT_OPTIONS=-DOT_READLINE=OFF sudo apt --no-install-recommends install -y expect ninja-build - name: Run run: | ./script/test build expect @@ -156,7 +156,7 @@ jobs: uses: codecov/codecov-action@v1 - name: Run RCP Mode run: | - VIRTUAL_TIME=0 NODE_MODE=rcp ./script/test clean build expect + OT_OPTIONS=-DOT_READLINE=OFF VIRTUAL_TIME=0 NODE_MODE=rcp ./script/test clean build expect - name: Codecov uses: codecov/codecov-action@v1 diff --git a/src/posix/CMakeLists.txt b/src/posix/CMakeLists.txt index a1e158185..6b0ca1219 100644 --- a/src/posix/CMakeLists.txt +++ b/src/posix/CMakeLists.txt @@ -39,6 +39,17 @@ set_property(CACHE OT_READLINE PROPERTY STRINGS "readline" "edit" "no") if(OT_READLINE) find_library(READLINE ${OT_READLINE}) + + if (NOT READLINE) + message(FATAL_ERROR "Failed to find ${OT_READLINE}") + endif() + + find_library(NCURSES ncurses) + if (NOT NCURSES) + message(FATAL_ERROR "Failed to find ncurses") + endif() + + list(APPEND READLINE_LINK_LIBRARIES "${READLINE}" "${NCURSES}") endif() if(OT_DAEMON) diff --git a/src/posix/daemon.cmake b/src/posix/daemon.cmake index 396b1f867..3c4b5a94c 100644 --- a/src/posix/daemon.cmake +++ b/src/posix/daemon.cmake @@ -79,7 +79,7 @@ target_compile_options(ot-ctl PRIVATE target_link_libraries(ot-ctl openthread-platform - $<$:${OT_READLINE}> + ${READLINE_LINK_LIBRARIES} ) target_include_directories(ot-ctl PRIVATE ${COMMON_INCLUDES}) diff --git a/src/posix/standalone.cmake b/src/posix/standalone.cmake index fc89ddd85..9ea77fdd1 100644 --- a/src/posix/standalone.cmake +++ b/src/posix/standalone.cmake @@ -57,7 +57,7 @@ target_link_libraries(ot-cli ${OT_PLATFORM_LIB} mbedcrypto openthread-ncp-ftd - $<$:${OT_READLINE}> + ${READLINE_LINK_LIBRARIES} ) add_executable(ot-ncp