mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 04:22:27 +01:00
some refactoring around readline/libedit
(handle dependent options, allow user with change WITH_READLINE to WITH_LIBEDIT and other way around after the first compile)
This commit is contained in:
parent
87513992ed
commit
10c0917897
1 changed files with 41 additions and 32 deletions
|
@ -13,16 +13,6 @@
|
|||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
MACRO(SET_WITH_BUNDLED_READLINE option)
|
||||
IF(option)
|
||||
SET(not_option OFF)
|
||||
ELSE()
|
||||
SET(not_option ON)
|
||||
ENDIF()
|
||||
SET(WITH_READLINE ${option} CACHE BOOL "Use bundled readline")
|
||||
SET(WITH_LIBEDIT ${not_option} CACHE BOOL "Use bundled libedit")
|
||||
ENDMACRO()
|
||||
|
||||
MACRO (MYSQL_CHECK_MULTIBYTE)
|
||||
CHECK_INCLUDE_FILE(wctype.h HAVE_WCTYPE_H)
|
||||
CHECK_INCLUDE_FILE(wchar.h HAVE_WCHAR_H)
|
||||
|
@ -119,8 +109,9 @@ MACRO (FIND_CURSES)
|
|||
ENDMACRO()
|
||||
|
||||
MACRO (MYSQL_USE_BUNDLED_READLINE)
|
||||
SET_WITH_BUNDLED_READLINE(ON)
|
||||
SET(USE_NEW_READLINE_INTERFACE 1)
|
||||
SET(HAVE_HIST_ENTRY)
|
||||
SET(USE_LIBEDIT_INTERFACE)
|
||||
SET(READLINE_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/cmd-line-utils)
|
||||
SET(READLINE_LIBRARY readline)
|
||||
FIND_CURSES()
|
||||
|
@ -128,26 +119,27 @@ MACRO (MYSQL_USE_BUNDLED_READLINE)
|
|||
ENDMACRO()
|
||||
|
||||
MACRO (MYSQL_USE_BUNDLED_LIBEDIT)
|
||||
SET_WITH_BUNDLED_READLINE(OFF)
|
||||
SET(USE_LIBEDIT_INTERFACE 1 CACHE INTERNAL "")
|
||||
SET(HAVE_HIST_ENTRY 1 CACHE INTERNAL "")
|
||||
SET(READLINE_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/cmd-line-utils/libedit")
|
||||
SET(USE_LIBEDIT_INTERFACE 1)
|
||||
SET(HAVE_HIST_ENTRY 1)
|
||||
SET(READLINE_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/cmd-line-utils/libedit)
|
||||
SET(READLINE_LIBRARY edit)
|
||||
FIND_CURSES()
|
||||
ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/cmd-line-utils/libedit)
|
||||
ENDMACRO()
|
||||
|
||||
|
||||
MACRO (MYSQL_FIND_SYSTEM_READLINE name)
|
||||
FIND_PATH(SYSTEM_READLINE_INCLUDE_DIR readline/readline.h )
|
||||
FIND_LIBRARY(SYSTEM_READLINE_LIBRARY NAMES ${name})
|
||||
MARK_AS_ADVANCED(SYSTEM_READLINE_INCLUDE_DIR SYSTEM_READLINE_LIBRARY)
|
||||
|
||||
FIND_PATH(${name}_INCLUDE_DIR readline/readline.h )
|
||||
FIND_LIBRARY(${name}_LIBRARY NAMES ${name})
|
||||
MARK_AS_ADVANCED(${name}_INCLUDE_DIR ${name}_LIBRARY)
|
||||
|
||||
INCLUDE(CheckCXXSourceCompiles)
|
||||
SET(CMAKE_REQUIRES_LIBRARIES ${SYSTEM_READLINE_LIBRARY})
|
||||
SET(CMAKE_REQUIRES_LIBRARIES ${${name}_LIBRARY})
|
||||
|
||||
IF(SYSTEM_READLINE_LIBRARY AND SYSTEM_READLINE_INCLUDE_DIR)
|
||||
IF(${name}_LIBRARY AND ${name}_INCLUDE_DIR)
|
||||
SET(SYSTEM_READLINE_FOUND 1)
|
||||
SET(CMAKE_REQUIRED_LIBRARIES ${SYSTEM_READLINE_LIBRARY})
|
||||
SET(CMAKE_REQUIRED_LIBRARIES ${${name}_LIBRARY})
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
#include <stdio.h>
|
||||
#include <readline/readline.h>
|
||||
|
@ -156,8 +148,8 @@ MACRO (MYSQL_FIND_SYSTEM_READLINE name)
|
|||
HIST_ENTRY entry;
|
||||
return 0;
|
||||
}"
|
||||
HAVE_HIST_ENTRY)
|
||||
|
||||
${name}_HAVE_HIST_ENTRY)
|
||||
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
#include <stdio.h>
|
||||
#include <readline/readline.h>
|
||||
|
@ -166,7 +158,7 @@ MACRO (MYSQL_FIND_SYSTEM_READLINE name)
|
|||
char res= *(*rl_completion_entry_function)(0,0);
|
||||
completion_matches(0,0);
|
||||
}"
|
||||
USE_LIBEDIT_INTERFACE)
|
||||
${name}_USE_LIBEDIT_INTERFACE)
|
||||
|
||||
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
|
@ -177,31 +169,48 @@ MACRO (MYSQL_FIND_SYSTEM_READLINE name)
|
|||
rl_completion_func_t *func1= (rl_completion_func_t*)0;
|
||||
rl_compentry_func_t *func2= (rl_compentry_func_t*)0;
|
||||
}"
|
||||
USE_NEW_READLINE_INTERFACE)
|
||||
${name}_USE_NEW_READLINE_INTERFACE)
|
||||
|
||||
IF(USE_LIBEDIT_INTERFACE OR USE_NEW_READLINE_INTERFACE)
|
||||
SET(READLINE_LIBRARY ${SYSTEM_READLINE_LIBRARY})
|
||||
SET(READLINE_INCLUDE_DIR ${SYSTEM_READLINE_INCLUDE_DIR})
|
||||
IF(${name}_USE_LIBEDIT_INTERFACE OR ${name}_USE_NEW_READLINE_INTERFACE)
|
||||
SET(READLINE_LIBRARY ${${name}_LIBRARY})
|
||||
SET(READLINE_INCLUDE_DIR ${${name}_INCLUDE_DIR})
|
||||
SET(HAVE_HIST_ENTRY ${${name}_HAVE_HIST_ENTRY})
|
||||
SET(USE_LIBEDIT_INTERFACE ${${name}_USE_LIBEDIT_INTERFACE})
|
||||
SET(USE_NEW_READLINE_INTERFACE ${${name}_USE_NEW_READLINE_INTERFACE})
|
||||
SET(READLINE_FOUND 1)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDMACRO()
|
||||
|
||||
|
||||
MACRO (MYSQL_CHECK_READLINE)
|
||||
IF (NOT WIN32)
|
||||
MYSQL_CHECK_MULTIBYTE()
|
||||
OPTION(WITH_READLINE "Use bundled readline" OFF)
|
||||
IF(NOT CYGWIN)
|
||||
# Bundled libedit does not compile on cygwin
|
||||
OPTION(WITH_LIBEDIT "Use bundled libedit" ON)
|
||||
SET(WITH_LIBEDIT ON CACHE BOOL "Use bundled libedit")
|
||||
SET(WITH_READLINE OFF CACHE BOOL "Use bundled readline")
|
||||
ELSE()
|
||||
OPTION(WITH_LIBEDIT "Use bundled libedit" OFF)
|
||||
# Bundled libedit does not compile on cygwin, only readline
|
||||
SET(WITH_READLINE OFF CACHE BOOL "Use bundled readline")
|
||||
ENDIF()
|
||||
|
||||
# Handle mutual exclusion of WITH_READLINE/WITH_LIBEDIT variables
|
||||
# We save current setting to recognize when user switched between
|
||||
# WITH_READLINE and WITH_LIBEDIT
|
||||
IF(WITH_READLINE AND SAVE_READLINE_SETTING MATCHES "WITH_LIBEDIT"
|
||||
OR NOT SAVE_READLINE_SETTING )
|
||||
SET(WITH_LIBEDIT OFF CACHE BOOL "Use bundled libedit" FORCE)
|
||||
ELSEIF(WITH_LIBEDIT AND SAVE_READLINE_SETTING MATCHES "WITH_READLINE"
|
||||
OR NOT SAVE_READLINE_SETTING )
|
||||
SET(WITH_READLINE OFF CACHE BOOL "Use bundled readline" FORCE)
|
||||
ENDIF()
|
||||
|
||||
IF(WITH_READLINE)
|
||||
MYSQL_USE_BUNDLED_READLINE()
|
||||
SET(SAVE_READLINE_SETTING WITH_READLINE CACHE INTERNAL "" FORCE)
|
||||
ELSEIF(WITH_LIBEDIT)
|
||||
MYSQL_USE_BUNDLED_LIBEDIT()
|
||||
SET(SAVE_READLINE_SETTING WITH_LIBEDIT CACHE INTERNAL "" FORCE)
|
||||
ELSE()
|
||||
MYSQL_FIND_SYSTEM_READLINE(readline)
|
||||
IF(NOT READLINE_FOUND)
|
||||
|
|
Loading…
Reference in a new issue