summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorMathias Preiner <mathias.preiner@gmail.com>2018-08-15 12:53:43 -0700
committerMathias Preiner <mathias.preiner@gmail.com>2018-09-22 16:30:59 -0700
commit48596d14f3aa3946fb53c632ca0f38827097951a (patch)
tree55cb93b95250fb2a8f0b638e95176ca622d2b710 /cmake
parent52b9d01f4c3cc0b34daa4759e1004fc315f3f30e (diff)
cmake: Add module finder for readline.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/FindReadline.cmake31
1 files changed, 31 insertions, 0 deletions
diff --git a/cmake/FindReadline.cmake b/cmake/FindReadline.cmake
new file mode 100644
index 000000000..2448f73cb
--- /dev/null
+++ b/cmake/FindReadline.cmake
@@ -0,0 +1,31 @@
+# Find Readline
+# Readline_FOUND - system has Readline lib
+# Readline_INCLUDE_DIR - the Readline include directory
+# Readline_LIBRARIES - Libraries needed to use Readline
+
+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
+ )
+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