mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Fix readline finding on mac; use config for readline vars (#397)
* Fix readline finding on mac; use config for readline vars * fix
This commit is contained in:
parent
f8d1573946
commit
70e641f58a
@ -1,10 +1,17 @@
|
||||
if (NOT READLINE_PATHS)
|
||||
set (READLINE_PATHS "/usr/local/opt/readline/lib")
|
||||
# First try find custom lib for macos users (default lib without history support)
|
||||
if (USE_STATIC_LIBRARIES)
|
||||
find_library (READLINE_LIB NAMES libreadline.a PATHS ${READLINE_PATHS} NO_DEFAULT_PATH)
|
||||
else ()
|
||||
find_library (READLINE_LIB NAMES readline PATHS ${READLINE_PATHS} NO_DEFAULT_PATH)
|
||||
endif ()
|
||||
if (NOT READLINE_LIB)
|
||||
if (USE_STATIC_LIBRARIES)
|
||||
find_library (READLINE_LIB NAMES libreadline.a PATHS ${READLINE_PATHS})
|
||||
else ()
|
||||
find_library (READLINE_LIB NAMES readline PATHS ${READLINE_PATHS})
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (USE_STATIC_LIBRARIES)
|
||||
find_library (TERMCAP_LIB NAMES libtermcap.a termcap)
|
||||
@ -20,8 +27,11 @@ if (NOT READLINE_PATHS)
|
||||
|
||||
set(READLINE_INCLUDE_PATHS "/usr/local/opt/readline/include")
|
||||
if (READLINE_LIB)
|
||||
find_path (READLINE_INCLUDE_DIR NAMES readline/readline.h PATHS ${READLINE_INCLUDE_PATHS} NO_DEFAULT_PATH)
|
||||
if (NOT READLINE_INCLUDE_DIR)
|
||||
find_path (READLINE_INCLUDE_DIR NAMES readline/readline.h PATHS ${READLINE_INCLUDE_PATHS})
|
||||
add_definitions (-D USE_READLINE)
|
||||
endif ()
|
||||
set (USE_READLINE 1)
|
||||
set (LINE_EDITING_LIBS ${READLINE_LIB} ${TERMCAP_LIB})
|
||||
message (STATUS "Using line editing libraries (readline): ${READLINE_INCLUDE_DIR} : ${LINE_EDITING_LIBS}")
|
||||
elseif (EDIT_LIB)
|
||||
@ -30,7 +40,7 @@ if (NOT READLINE_PATHS)
|
||||
else ()
|
||||
find_library (CURSES_LIB NAMES curses)
|
||||
endif ()
|
||||
add_definitions (-D USE_LIBEDIT)
|
||||
set(USE_LIBEDIT 1)
|
||||
find_path (READLINE_INCLUDE_DIR NAMES editline/readline.h PATHS ${READLINE_INCLUDE_PATHS})
|
||||
set (LINE_EDITING_LIBS ${EDIT_LIB} ${CURSES_LIB} ${TERMCAP_LIB})
|
||||
message (STATUS "Using line editing libraries (edit): ${READLINE_INCLUDE_DIR} : ${LINE_EDITING_LIBS}")
|
||||
@ -41,4 +51,18 @@ if (NOT READLINE_PATHS)
|
||||
include_directories (${READLINE_INCLUDE_DIR})
|
||||
endif ()
|
||||
|
||||
endif ()
|
||||
include (CheckCXXSourceRuns)
|
||||
|
||||
set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${LINE_EDITING_LIBS})
|
||||
check_cxx_source_runs("
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
int main() {
|
||||
add_history(nullptr);
|
||||
append_history(1,nullptr);
|
||||
}
|
||||
" HAVE_READLINE_HISTORY)
|
||||
|
||||
#if (HAVE_READLINE_HISTORY)
|
||||
# add_definitions (-D HAVE_READLINE_HISTORY)
|
||||
#endif ()
|
||||
|
@ -60,6 +60,7 @@
|
||||
|
||||
#include <DB/Common/NetException.h>
|
||||
|
||||
#include <common/config_common.h>
|
||||
|
||||
/// Different line editing libraries can be used depending on the environment.
|
||||
#ifdef USE_READLINE
|
||||
@ -497,7 +498,7 @@ private:
|
||||
std::replace(logged_query.begin(), logged_query.end(), '\n', ' ');
|
||||
add_history(logged_query.c_str());
|
||||
|
||||
#ifdef USE_READLINE
|
||||
#if USE_READLINE && HAVE_READLINE_HISTORY
|
||||
if (!history_file.empty() && append_history(1, history_file.c_str()))
|
||||
throwFromErrno("Cannot append history to file " + history_file, ErrorCodes::CANNOT_APPEND_HISTORY);
|
||||
#endif
|
||||
|
@ -4,3 +4,7 @@
|
||||
|
||||
#cmakedefine01 APPLE_SIERRA_OR_NEWER
|
||||
#cmakedefine01 ENABLE_LIBTCMALLOC
|
||||
|
||||
#cmakedefine01 USE_READLINE
|
||||
#cmakedefine01 USE_LIBEDIT
|
||||
#cmakedefine01 HAVE_READLINE_HISTORY
|
||||
|
Loading…
Reference in New Issue
Block a user