1 # Attempts to discover terminfo library with a linkable setupterm function.
5 # find_package(Terminfo)
7 # If successful, the following variables will be defined:
11 # Additionally, the following import target will be defined:
14 find_library(Terminfo_LIBRARIES NAMES terminfo tinfo curses ncurses ncursesw)
16 if(Terminfo_LIBRARIES)
17 include(CMakePushCheckState)
18 include(CheckCSourceCompiles)
19 cmake_push_check_state()
20 list(APPEND CMAKE_REQUIRED_LIBRARIES ${Terminfo_LIBRARIES})
21 check_c_source_compiles("
22 int setupterm(char *term, int filedes, int *errret);
23 int main(void) { return setupterm(0, 0, 0); }"
25 cmake_pop_check_state()
28 include(FindPackageHandleStandardArgs)
29 find_package_handle_standard_args(Terminfo
35 mark_as_advanced(Terminfo_LIBRARIES
39 if(NOT TARGET Terminfo::terminfo)
40 add_library(Terminfo::terminfo UNKNOWN IMPORTED)
41 set_target_properties(Terminfo::terminfo PROPERTIES IMPORTED_LOCATION "${Terminfo_LIBRARIES}")