Cleanup support for std::regex with autotools

Do not link against system boost regex lib or build included boost regex when not needed.
This commit is contained in:
Jean-Marc Lasgouttes 2015-01-06 13:53:18 +01:00
parent dd2a8b616e
commit 41405babc5
5 changed files with 56 additions and 19 deletions

View File

@ -24,16 +24,35 @@ AM_CPPFLAGS += $(BOOST_INCLUDES)
if MONOLITHIC_BOOST if MONOLITHIC_BOOST
if LYX_USE_STD_REGEX
liblyxboost_a_SOURCES = \
lyxboostsignals.cpp
else
liblyxboost_a_SOURCES = \ liblyxboost_a_SOURCES = \
lyxboost.cpp \ lyxboost.cpp \
libs/regex/src/instances.cpp \ libs/regex/src/instances.cpp \
libs/regex/src/cpp_regex_traits.cpp \ libs/regex/src/cpp_regex_traits.cpp \
libs/regex/src/c_regex_traits.cpp libs/regex/src/c_regex_traits.cpp
endif #LYX_USE_STD_REGEX
else
if LYX_USE_STD_REGEX
liblyxboost_a_SOURCES = \
libs/signals/src/connection.cpp \
libs/signals/src/named_slot_map.cpp \
libs/signals/src/signal_base.cpp \
libs/signals/src/slot.cpp \
libs/signals/src/trackable.cpp
else else
liblyxboost_a_SOURCES = \ liblyxboost_a_SOURCES = \
\
libs/regex/src/internals.hpp \ libs/regex/src/internals.hpp \
libs/regex/src/c_regex_traits.cpp \ libs/regex/src/c_regex_traits.cpp \
libs/regex/src/cpp_regex_traits.cpp \ libs/regex/src/cpp_regex_traits.cpp \
@ -55,4 +74,7 @@ liblyxboost_a_SOURCES = \
libs/signals/src/slot.cpp \ libs/signals/src/slot.cpp \
libs/signals/src/trackable.cpp libs/signals/src/trackable.cpp
endif endif #LYX_USE_STD_REGEX
endif #MONOLITHIC_BOOST

View File

@ -12,9 +12,4 @@
#include "libs/regex/src/regex_debug.cpp" #include "libs/regex/src/regex_debug.cpp"
#include "libs/regex/src/winstances.cpp" #include "libs/regex/src/winstances.cpp"
#include "libs/signals/src/connection.cpp" #include "lyxboostsignals.cpp"
#include "libs/signals/src/named_slot_map.cpp"
#include "libs/signals/src/signal_base.cpp"
#include "libs/signals/src/slot.cpp"
#include "libs/signals/src/trackable.cpp"

View File

@ -0,0 +1,6 @@
#include "libs/signals/src/connection.cpp"
#include "libs/signals/src/named_slot_map.cpp"
#include "libs/signals/src/signal_base.cpp"
#include "libs/signals/src/slot.cpp"
#include "libs/signals/src/trackable.cpp"

View File

@ -354,11 +354,30 @@ if test x$GXX = xyes; then
lyx_flags="$lyx_flags c++11-mode" lyx_flags="$lyx_flags c++11-mode"
CXXFLAGS="-std=gnu++0x $CXXFLAGS" CXXFLAGS="-std=gnu++0x $CXXFLAGS"
;; ;;
4.7*|4.8*) 4.7*|4.8*|4.9*)
lyx_flags="$lyx_flags c++11-mode" lyx_flags="$lyx_flags c++11-mode"
CXXFLAGS="-std=gnu++11 $CXXFLAGS" CXXFLAGS="-std=gnu++11 $CXXFLAGS"
;; ;;
esac esac
lyx_std_regex=no
if test x$CLANG = xno || test $lyx_cv_lib_stdcxx = yes; then
dnl <regex> in gcc is unusable in versions less than 4.9.0
dnl see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631
case $gxx_version in
4.9*)
lyx_flags="$lyx_flags stdregex"
lyx_std_regex=yes
;;
esac
else
lyx_flags="$lyx_flags stdregex"
lyx_std_regex=yes
fi
if test $lyx_std_regex = yes ; then
AC_DEFINE([LYX_USE_STD_REGEX], 1, [define to 1 if std::regex should be preferred to boost::regex])
fi
AM_CONDITIONAL([LYX_USE_STD_REGEX], test $lyx_std_regex = yes)
fi fi
fi fi
test "$lyx_pch_comp" = yes && lyx_flags="$lyx_flags pch" test "$lyx_pch_comp" = yes && lyx_flags="$lyx_flags pch"
@ -404,7 +423,11 @@ AC_DEFUN([LYX_USE_INCLUDED_BOOST],[
LIBS=$save_LIBS LIBS=$save_LIBS
AC_LANG_POP(C++) AC_LANG_POP(C++)
BOOST_INCLUDES= BOOST_INCLUDES=
BOOST_LIBS="-lboost_regex${BOOST_MT} -lboost_signals${BOOST_MT}" if test $lyx_std_regex = yes ; then
BOOST_LIBS="-lboost_signals${BOOST_MT}"
else
BOOST_LIBS="-lboost_regex${BOOST_MT} -lboost_signals${BOOST_MT}"
fi
fi fi
AC_SUBST(BOOST_INCLUDES) AC_SUBST(BOOST_INCLUDES)
AC_SUBST(BOOST_LIBS) AC_SUBST(BOOST_LIBS)

View File

@ -285,15 +285,6 @@ char * strerror(int n);
#define BOOST_NO_WSTRING 1 #define BOOST_NO_WSTRING 1
#define BOOST_SIGNALS_NO_DEPRECATION_WARNING 1 #define BOOST_SIGNALS_NO_DEPRECATION_WARNING 1
// <regex> in gcc is unusable in versions less than 4.9.0
// see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631
// clang defines __GNUC__ but how do the versions match?
#ifndef LYX_USE_STD_REGEX
# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 9) || __GNUC__ > 4 || defined(USE_LLVM_LIBCPP)
# define LYX_USE_STD_REGEX
# endif
#endif
#ifdef __CYGWIN__ #ifdef __CYGWIN__
# define NOMINMAX # define NOMINMAX
# define BOOST_POSIX 1 # define BOOST_POSIX 1