commit 3c2d3caf278bf8b0c708845aec1ec8f00424392e
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Tue Feb 16 15:31:08 2016 +0100
Do not add -std=c++11 to CPPFLAGS (because objc does not like it)
Since at least gcc 4.6 requires it, -std=c++11 has been passed to CPPFLAGS
at 39717adfd. This was deemed necessary so that tests that use the preprocessor
directly (AC_CHECK_HEADER) can have the right information.
It turns out that CPPFLAGS gets passed to objc compilation too (on Mac OS
X) and this create compile-time errors.
Therefore we remove the -std flag from CPPFLAGS and re-add it to a separate
variable cxx11_flags that is passed to LYX_CXX_USE_REGEX.
diff --git a/config/lyxinclude.m4 b/config/lyxinclude.m4
index 81e91ca..8decd37 100644
--- a/config/lyxinclude.m4
+++ b/config/lyxinclude.m4
@@ -168,13 +168,19 @@ AC_DEFUN([LYX_CXX_CXX11],
lyx_use_cxx11=$lyx_cv_cxx_cxx11
])
+
+dnl Usage: LYX_CXX_USE_REGEX(cxx11_flags)
dnl decide whether we want to use std::regex and set the
dnl LYX_USE_STD_REGEX accordingly.
+dnl the extra cxx11 flags have to be passed to the preprocessor. They are
+dnl not plainly added to AM_CPPFLAGS because then the objc compiler (mac)
+dnl would fail.
AC_DEFUN([LYX_CXX_USE_REGEX],
[lyx_std_regex=no
if test $lyx_use_cxx11 = yes; then
save_CPPFLAGS=$CPPFLAGS
- CPPFLAGS="$AM_CPPFLAGS $CPPFLAGS"
+ # we want to pass -std=c++11 to clang/cpp if necessary
+ CPPFLAGS="$AM_CPPFLAGS $1 $CPPFLAGS"
save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
AC_LANG_PUSH(C++)
@@ -362,17 +368,20 @@ if test x$GXX = xyes; then
4.3*|4.4*|4.5*|4.6*)
dnl Note that this will define __GXX_EXPERIMENTAL_CXX0X__.
dnl The source code relies on that.
- AM_CPPFLAGS="$AM_CPPFLAGS -std=c++0x";;
+ cxx11_flags="-std=c++0x";;
clang)
dnl presumably all clang versions support c++11.
dnl the deprecated-register warning is very annoying with Qt4.x right
now.
- AM_CPPFLAGS="$AM_CPPFLAGS -std=c++11"
+ cxx11_flags="-std=c++11"
AM_CXXFLAGS="$AM_CXXFLAGS -Wno-deprecated-register";;
*)
AS_CASE([$host], [*cygwin*],
- [AM_CPPFLAGS="$AM_CPPFLAGS -std=gnu++11"],
- [AM_CPPFLAGS="$AM_CPPFLAGS -std=c++11"]);;
+ [cxx11_flags="-std=gnu++11"],
+ [cxx11_flags="-std=c++11"]);;
esac
+ # cxx11_flags is useful when running preprocessor alone
+ # (see detection of regex).
+ AM_CXXFLAGS="$cxx11_flags $AM_CXXFLAGS"
fi
fi
@@ -383,7 +392,7 @@ if test $lyx_use_cxx11 = yes; then
AM_CXXFLAGS="$AM_CXXFLAGS -Wno-deprecated-declarations"
fi
fi
-LYX_CXX_USE_REGEX
+LYX_CXX_USE_REGEX([$cxx11_flags])
])
dnl Usage: LYX_USE_INCLUDED_BOOST : select if the included boost should