1# This file contains all the logic for running configure-time checks
2
3include(CheckSymbolExists)
4include(CheckIncludeFile)
5include(CheckIncludeFiles)
6include(CheckLibraryExists)
7include(CheckTypeSize)
8
9set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
10check_symbol_exists(ppoll poll.h HAVE_PPOLL)
11set(CMAKE_REQUIRED_DEFINITIONS)
12check_symbol_exists(sigaction signal.h HAVE_SIGACTION)
13check_cxx_symbol_exists(accept4 "sys/socket.h" HAVE_ACCEPT4)
14
15check_include_file(termios.h HAVE_TERMIOS_H)
16check_include_files("sys/types.h;sys/event.h" HAVE_SYS_EVENT_H)
17
18check_cxx_symbol_exists(process_vm_readv "sys/uio.h" HAVE_PROCESS_VM_READV)
19check_cxx_symbol_exists(__NR_process_vm_readv "sys/syscall.h" HAVE_NR_PROCESS_VM_READV)
20
21check_library_exists(compression compression_encode_buffer "" HAVE_LIBCOMPRESSION)
22
23# These checks exist in LLVM's configuration, so I want to match the LLVM names
24# so that the check isn't duplicated, but we translate them into the LLDB names
25# so that I don't have to change all the uses at the moment.
26set(LLDB_CONFIG_TERMIOS_SUPPORTED ${HAVE_TERMIOS_H})
27if(NOT UNIX)
28  set(LLDB_DISABLE_POSIX 1)
29endif()
30
31if (NOT LLDB_DISABLE_LIBEDIT)
32  # Check if we libedit capable of handling wide characters (built with
33  # '--enable-widec').
34  set(CMAKE_REQUIRED_LIBRARIES ${libedit_LIBRARIES})
35  set(CMAKE_REQUIRED_INCLUDES ${libedit_INCLUDE_DIRS})
36  check_symbol_exists(el_winsertstr histedit.h LLDB_EDITLINE_USE_WCHAR)
37  set(CMAKE_EXTRA_INCLUDE_FILES histedit.h)
38  check_type_size(el_rfunc_t LLDB_EL_RFUNC_T_SIZE)
39  if (LLDB_EL_RFUNC_T_SIZE STREQUAL "")
40    set(LLDB_HAVE_EL_RFUNC_T 0)
41  else()
42    set(LLDB_HAVE_EL_RFUNC_T 1)
43  endif()
44  set(CMAKE_REQUIRED_LIBRARIES)
45  set(CMAKE_REQUIRED_INCLUDES)
46  set(CMAKE_EXTRA_INCLUDE_FILES)
47endif()
48
49if(NOT LLDB_CONFIG_HEADER_INPUT)
50 set(LLDB_CONFIG_HEADER_INPUT ${LLDB_INCLUDE_ROOT}/lldb/Host/Config.h.cmake)
51endif()
52
53if(NOT LLDB_CONFIG_HEADER_OUTPUT)
54 set(LLDB_CONFIG_HEADER_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/lldb/Host/Config.h)
55endif()
56
57# This should be done at the end
58configure_file(
59  ${LLDB_CONFIG_HEADER_INPUT}
60  ${LLDB_CONFIG_HEADER_OUTPUT}
61  )
62