summaryrefslogtreecommitdiff
path: root/cmake/FindReadline.cmake
blob: 16dd722362d1162ef63f11da8c37f4b4b452800d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Find Readline
# Readline_FOUND - system has Readline lib
# Readline_INCLUDE_DIR - the Readline include directory
# Readline_LIBRARIES - Libraries needed to use Readline
# Readline_COMPENTRY_FUNC_RETURNS_CHARPTR - Indicates if compentry function
#                                           returns a (char *)

find_path(Readline_INCLUDE_DIR NAMES readline/readline.h)
find_library(Readline_LIBRARIES NAMES readline)

# Check which standard of readline is installed on the system.
# https://github.com/CVC4/CVC4/issues/702
if(Readline_INCLUDE_DIR)
  include(CheckCXXSourceCompiles)
  set(CMAKE_REQUIRED_QUIET TRUE)
  set(CMAKE_REQUIRED_LIBRARIES readline)
  check_cxx_source_compiles(
    "#include <stdio.h>
     #include <readline/readline.h>
     char* foo(const char*, int) { return (char*)0; }
     int main() { rl_completion_entry_function = foo; return 0; }"
     Readline_COMPENTRY_FUNC_RETURNS_CHARPTR
  )
  unset(CMAKE_REQUIRED_QUIET)
  unset(CMAKE_REQUIRED_LIBRARIES)
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Readline
  DEFAULT_MSG Readline_INCLUDE_DIR Readline_LIBRARIES)
mark_as_advanced(
  Readline_INCLUDE_DIR
  Readline_LIBRARIES
  Readline_COMPENTRY_FUNC_RETURNS_CHARPTR
)
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback