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 cmake_push_check_state()
19 list(APPEND CMAKE_REQUIRED_LIBRARIES ${Terminfo_LIBRARIES})
20 set(Terminfo_LINKABLE_SRC [=[
24 int setupterm(char *term, int filedes, int *errret);
28 int main(void) { return setupterm(0, 0, 0); }
30 if(DEFINED CMAKE_C_COMPILER)
31 include(CheckCSourceCompiles)
32 check_c_source_compiles("${Terminfo_LINKABLE_SRC}" Terminfo_LINKABLE)
34 include(CheckCXXSourceCompiles)
35 check_cxx_source_compiles("${Terminfo_LINKABLE_SRC}" Terminfo_LINKABLE)
37 cmake_pop_check_state()
40 include(FindPackageHandleStandardArgs)
41 find_package_handle_standard_args(Terminfo
47 mark_as_advanced(Terminfo_LIBRARIES
51 if(NOT TARGET Terminfo::terminfo)
52 add_library(Terminfo::terminfo UNKNOWN IMPORTED)
53 set_target_properties(Terminfo::terminfo PROPERTIES IMPORTED_LOCATION "${Terminfo_LIBRARIES}")