Make GNU Readline dependency optional
Reviewers: florijan, buda Reviewed By: buda Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D171
This commit is contained in:
parent
087c56315e
commit
35668d5b9f
@ -57,7 +57,13 @@ add_custom_target(clean_all
|
|||||||
|
|
||||||
# threading
|
# threading
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
# find_package(readline REQUIRED)
|
# optional readline
|
||||||
|
find_package(Readline REQUIRED)
|
||||||
|
if (READLINE_FOUND)
|
||||||
|
include_directories(SYSTEM ${READLINE_INCLUDE_DIR})
|
||||||
|
add_definitions(-DHAS_READLINE)
|
||||||
|
endif()
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
# c++14
|
# c++14
|
||||||
@ -424,7 +430,9 @@ if (MEMGRAPH)
|
|||||||
target_link_libraries(${MEMGRAPH_BUILD_NAME} yaml-cpp)
|
target_link_libraries(${MEMGRAPH_BUILD_NAME} yaml-cpp)
|
||||||
target_link_libraries(${MEMGRAPH_BUILD_NAME} antlr_opencypher_parser_lib)
|
target_link_libraries(${MEMGRAPH_BUILD_NAME} antlr_opencypher_parser_lib)
|
||||||
target_link_libraries(${MEMGRAPH_BUILD_NAME} dl)
|
target_link_libraries(${MEMGRAPH_BUILD_NAME} dl)
|
||||||
target_link_libraries(${MEMGRAPH_BUILD_NAME} readline)
|
if (READLINE_FOUND)
|
||||||
|
target_link_libraries(${MEMGRAPH_BUILD_NAME} ${READLINE_LIBRARY})
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# utility target to copy hardcoded queries
|
# utility target to copy hardcoded queries
|
||||||
|
27
cmake/FindReadline.cmake
Normal file
27
cmake/FindReadline.cmake
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# Find the GNU Readline library.
|
||||||
|
# This module plugs into CMake's `find_package` so the example usage is:
|
||||||
|
# `find_package(Readline REQUIRED)`
|
||||||
|
# Options to `find_package` are as documented in CMake documentation.
|
||||||
|
# READLINE_LIBRARY will be a path to the library.
|
||||||
|
# READLINE_INCLUDE_DIR will be a path to the include directory.
|
||||||
|
# READLINE_FOUND will be TRUE if the library is found.
|
||||||
|
if (READLINE_LIBRARY AND READLINE_INCLUDE_DIR)
|
||||||
|
set(READLINE_FOUND TRUE)
|
||||||
|
else()
|
||||||
|
find_library(READLINE_LIBRARY readline)
|
||||||
|
find_path(READLINE_INCLUDE_DIR readline/readline.h)
|
||||||
|
if (READLINE_LIBRARY AND READLINE_INCLUDE_DIR)
|
||||||
|
set(READLINE_FOUND TRUE)
|
||||||
|
if (NOT READLINE_FIND_QUIETLY)
|
||||||
|
message(STATUS "Found Readline: ${READLINE_LIBRARY} ${READLINE_INCLUDE_DIR}")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(READLINE_FOUND FALSE)
|
||||||
|
if (READLINE_FIND_REQUIRED)
|
||||||
|
message(FATAL_ERROR "Could not find Readline")
|
||||||
|
elseif (NOT READLINE_FIND_QUIETLY)
|
||||||
|
message(STATUS "Could not find Readline")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
mark_as_advanced(READLINE_LIBRARY READLINE_INCLUDE_DIR)
|
||||||
|
endif()
|
@ -12,6 +12,8 @@
|
|||||||
#include "query/exceptions.hpp"
|
#include "query/exceptions.hpp"
|
||||||
#include "query/interpreter.hpp"
|
#include "query/interpreter.hpp"
|
||||||
|
|
||||||
|
#ifdef HAS_READLINE
|
||||||
|
|
||||||
#include "readline/history.h"
|
#include "readline/history.h"
|
||||||
#include "readline/readline.h"
|
#include "readline/readline.h"
|
||||||
|
|
||||||
@ -34,6 +36,17 @@ std::string ReadLine(const char *prompt) {
|
|||||||
return r_val;
|
return r_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
std::string ReadLine(const char *prompt) {
|
||||||
|
std::cout << prompt;
|
||||||
|
std::string line;
|
||||||
|
std::getline(std::cin, line);
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // HAS_READLINE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function that outputs a collection of items to
|
* Helper function that outputs a collection of items to
|
||||||
* the given stream, separating them with the given delimiter.
|
* the given stream, separating them with the given delimiter.
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
# find_package(readline REQUIRED)
|
|
||||||
|
# optional readline
|
||||||
|
find_package(Readline)
|
||||||
|
if (READLINE_FOUND)
|
||||||
|
include_directories(SYSTEM ${READLINE_INCLUDE_DIR})
|
||||||
|
add_definitions(-DHAS_READLINE)
|
||||||
|
endif()
|
||||||
|
|
||||||
# set current directory name as a test type
|
# set current directory name as a test type
|
||||||
get_filename_component(test_type ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
get_filename_component(test_type ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
||||||
@ -38,10 +44,12 @@ foreach(test_cpp ${test_type_cpps})
|
|||||||
# yaml parser lib
|
# yaml parser lib
|
||||||
target_link_libraries(${target_name} yaml-cpp)
|
target_link_libraries(${target_name} yaml-cpp)
|
||||||
# antlr
|
# antlr
|
||||||
target_link_libraries(${target_name} antlr_opencypher_parser_lib)
|
target_link_libraries(${target_name} antlr_opencypher_parser_lib)
|
||||||
# dynamic lib
|
# dynamic lib
|
||||||
target_link_libraries(${target_name} dl)
|
target_link_libraries(${target_name} dl)
|
||||||
# readline lib
|
# readline lib
|
||||||
target_link_libraries(${target_name} readline)
|
if (READLINE_FOUND)
|
||||||
|
target_link_libraries(${target_name} ${READLINE_LIBRARY})
|
||||||
|
endif()
|
||||||
|
|
||||||
endforeach()
|
endforeach()
|
||||||
|
Loading…
Reference in New Issue
Block a user