Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 pmbaty 1
# Attempts to discover terminfo library with a linkable setupterm function.
2
#
3
# Example usage:
4
#
5
# find_package(Terminfo)
6
#
7
# If successful, the following variables will be defined:
8
# Terminfo_FOUND
9
# Terminfo_LIBRARIES
10
#
11
# Additionally, the following import target will be defined:
12
# Terminfo::terminfo
13
 
14
find_library(Terminfo_LIBRARIES NAMES terminfo tinfo curses ncurses ncursesw)
15
 
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); }"
24
    Terminfo_LINKABLE)
25
  cmake_pop_check_state()
26
endif()
27
 
28
include(FindPackageHandleStandardArgs)
29
find_package_handle_standard_args(Terminfo
30
                                  FOUND_VAR
31
                                    Terminfo_FOUND
32
                                  REQUIRED_VARS
33
                                    Terminfo_LIBRARIES
34
                                    Terminfo_LINKABLE)
35
mark_as_advanced(Terminfo_LIBRARIES
36
                 Terminfo_LINKABLE)
37
 
38
if(Terminfo_FOUND)
39
  if(NOT TARGET Terminfo::terminfo)
40
    add_library(Terminfo::terminfo UNKNOWN IMPORTED)
41
    set_target_properties(Terminfo::terminfo PROPERTIES IMPORTED_LOCATION "${Terminfo_LIBRARIES}")
42
  endif()
43
endif()