diff --git a/src/posix/CMakeLists.txt b/src/posix/CMakeLists.txt index 978bb9fd6..06940093d 100644 --- a/src/posix/CMakeLists.txt +++ b/src/posix/CMakeLists.txt @@ -38,15 +38,32 @@ set(COMMON_INCLUDES ${PROJECT_SOURCE_DIR}/src/posix/platform/include ) -set(OT_READLINE "readline" CACHE STRING "set readline library name") -set_property(CACHE OT_READLINE PROPERTY STRINGS "readline" "edit") +set(OT_READLINE_VALUES + "readline" + "edit" +) -if(OT_READLINE) +set(OT_READLINE "" CACHE STRING "set readline library name") +set_property(CACHE OT_READLINE PROPERTY STRINGS ${OT_READLINE_VALUES}) + +if(OT_READLINE STREQUAL "") + foreach(X IN LISTS OT_READLINE_VALUES) + find_library(READLINE ${X}) + if (READLINE) + set(OT_READLINE ${X}) + break() + endif() + endforeach() +elseif(OT_READLINE) find_library(READLINE ${OT_READLINE}) if (NOT READLINE) message(FATAL_ERROR "Failed to find ${OT_READLINE}") endif() +endif() + +if (READLINE) + message(STATUS "Readline: ${OT_READLINE}") find_library(NCURSES ncurses) if (NOT NCURSES)