diff options
author | Andrew V. Jones <andrew.jones@vector.com> | 2020-07-17 18:09:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-17 10:09:14 -0700 |
commit | e8df6f67cc2654f50d49995377a4b411668235e1 (patch) | |
tree | fb8c2b35197e5821ac15c78b74da0d2de8eec3fc /cmake | |
parent | 0988217562006d3f59e01dc261f39121df6d75f5 (diff) |
Support for using 'libedit' over 'readline' #4571 (#4579)
Signed-off-by: Andrew V. Jones <andrew.jones@vector.com>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/FindEditline.cmake | 40 | ||||
-rw-r--r-- | cmake/FindReadline.cmake | 69 |
2 files changed, 40 insertions, 69 deletions
diff --git a/cmake/FindEditline.cmake b/cmake/FindEditline.cmake new file mode 100644 index 000000000..fe4001173 --- /dev/null +++ b/cmake/FindEditline.cmake @@ -0,0 +1,40 @@ +# Find Editline +# Editline_FOUND - found Editline lib +# Editline_INCLUDE_DIR - the Editline include directory +# Editline_LIBRARIES - Libraries needed to use Editline +# Editline_COMPENTRY_FUNC_RETURNS_CHARPTR - Indicates if compentry function +# returns a (char *) + +find_path(Editline_INCLUDE_DIR NAMES histedit.h) +find_library(Editline_LIBRARIES NAMES edit libedit) + +if(Editline_INCLUDE_DIR) + # Check which standard of editline is installed on the system. + # https://github.com/CVC4/CVC4/issues/702 + include(CheckCXXSourceCompiles) + set(CMAKE_REQUIRED_QUIET TRUE) + set(CMAKE_REQUIRED_LIBRARIES ${Editline_LIBRARIES}) + set(CMAKE_REQUIRED_INCLUDES ${Editline_INCLUDE_DIR}) + check_cxx_source_compiles( + "#include <stdio.h> + #include <editline/readline.h> + char* foo(const char*, int) { return (char*)0; } + int main() { rl_completion_entry_function = foo; return 0; }" + Editline_COMPENTRY_FUNC_RETURNS_CHARPTR + ) + unset(CMAKE_REQUIRED_QUIET) + unset(CMAKE_REQUIRED_LIBRARIES) + unset(CMAKE_REQUIRED_INCLUDES) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Editline + DEFAULT_MSG Editline_INCLUDE_DIR Editline_LIBRARIES) +mark_as_advanced( + Editline_INCLUDE_DIR + Editline_LIBRARIES + Editline_COMPENTRY_FUNC_RETURNS_CHARPTR +) +if(Editline_LIBRARIES) + message(STATUS "Editline library: ${Editline_LIBRARIES}") +endif() diff --git a/cmake/FindReadline.cmake b/cmake/FindReadline.cmake deleted file mode 100644 index edac03027..000000000 --- a/cmake/FindReadline.cmake +++ /dev/null @@ -1,69 +0,0 @@ -# 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) - -# Try to compile and link a simple program against readline. 'libs' can be -# used to specify additional required libraries. -function(try_compile_readline libs _result) - set(CMAKE_REQUIRED_QUIET TRUE) - set(CMAKE_REQUIRED_LIBRARIES ${Readline_LIBRARIES} ${libs}) - check_cxx_source_compiles( - " - #include <stdio.h> - #include <readline/readline.h> - int main() { readline(\"\"); return 0; } - " - ${_result} - ) - set(${_result} ${${_result}} PARENT_SCOPE) -endfunction() - -if(Readline_INCLUDE_DIR) - # We only need to figure out readline's additional libraries dependencies if - # we compile static. - # Note: It might be the case that we need to check for more/other libraries - # depending on what the installed version of readline is linked against - # (e.g., termcap, ncurses, ...). - find_library(TINFO_LIBRARY tinfo) - try_compile_readline(${TINFO_LIBRARY} OK) - if(OK) - list(APPEND Readline_LIBRARIES ${TINFO_LIBRARY}) - else() - message(FATAL_ERROR - "Could not link against readline. " - "Check CMakeError.log for more details") - endif() - - # Check which standard of readline is installed on the system. - # https://github.com/CVC4/CVC4/issues/702 - include(CheckCXXSourceCompiles) - set(CMAKE_REQUIRED_QUIET TRUE) - set(CMAKE_REQUIRED_LIBRARIES ${Readline_LIBRARIES}) - 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 -) -if(Readline_LIBRARIES) - message(STATUS "Found Readline libs: ${Readline_LIBRARIES}") -endif() |