[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / llvm / cmake / modules / FindTerminfo.cmake
blob163af66970677103f03876ae8a1ecf13cf831bf3
1 # Attempts to discover terminfo library with a linkable setupterm function.
3 # Example usage:
5 # find_package(Terminfo)
7 # If successful, the following variables will be defined:
8 # Terminfo_FOUND
9 # Terminfo_LIBRARIES
11 # Additionally, the following import target will be defined:
12 # Terminfo::terminfo
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 [=[
21     #ifdef __cplusplus
22     extern "C" {
23     #endif
24     int setupterm(char *term, int filedes, int *errret);
25     #ifdef __cplusplus
26     }
27     #endif
28     int main(void) { return setupterm(0, 0, 0); }
29     ]=])
30   if(DEFINED CMAKE_C_COMPILER)
31     include(CheckCSourceCompiles)
32     check_c_source_compiles("${Terminfo_LINKABLE_SRC}" Terminfo_LINKABLE)
33   else()
34     include(CheckCXXSourceCompiles)
35     check_cxx_source_compiles("${Terminfo_LINKABLE_SRC}" Terminfo_LINKABLE)
36   endif()
37   cmake_pop_check_state()
38 endif()
40 include(FindPackageHandleStandardArgs)
41 find_package_handle_standard_args(Terminfo
42                                   FOUND_VAR
43                                     Terminfo_FOUND
44                                   REQUIRED_VARS
45                                     Terminfo_LIBRARIES
46                                     Terminfo_LINKABLE)
47 mark_as_advanced(Terminfo_LIBRARIES
48                  Terminfo_LINKABLE)
50 if(Terminfo_FOUND)
51   if(NOT TARGET Terminfo::terminfo)
52     add_library(Terminfo::terminfo UNKNOWN IMPORTED)
53     set_target_properties(Terminfo::terminfo PROPERTIES IMPORTED_LOCATION "${Terminfo_LIBRARIES}")
54   endif()
55 endif()