69 lines · plain
1#.rst:2# FindCursesAndPanel3# -----------4#5# Find the curses, terminfo, and panel library as a whole.6 7include(CMakePushCheckState)8 9function(lldb_check_curses_tinfo CURSES_INCLUDE_DIRS CURSES_LIBRARIES CURSES_HAS_TINFO)10 cmake_reset_check_state()11 set(CMAKE_REQUIRED_INCLUDES "${CURSES_INCLUDE_DIRS}")12 set(CMAKE_REQUIRED_LIBRARIES "${CURSES_LIBRARIES}")13 # acs_map is one of many symbols that are part of tinfo but could14 # be bundled in curses.15 check_symbol_exists(acs_map "curses.h" CURSES_HAS_TINFO)16endfunction()17 18if(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()28 set(CURSESANDPANEL_FOUND TRUE)29else()30 find_package(Curses QUIET)31 find_library(PANEL_LIBRARIES NAMES panel DOC "The curses panel library" QUIET)32 include(FindPackageHandleStandardArgs)33 34 if(CURSES_FOUND AND PANEL_LIBRARIES)35 # Sometimes the curses libraries define their own terminfo symbols,36 # other times they're extern and are defined by a separate terminfo library.37 # Auto-detect which.38 lldb_check_curses_tinfo("${CURSES_INCLUDE_DIRS}"39 "${CURSES_LIBRARIES}"40 CURSES_HAS_TINFO)41 if(NOT CURSES_HAS_TINFO)42 message(STATUS "curses library missing terminfo symbols, looking for tinfo separately")43 find_library(TINFO_LIBRARIES NAMES tinfo DOC "The curses tinfo library" QUIET)44 list(APPEND CURSES_LIBRARIES "${TINFO_LIBRARIES}")45 endif()46 set(HAS_TERMINFO_SYMBOLS "$<OR:$<BOOL:${TERMINFO_LIBRARIES}>,$<BOOL:${CURSES_HAS_TINFO}>>")47 endif()48 49 find_package_handle_standard_args(CursesAndPanel50 FOUND_VAR51 CURSESANDPANEL_FOUND52 REQUIRED_VARS53 CURSES_INCLUDE_DIRS54 CURSES_LIBRARIES55 PANEL_LIBRARIES56 HAS_TERMINFO_SYMBOLS)57 58 if(CURSES_FOUND AND PANEL_LIBRARIES AND HAS_TERMINFO_SYMBOLS)59 mark_as_advanced(CURSES_INCLUDE_DIRS60 PANEL_LIBRARIES61 HAS_TERMINFO_SYMBOLS62 CURSES_HAS_TINFO)63 endif()64 if(TINFO_LIBRARIES)65 mark_as_advanced(TINFO_LIBRARIES)66 endif()67endif()68 69