Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 36 additions & 5 deletions lldb/cmake/modules/FindCursesAndPanel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,54 @@
# FindCursesAndPanel
# -----------
#
# Find the curses and panel library as a whole.
# Find the curses, terminfo, and panel library as a whole.

if(CURSES_INCLUDE_DIRS AND CURSES_LIBRARIES AND PANEL_LIBRARIES)
include(CMakePushCheckState)

function(lldb_check_curses_tinfo CURSES_LIBRARIES CURSES_HAS_TINFO)
cmake_reset_check_state()
set(CMAKE_REQUIRED_LIBRARIES "${CURSES_LIBRARIES}")
# acs_map is one of many symbols that are part of tinfo but could
# be bundled in curses.
check_symbol_exists(acs_map "curses.h" CURSES_HAS_TINFO)
endfunction()

if(CURSES_INCLUDE_DIRS AND CURSES_LIBRARIES AND TINFO_LIBRARIES AND PANEL_LIBRARIES)
set(CURSESANDPANEL_FOUND TRUE)
else()
find_package(Curses QUIET)
find_library(PANEL_LIBRARIES NAMES panel DOC "The curses panel library" QUIET)
include(FindPackageHandleStandardArgs)

# Sometimes the curses libraries define their own terminfo symbols,
# other times they're extern and are defined by a separate terminfo library.
# Auto-detect which.
lldb_check_curses_tinfo("${CURSES_LIBRARIES}" CURSES_HAS_TINFO)
if(CURSES_FOUND AND PANEL_LIBRARIES)
if (NOT CURSES_HAS_TINFO)
message(STATUS "curses library missing terminfo symbols, looking for tinfo separately")
find_library(TINFO_LIBRARIES NAMES tinfo DOC "The curses tinfo library" QUIET)
endif()
set(HAS_TERMINFO_SYMBOLS "$<OR:$<BOOL:${TERMINFO_LIBRARIES}>,$<BOOL:${CURSES_HAS_TINFO}>>")
endif()
find_package_handle_standard_args(CursesAndPanel
FOUND_VAR
CURSESANDPANEL_FOUND
REQUIRED_VARS
CURSES_INCLUDE_DIRS
CURSES_LIBRARIES
PANEL_LIBRARIES)
if(CURSES_FOUND AND PANEL_LIBRARIES)
mark_as_advanced(CURSES_INCLUDE_DIRS CURSES_LIBRARIES PANEL_LIBRARIES)
PANEL_LIBRARIES
HAS_TERMINFO_SYMBOLS
)

if(CURSES_FOUND AND PANEL_LIBRARIES AND HAS_TERMINFO_SYMBOLS)
mark_as_advanced(CURSES_INCLUDE_DIRS
PANEL_LIBRARIES
HAS_TERMINFO_SYMBOLS
CURSES_HAS_TINFO)
endif()
if(TINFO_LIBRARIES)
mark_as_advanced(TINFO_LIBRARIES)
endif()
endif()

3 changes: 3 additions & 0 deletions lldb/source/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ set(LLDB_LIBEDIT_LIBS)

if (LLDB_ENABLE_CURSES)
list(APPEND LLDB_CURSES_LIBS ${PANEL_LIBRARIES} ${CURSES_LIBRARIES})
if(NOT CURSES_HAS_TINFO)
list(APPEND LLDB_CURSES_LIBS ${TINFO_LIBRARIES})
endif()
if (LLVM_BUILD_STATIC)
list(APPEND LLDB_CURSES_LIBS gpm)
endif()
Expand Down
Loading