[cmake] auto choose readline library (#6251)

This commit is contained in:
Yakun Xu
2021-03-09 10:48:47 -08:00
committed by GitHub
parent 21cd2d18d7
commit e5614d8ecb
+20 -3
View File
@@ -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)