cmake: Add ENABLE_HISTORY option

For enabling history expansion support in the Lua console. Uses GNU
libhistory.
This commit is contained in:
Ignacio R. Morelle 2015-04-13 04:30:57 -03:00
parent 3aa9f2627b
commit cfbeee2f50
3 changed files with 23 additions and 7 deletions

View File

@ -87,7 +87,7 @@ option(ENABLE_PANDORA "Add support for the OpenPandora by adding support for the
option(ENABLE_SDL_GPU "Enable building with SDL_gpu (experimental)" OFF)
option(ENABLE_LIBPNG "Enable support for writing png files (screenshots, images)" ON)
option(ENABLE_LIBINTL "Enable using libintl for translations instead of Boost.Locale library (not recommended)" OFF)
#option(ENABLE_HISTORY "Enable using GNU history for history in lua console" ON) -- This feature is not supported in cmake yet, there is no cmake script to find the lib
option(ENABLE_HISTORY "Enable using GNU history for history in lua console" ON)
# if no build type is specified, it can happen that the game is built without
# optimization (c.f. bug #23445), work around this by enforcing "release" type
@ -608,12 +608,12 @@ if(ENABLE_GAME)
message("Could not find lib PNG. Disabling support for writing PNG images.")
endif(ENABLE_LIBPNG AND PNG_FOUND)
#find_package( HISTORY )
#if(ENABLE_HISTORY AND HISTORY_FOUND)
# add_definitions(-DHAVE_HISTORY)
#else(ENABLE_HISTORY AND HISTORY_FOUND)
# message("Could not find GNU history. Disabling support for command history in lua console.")
#endif(ENABLE_HISTORY AND HISTORY_FOUND)
find_package( History )
if(ENABLE_HISTORY AND HISTORY_FOUND)
add_definitions(-DHAVE_HISTORY)
else(ENABLE_HISTORY AND HISTORY_FOUND)
message("Could not find GNU history. Disabling support for command history in lua console.")
endif(ENABLE_HISTORY AND HISTORY_FOUND)
endif(ENABLE_GAME)
if(ENABLE_GAME OR ENABLE_SERVER)

9
cmake/FindHistory.cmake Normal file
View File

@ -0,0 +1,9 @@
# Locale GNU history library
find_path(HISTORY_INCLUDE_DIR readline/history.h)
find_library(HISTORY_LIBRARY history)
# handle the QUIETLY and REQUIRED arguments and set XXX_FOUND to TRUE if all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(HISTORY DEFAULT_MSG HISTORY_LIBRARY HISTORY_INCLUDE_DIR)

View File

@ -126,6 +126,13 @@ if(ENABLE_LIBPNG AND PNG_FOUND)
)
endif(ENABLE_LIBPNG AND PNG_FOUND)
if(ENABLE_HISTORY AND HISTORY_FOUND)
set(game-external-libs
${game-external-libs}
${HISTORY_LIBRARY}
)
endif(ENABLE_HISTORY AND HISTORY_FOUND)
set(game-external-libs
${game-external-libs}
${VORBISFILE_LIBRARIES}