2017-01-25 20:14:41 +00:00
|
|
|
set (READLINE_PATHS "/usr/local/opt/readline/lib")
|
|
|
|
# First try find custom lib for macos users (default lib without history support)
|
2017-01-27 20:00:02 +00:00
|
|
|
find_library (READLINE_LIB NAMES readline PATHS ${READLINE_PATHS} NO_DEFAULT_PATH)
|
2017-01-25 20:14:41 +00:00
|
|
|
if (NOT READLINE_LIB)
|
2017-01-27 20:00:02 +00:00
|
|
|
find_library (READLINE_LIB NAMES readline PATHS ${READLINE_PATHS})
|
2017-01-25 20:14:41 +00:00
|
|
|
endif ()
|
2017-01-17 21:00:23 +00:00
|
|
|
|
2017-01-30 13:40:04 +00:00
|
|
|
list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .so.2)
|
2017-01-17 21:00:23 +00:00
|
|
|
|
2017-01-30 13:40:04 +00:00
|
|
|
find_library (TERMCAP_LIB NAMES termcap)
|
2017-01-27 20:00:02 +00:00
|
|
|
find_library (EDIT_LIB NAMES edit)
|
2017-01-17 21:00:23 +00:00
|
|
|
|
2017-01-25 20:14:41 +00:00
|
|
|
set(READLINE_INCLUDE_PATHS "/usr/local/opt/readline/include")
|
2017-01-30 13:40:04 +00:00
|
|
|
if (READLINE_LIB AND TERMCAP_LIB)
|
2017-01-25 20:14:41 +00:00
|
|
|
find_path (READLINE_INCLUDE_DIR NAMES readline/readline.h PATHS ${READLINE_INCLUDE_PATHS} NO_DEFAULT_PATH)
|
|
|
|
if (NOT READLINE_INCLUDE_DIR)
|
2017-01-24 21:07:08 +00:00
|
|
|
find_path (READLINE_INCLUDE_DIR NAMES readline/readline.h PATHS ${READLINE_INCLUDE_PATHS})
|
2017-01-17 21:00:23 +00:00
|
|
|
endif ()
|
2017-01-25 20:14:41 +00:00
|
|
|
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)
|
2017-01-27 20:00:02 +00:00
|
|
|
find_library (CURSES_LIB NAMES curses)
|
2017-01-25 20:14:41 +00:00
|
|
|
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}")
|
|
|
|
else ()
|
|
|
|
message (STATUS "Not using any library for line editing.")
|
2017-01-17 21:00:23 +00:00
|
|
|
endif ()
|
2017-01-25 20:14:41 +00:00
|
|
|
if (READLINE_INCLUDE_DIR)
|
|
|
|
include_directories (${READLINE_INCLUDE_DIR})
|
|
|
|
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);
|
2017-01-30 13:40:04 +00:00
|
|
|
return 0;
|
2017-01-25 20:14:41 +00:00
|
|
|
}
|
|
|
|
" HAVE_READLINE_HISTORY)
|