forked from github/server
add a Readline module, fix detection, keep disabled for now
This commit is contained in:
parent
a286cb45f1
commit
51fb719bb6
5 changed files with 59 additions and 5 deletions
|
@ -38,6 +38,8 @@ else (MSVC)
|
||||||
find_package (Curses)
|
find_package (Curses)
|
||||||
endif (MSVC)
|
endif (MSVC)
|
||||||
|
|
||||||
|
find_package (Readline)
|
||||||
|
|
||||||
if (ERESSEA_DB STREQUAL "db")
|
if (ERESSEA_DB STREQUAL "db")
|
||||||
find_package (BerkeleyDB REQUIRED QUIET)
|
find_package (BerkeleyDB REQUIRED QUIET)
|
||||||
else()
|
else()
|
||||||
|
|
47
cmake/Modules/FindReadline.cmake
Normal file
47
cmake/Modules/FindReadline.cmake
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
# - Try to find readline include dirs and libraries
|
||||||
|
#
|
||||||
|
# Usage of this module as follows:
|
||||||
|
#
|
||||||
|
# find_package(Readline)
|
||||||
|
#
|
||||||
|
# Variables used by this module, they can change the default behaviour and need
|
||||||
|
# to be set before calling find_package:
|
||||||
|
#
|
||||||
|
# READLINE_ROOT_DIR Set this variable to the root installation of
|
||||||
|
# readline if the module has problems finding the
|
||||||
|
# proper installation path.
|
||||||
|
#
|
||||||
|
# Variables defined by this module:
|
||||||
|
#
|
||||||
|
# READLINE_FOUND System has readline, include and lib dirs found
|
||||||
|
# READLINE_INCLUDE_DIR The readline include directories.
|
||||||
|
# READLINE_LIBRARY The readline library.
|
||||||
|
|
||||||
|
find_path(READLINE_ROOT_DIR
|
||||||
|
NAMES include/readline/readline.h
|
||||||
|
)
|
||||||
|
|
||||||
|
find_path(READLINE_INCLUDE_DIR
|
||||||
|
NAMES readline/readline.h
|
||||||
|
HINTS ${READLINE_ROOT_DIR}/include
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(READLINE_LIBRARY
|
||||||
|
NAMES readline
|
||||||
|
HINTS ${READLINE_ROOT_DIR}/lib
|
||||||
|
)
|
||||||
|
|
||||||
|
if(READLINE_INCLUDE_DIR AND READLINE_LIBRARY AND Ncurses_LIBRARY)
|
||||||
|
set(READLINE_FOUND TRUE)
|
||||||
|
else(READLINE_INCLUDE_DIR AND READLINE_LIBRARY AND Ncurses_LIBRARY)
|
||||||
|
FIND_LIBRARY(READLINE_LIBRARY NAMES readline)
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Readline DEFAULT_MSG READLINE_INCLUDE_DIR READLINE_LIBRARY )
|
||||||
|
MARK_AS_ADVANCED(READLINE_INCLUDE_DIR READLINE_LIBRARY)
|
||||||
|
endif(READLINE_INCLUDE_DIR AND READLINE_LIBRARY AND Ncurses_LIBRARY)
|
||||||
|
|
||||||
|
mark_as_advanced(
|
||||||
|
READLINE_ROOT_DIR
|
||||||
|
READLINE_INCLUDE_DIR
|
||||||
|
READLINE_LIBRARY
|
||||||
|
)
|
|
@ -295,6 +295,12 @@ target_link_libraries(test_eressea ${DB_LIBRARIES})
|
||||||
add_definitions(-DUSE_DB)
|
add_definitions(-DUSE_DB)
|
||||||
endif(SQLITE3_FOUND)
|
endif(SQLITE3_FOUND)
|
||||||
|
|
||||||
|
if (READLINE_FOUND)
|
||||||
|
include_directories (${READLINE_INCLUDE_DIR})
|
||||||
|
target_link_libraries(eressea ${READLINE_LIBRARY})
|
||||||
|
add_definitions(-DUSE_READLINE)
|
||||||
|
endif (READLINE_FOUND)
|
||||||
|
|
||||||
if (CURSES_FOUND)
|
if (CURSES_FOUND)
|
||||||
include_directories (${CURSES_INCLUDE_DIR})
|
include_directories (${CURSES_INCLUDE_DIR})
|
||||||
target_link_libraries(eressea ${CURSES_LIBRARIES})
|
target_link_libraries(eressea ${CURSES_LIBRARIES})
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#define lua_strlen(L, idx) lua_rawlen(L, idx)
|
#define lua_strlen(L, idx) lua_rawlen(L, idx)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(LUA_USE_READLINE)
|
#ifdef LUA_USE_READLINE
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <readline/readline.h>
|
#include <readline/readline.h>
|
||||||
#include <readline/history.h>
|
#include <readline/history.h>
|
||||||
|
@ -58,7 +58,7 @@ static int lua_readline(lua_State * l, char *b, const char *prompt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_readline(readline foo)
|
void set_readline(readline_fun foo)
|
||||||
{
|
{
|
||||||
my_readline = foo;
|
my_readline = foo;
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,6 @@ static int pushline(lua_State * L, int firstline)
|
||||||
lua_pushfstring(L, "return %s", b + 1); /* change it to `return' */
|
lua_pushfstring(L, "return %s", b + 1); /* change it to `return' */
|
||||||
else
|
else
|
||||||
lua_pushstring(L, b);
|
lua_pushstring(L, b);
|
||||||
lua_freeline(L, b);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,8 @@ extern "C" {
|
||||||
extern int lua_console(struct lua_State *L);
|
extern int lua_console(struct lua_State *L);
|
||||||
extern int lua_do(struct lua_State *L);
|
extern int lua_do(struct lua_State *L);
|
||||||
|
|
||||||
typedef int (*readline) (struct lua_State *, char *, size_t, const char *);
|
typedef int (*readline_fun) (struct lua_State *, char *, size_t, const char *);
|
||||||
extern void set_readline(readline foo);
|
extern void set_readline(readline_fun foo);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue