|
2 | 2 | # FindCursesAndPanel
|
3 | 3 | # -----------
|
4 | 4 | #
|
5 |
| -# Find the curses and panel library as a whole. |
| 5 | +# Find the curses, terminfo, and panel library as a whole. |
6 | 6 |
|
7 |
| -if(CURSES_INCLUDE_DIRS AND CURSES_LIBRARIES AND PANEL_LIBRARIES) |
| 7 | +include(CMakePushCheckState) |
| 8 | + |
| 9 | +function(lldb_check_curses_tinfo CURSES_LIBRARIES CURSES_HAS_TINFO) |
| 10 | + cmake_reset_check_state() |
| 11 | + set(CMAKE_REQUIRED_LIBRARIES "${CURSES_LIBRARIES}") |
| 12 | + # acs_map is one of many symbols that are part of tinfo but could |
| 13 | + # be bundled in curses. |
| 14 | + check_symbol_exists(acs_map "curses.h" CURSES_HAS_TINFO) |
| 15 | +endfunction() |
| 16 | + |
| 17 | +if(CURSES_INCLUDE_DIRS AND CURSES_LIBRARIES AND TINFO_LIBRARIES AND PANEL_LIBRARIES) |
8 | 18 | set(CURSESANDPANEL_FOUND TRUE)
|
9 | 19 | else()
|
10 | 20 | find_package(Curses QUIET)
|
11 | 21 | find_library(PANEL_LIBRARIES NAMES panel DOC "The curses panel library" QUIET)
|
12 | 22 | include(FindPackageHandleStandardArgs)
|
| 23 | + |
| 24 | + if(CURSES_FOUND AND PANEL_LIBRARIES) |
| 25 | + # Sometimes the curses libraries define their own terminfo symbols, |
| 26 | + # other times they're extern and are defined by a separate terminfo library. |
| 27 | + # Auto-detect which. |
| 28 | + lldb_check_curses_tinfo("${CURSES_LIBRARIES}" CURSES_HAS_TINFO) |
| 29 | + if (NOT CURSES_HAS_TINFO) |
| 30 | + message(STATUS "curses library missing terminfo symbols, looking for tinfo separately") |
| 31 | + find_library(TINFO_LIBRARIES NAMES tinfo DOC "The curses tinfo library" QUIET) |
| 32 | + list(APPEND CURSES_LIBRARIES "${TINFO_LIBRARIES}") |
| 33 | + endif() |
| 34 | + set(HAS_TERMINFO_SYMBOLS "$<OR:$<BOOL:${TERMINFO_LIBRARIES}>,$<BOOL:${CURSES_HAS_TINFO}>>") |
| 35 | + endif() |
| 36 | + |
13 | 37 | find_package_handle_standard_args(CursesAndPanel
|
14 | 38 | FOUND_VAR
|
15 | 39 | CURSESANDPANEL_FOUND
|
16 | 40 | REQUIRED_VARS
|
17 | 41 | CURSES_INCLUDE_DIRS
|
18 | 42 | CURSES_LIBRARIES
|
19 |
| - PANEL_LIBRARIES) |
20 |
| - if(CURSES_FOUND AND PANEL_LIBRARIES) |
21 |
| - mark_as_advanced(CURSES_INCLUDE_DIRS CURSES_LIBRARIES PANEL_LIBRARIES) |
| 43 | + PANEL_LIBRARIES |
| 44 | + HAS_TERMINFO_SYMBOLS) |
| 45 | + |
| 46 | + if(CURSES_FOUND AND PANEL_LIBRARIES AND HAS_TERMINFO_SYMBOLS) |
| 47 | + mark_as_advanced(CURSES_INCLUDE_DIRS |
| 48 | + PANEL_LIBRARIES |
| 49 | + HAS_TERMINFO_SYMBOLS |
| 50 | + CURSES_HAS_TINFO) |
| 51 | + endif() |
| 52 | + if(TINFO_LIBRARIES) |
| 53 | + mark_as_advanced(TINFO_LIBRARIES) |
22 | 54 | endif()
|
23 | 55 | endif()
|
24 | 56 |
|
0 commit comments