Add option whether to link with libreadline or not

Reviewers: buda, mislav.bradac, mferencevic

Reviewed By: mferencevic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D850
This commit is contained in:
Teon Banek 2017-10-04 14:46:57 +02:00
parent 73052dcff4
commit 1cd83d2c19
5 changed files with 18 additions and 15 deletions

View File

@ -58,10 +58,13 @@ add_custom_target(clean_all
find_package(Threads REQUIRED)
# optional readline
find_package(Readline REQUIRED)
if (READLINE_FOUND)
include_directories(SYSTEM ${READLINE_INCLUDE_DIR})
add_definitions(-DHAS_READLINE)
option(USE_READLINE "Use GNU Readline library if available (default ON). \
Set this to OFF to prevent linking with Readline even if it is available." ON)
if (USE_READLINE)
find_package(Readline)
if (READLINE_FOUND)
add_definitions(-DHAS_READLINE)
endif()
endif()
# -----------------------------------------------------------------------------
@ -265,7 +268,7 @@ set(memgraph_src_files
set(MEMGRAPH_ALL_LIBS stdc++fs Threads::Threads fmt cppitertools
antlr_opencypher_parser_lib dl glog gflags)
if (READLINE_FOUND)
list(APPEND MEMGRAPH_ALL_LIBS ${READLINE_LIBRARY})
list(APPEND MEMGRAPH_ALL_LIBS readline)
endif()
# STATIC library used by memgraph executables

View File

@ -5,6 +5,11 @@
# 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 the library is found, an imported target `readline` will be provided. This
# can be used for linking via `target_link_libraries`, without the need to
# explicitly include READLINE_INCLUDE_DIR and link with READLINE_LIBRARY. For
# example: `target_link_libraries(my_executable readline)`.
if (READLINE_LIBRARY AND READLINE_INCLUDE_DIR)
set(READLINE_FOUND TRUE)
else()
@ -24,4 +29,7 @@ else()
endif()
endif()
mark_as_advanced(READLINE_LIBRARY READLINE_INCLUDE_DIR)
add_library(readline SHARED IMPORTED)
set_property(TARGET readline PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${READLINE_INCLUDE_DIR})
set_property(TARGET readline PROPERTY IMPORTED_LOCATION ${READLINE_LIBRARY})
endif()

View File

@ -1,10 +1,3 @@
# 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
get_filename_component(test_type ${CMAKE_CURRENT_SOURCE_DIR} NAME)

View File

@ -36,9 +36,8 @@ disallow_in_source_build()
find_package(Threads REQUIRED)
# optional readline
find_package(Readline REQUIRED)
find_package(Readline)
if (READLINE_FOUND)
include_directories(SYSTEM ${READLINE_INCLUDE_DIR})
add_definitions(-DHAS_READLINE)
endif()

View File

@ -9,7 +9,7 @@ TIMEOUT=600 ./init
bash -c "doxygen Doxyfile >/dev/null 2>/dev/null"
cd build
cmake -DCMAKE_BUILD_TYPE=release ..
cmake -DCMAKE_BUILD_TYPE=Release -DUSE_READLINE=OFF ..
TIMEOUT=1000 make -j$THREADS
cd ../tools