pcre2test: allow using readline headers for libedit (#99)

At least in OpenBSD, there is a libedit library in base, but without
public headers.  Public headers for readline are available but since
15db5d36 (pcre2test: avoid using readline headers with libedit,
2022-04-07) won't be picked up automatically.

Allow pointing cmake to those headers by doing (for example):

  $ cmake -DEDITLINE_INCLUDE_DIR=/usr/include/readline

Or using custom CPPFLAGS with configure (for example):

  $ CPPFLAGS=-I/usr/include/readline ./configure --enable-pcre2test-libedit

Since the headers from readline.h would be otherwise incomplete, detect
that case and pull the extra headers that are required automagically and
while at it, cleanup the NCURSES dependency that was unnecessarily copied
from readline.
This commit is contained in:
Carlo Marcelo Arenas Belón 2022-04-14 08:51:51 -07:00 committed by GitHub
parent 8ff3ab27d5
commit 4279abbd7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 13 deletions

View File

@ -110,6 +110,11 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0)
# GET_TARGET_PROPERTY. This should no longer be required.
# CMAKE_POLICY(SET CMP0026 OLD)
# With a recent cmake, you can provide a rootdir to look for non
# standard installed library dependencies, but to do so, the policy
# needs to be set to new (by uncommenting the following)
# CMAKE_POLICY(SET CMP0074 NEW)
# For FindReadline.cmake. This was changed to allow setting CMAKE_MODULE_PATH
# on the command line.
# SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
@ -312,7 +317,11 @@ IF(EDITLINE_FOUND)
ENDIF(PCRE2_SUPPORT_LIBEDIT)
ELSE(EDITLINE_FOUND)
IF(PCRE2_SUPPORT_LIBEDIT)
MESSAGE(FATAL_ERROR "libedit not found, set Editline_ROOT if needed")
MESSAGE(FATAL_ERROR
" libedit not found, set EDITLINE_INCLUDE_DIR to a compatible header\n"
" or set Editline_ROOT to a full libedit installed tree, as needed\n"
" Might need to enable policy CMP0074 in CMakeLists.txt"
)
ENDIF(PCRE2_SUPPORT_LIBEDIT)
ENDIF(EDITLINE_FOUND)

View File

@ -1,8 +1,8 @@
# Modified from FindReadline.cmake (PH Feb 2012)
if(EDITLINE_INCLUDE_DIR AND EDITLINE_LIBRARY AND NCURSES_LIBRARY)
if(EDITLINE_INCLUDE_DIR AND EDITLINE_LIBRARY)
set(EDITLINE_FOUND TRUE)
else(EDITLINE_INCLUDE_DIR AND EDITLINE_LIBRARY AND NCURSES_LIBRARY)
else(EDITLINE_INCLUDE_DIR AND EDITLINE_LIBRARY)
FIND_PATH(EDITLINE_INCLUDE_DIR readline.h PATH_SUFFIXES
editline
edit/readline
@ -10,7 +10,7 @@ else(EDITLINE_INCLUDE_DIR AND EDITLINE_LIBRARY AND NCURSES_LIBRARY)
FIND_LIBRARY(EDITLINE_LIBRARY NAMES edit)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Editline DEFAULT_MSG EDITLINE_INCLUDE_DIR EDITLINE_LIBRARY )
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Editline DEFAULT_MSG EDITLINE_INCLUDE_DIR EDITLINE_LIBRARY)
MARK_AS_ADVANCED(EDITLINE_INCLUDE_DIR EDITLINE_LIBRARY)
endif(EDITLINE_INCLUDE_DIR AND EDITLINE_LIBRARY AND NCURSES_LIBRARY)
endif(EDITLINE_INCLUDE_DIR AND EDITLINE_LIBRARY)

View File

@ -601,7 +601,7 @@ fi
# headers in different places. Try to cover the most common ones.
if test "$enable_pcre2test_libedit" = "yes"; then
AC_CHECK_HEADERS([editline/readline.h edit/readline/readline.h], [
AC_CHECK_HEADERS([editline/readline.h edit/readline/readline.h readline.h], [
HAVE_LIBEDIT_HEADER=1
break
])
@ -941,8 +941,8 @@ if test "$enable_pcre2test_libedit" = "yes"; then
exit 1
fi
if test -z "$HAVE_LIBEDIT_HEADER"; then
echo "** Cannot --enable-pcre2test-libedit because neither editline/readline.h"
echo "** nor edit/readline/readline.h was found."
echo "** Cannot --enable-pcre2test-libedit because neither editline/readline.h,"
echo "** edit/readline/readline.h nor a compatible header was found."
exit 1
fi
if test -z "$LIBEDIT"; then

View File

@ -110,6 +110,9 @@ type, gbreak or bidi. The defined values for that property are listed. */
#include <editline/readline.h>
#else
#include <readline/readline.h>
#ifdef RL_VERSION_MAJOR
#include <readline/history.h>
#endif
#endif
#endif
#endif

View File

@ -82,11 +82,7 @@ from www.cbttape.org. */
/* #define DEBUG_SHOW_MALLOC_ADDRESSES */
/* Both libreadline and libedit are optionally supported. The user-supplied
original patch uses readline/readline.h for libedit, but in at least one system
it is installed as editline/readline.h, so the configuration code now looks for
that first, falling back to readline/readline.h. */
/* Both libreadline and libedit are optionally supported */
#if defined(SUPPORT_LIBREADLINE) || defined(SUPPORT_LIBEDIT)
#if defined(SUPPORT_LIBREADLINE)
#include <readline/readline.h>
@ -98,6 +94,11 @@ that first, falling back to readline/readline.h. */
#include <edit/readline/readline.h>
#else
#include <readline.h>
/* GNU readline defines this macro but libedit doesn't, if that ever changes
this needs to be updated or the build could break */
#ifdef RL_VERSION_MAJOR
#include <history.h>
#endif
#endif
#endif
#endif