New C++ Api: Clean up usage of internal types in Term. (#6054)
[cvc5.git] / cmake / FindEditline.cmake
1 #####################
2 ## FindEditline.cmake
3 ## Top contributors (to current version):
4 ## Andrew V. Jones, Mathias Preiner
5 ## This file is part of the CVC4 project.
6 ## Copyright (c) 2009-2020 by the authors listed in the file AUTHORS
7 ## in the top-level source directory and their institutional affiliations.
8 ## All rights reserved. See the file COPYING in the top-level source
9 ## directory for licensing information.
10 ##
11 # Find Editline
12 # Editline_FOUND - found Editline lib
13 # Editline_INCLUDE_DIRS - the Editline include directory
14 # Editline_LIBRARIES - Libraries needed to use Editline
15 # Editline_COMPENTRY_FUNC_RETURNS_CHARPTR - Indicates if compentry function
16 # returns a (char *)
17
18 # When finding libedit, use pkg-config to ensure we find all the required
19 # linking flags for libedit
20 find_package(PkgConfig REQUIRED)
21 pkg_check_modules(Editline REQUIRED libedit)
22
23 if(Editline_INCLUDE_DIRS)
24 # Check which standard of editline is installed on the system.
25 # https://github.com/CVC4/CVC4/issues/702
26 include(CheckCXXSourceCompiles)
27 set(CMAKE_REQUIRED_QUIET TRUE)
28 set(CMAKE_REQUIRED_LIBRARIES ${Editline_LIBRARIES})
29 set(CMAKE_REQUIRED_INCLUDES ${Editline_INCLUDE_DIRS})
30 check_cxx_source_compiles(
31 "#include <stdio.h>
32 #include <editline/readline.h>
33 char* foo(const char*, int) { return (char*)0; }
34 int main() { rl_completion_entry_function = foo; return 0; }"
35 Editline_COMPENTRY_FUNC_RETURNS_CHARPTR
36 )
37 unset(CMAKE_REQUIRED_QUIET)
38 unset(CMAKE_REQUIRED_LIBRARIES)
39 unset(CMAKE_REQUIRED_INCLUDES)
40 endif()
41
42 include(FindPackageHandleStandardArgs)
43 find_package_handle_standard_args(Editline
44 DEFAULT_MSG Editline_INCLUDE_DIRS Editline_LIBRARIES)
45 mark_as_advanced(
46 Editline_INCLUDE_DIRS
47 Editline_LIBRARIES
48 Editline_COMPENTRY_FUNC_RETURNS_CHARPTR
49 )
50 if(Editline_LIBRARIES)
51 message(STATUS "Editline library: ${Editline_LIBRARIES}")
52 endif()