configure: check for system-wide installed jpcre2.hpp & use if new enough

Implements #2929.
This commit is contained in:
Moritz Bunkus 2020-09-30 17:19:02 +02:00
parent dd568f06a1
commit f588ebbe32
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85
6 changed files with 55 additions and 1 deletions

View File

@ -48,6 +48,13 @@
* mkvmerge, mkvinfo, mkvextract, mkvpropedit: Matroska access class: fixed an
invalid memory access under certain data conditions. Found by fuzzying.
## Build system changes
* `configure` now checks for the presence of the a system-wide installed copy
of the JPCRE2 C++ wrapper library for the PCRE2 library and uses that if
it's new enough (at least v10.32.1). If not, the bundled version will be
used as a fallback. Implements #2929.
# Version 50.0.0 "Awakenings" 2020-09-06

View File

@ -128,6 +128,9 @@ These libraries are:
- [fmt](http://fmtlib.net/) — a small, safe and fast formatting
library. Version 3 or later is required.
- [JPCRE2](https://github.com/jpcre2/jpcre2/) — C++ wrapper for the
PCRE2 library. Version 10.32.1 or newer is required.
- [libEBML v1.4.0](http://dl.matroska.org/downloads/libebml/) or later
and [libMatroska v1.6.1](http://dl.matroska.org/downloads/libmatroska/)
or later for low-level access to Matroska files. Instructions on how to

View File

@ -86,6 +86,7 @@ def setup_globals
$manpages << "doc/man/mkvtoolnix-gui.1" if $build_mkvtoolnix_gui
$system_includes = "-I. -Ilib -Ilib/avilib-0.6.10 -Isrc"
$system_includes += " -Ilib/jpcre2" if c?(:JPCRE2_INTERNAL)
$system_includes += " -Ilib/utf8-cpp/source" if c?(:UTF8CPP_INTERNAL)
$system_includes += " -Ilib/pugixml/src" if c?(:PUGIXML_INTERNAL)
$system_libdirs = "-Llib/avilib-0.6.10 -Llib/librmff -Lsrc/common"

View File

@ -15,3 +15,45 @@ fi
AC_SUBST(PCRE2_CFLAGS)
AC_SUBST(PCRE2_LIBS)
dnl
dnl Check for jpcre2
dnl
AC_CACHE_CHECK([for JPCRE2],[ac_cv_jpcre2],[
AC_LANG_PUSH(C++)
ac_save_CXXFLAGS="$CXXFLAGS"
ac_save_LIBS="$LIBS"
CXXFLAGS="$STD_CXX $CXXFLAGS"
LIBS="$LIBS -ljpcre2"
AC_TRY_COMPILE([
#include <jpcre2.hpp>
#if !defined(JPCRE2_VERSION) || (JPCRE2_VERSION < 103201)
#error jpcre2 is too old, need 10.32.1 or later
#endif
],[
using jp = jpcre2::select<char>;
jp::Regex regex{"moo"};
jp::RegexMatch()
.setRegexObject(&regex)
.setSubject("cow")
.match();
],[ac_cv_jpcre2=yes],[ac_cv_jpcre2=no])
CXXFLAGS="$ac_save_CXXFLAGS"
LIBS="$ac_save_LIBS"
AC_LANG_POP
])
if test x"$ac_cv_jpcre2" = xyes; then
JPCRE2_INTERNAL=no
else
AC_MSG_NOTICE([Using the internal version of jpcre2])
JPCRE2_INTERNAL=yes
fi
AC_SUBST(JPCRE2_INTERNAL)

View File

@ -103,6 +103,7 @@ GTEST_TYPE = @GTEST_TYPE@
LDFLAGS_RPATHS = @LDFLAGS_RPATHS@
FLAC_LIBS = @FLAC_LIBS@
ICONV_LIBS = @ICONV_LIBS@
JPCRE2_INTERNAL = @JPCRE2_INTERNAL@
LIBINTL_LIBS = @LIBINTL_LIBS@
LINK_STATICALLY=@LINK_STATICALLY@
LLVM_LLD = @LLVM_LLD@

View File

@ -15,7 +15,7 @@
#include "common/common_pch.h"
#include "jpcre2/jpcre2.hpp"
#include <jpcre2.hpp>
namespace mtx::regex {