[lldb] Fix manual CURSES_LIBRARIES tinfo finding (#128245) · llvm/llvm-project@54c90e4 (original) (raw)

Original file line number Diff line number Diff line change
@@ -6,15 +6,25 @@
6 6
7 7 include(CMakePushCheckState)
8 8
9 -function(lldb_check_curses_tinfo CURSES_LIBRARIES CURSES_HAS_TINFO)
9 +function(lldb_check_curses_tinfo CURSES_INCLUDE_DIRS CURSES_LIBRARIES CURSES_HAS_TINFO)
10 10 cmake_reset_check_state()
11 +set(CMAKE_REQUIRED_INCLUDES "${CURSES_INCLUDE_DIRS}")
11 12 set(CMAKE_REQUIRED_LIBRARIES "${CURSES_LIBRARIES}")
12 13 # acs_map is one of many symbols that are part of tinfo but could
13 14 # be bundled in curses.
14 15 check_symbol_exists(acs_map "curses.h" CURSES_HAS_TINFO)
15 16 endfunction()
16 17
17 -if(CURSES_INCLUDE_DIRS AND CURSES_LIBRARIES AND TINFO_LIBRARIES AND PANEL_LIBRARIES)
18 +if(CURSES_INCLUDE_DIRS AND CURSES_LIBRARIES AND PANEL_LIBRARIES)
19 + if(NOT HAS_TERMINFO_SYMBOLS)
20 +lldb_check_curses_tinfo("${CURSES_INCLUDE_DIRS}"
21 +"${CURSES_LIBRARIES}"
22 +CURSES_HAS_TINFO)
23 + if(NOT CURSES_HAS_TINFO)
24 +message(WARNING "CURSES_LIBRARIES was provided manually but is missing terminfo symbols")
25 + endif()
26 +mark_as_advanced(CURSES_HAS_TINFO)
27 + endif()
18 28 set(CURSESANDPANEL_FOUND TRUE)
19 29 else()
20 30 find_package(Curses QUIET)
@@ -25,8 +35,10 @@ else()
25 35 # Sometimes the curses libraries define their own terminfo symbols,
26 36 # other times they're extern and are defined by a separate terminfo library.
27 37 # Auto-detect which.
28 -lldb_check_curses_tinfo("${CURSES_LIBRARIES}" CURSES_HAS_TINFO)
29 - if (NOT CURSES_HAS_TINFO)
38 +lldb_check_curses_tinfo("${CURSES_INCLUDE_DIRS}"
39 +"${CURSES_LIBRARIES}"
40 +CURSES_HAS_TINFO)
41 + if(NOT CURSES_HAS_TINFO)
30 42 message(STATUS "curses library missing terminfo symbols, looking for tinfo separately")
31 43 find_library(TINFO_LIBRARIES NAMES tinfo DOC "The curses tinfo library" QUIET)
32 44 list(APPEND CURSES_LIBRARIES "${TINFO_LIBRARIES}")