Le 27/08/2015 22:00, Georg Baum a écrit :
We can at least turn c++11 on automatically for "non-weird" compilers (and I
think we should do it).

The following patch (on top of the previous one) does this. OK?

JMarc



>From 28cbe60e390afccaf38ff275825aa22d20dfb51a Mon Sep 17 00:00:00 2001
From: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date: Mon, 31 Aug 2015 18:17:35 +0200
Subject: [PATCH] Use C++11 automatically when possible

Update INSTALL file accordingly and clean it a little bit.
---
 INSTALL              |   10 ++++------
 config/lyxinclude.m4 |   25 ++++++++++++++++---------
 2 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/INSTALL b/INSTALL
index cc056ef..6b75fac 100644
--- a/INSTALL
+++ b/INSTALL
@@ -113,7 +113,7 @@ flags:
     debug                            X           X           X       X
 
     The defaults are as follows in terms of version number
-    release: stable release (1.x.y)
+    release: stable release (2.x.y)
     prerelease: version number contains alpha, beta, rc or pre.
     development: version number contains dev.
 
@@ -209,6 +209,9 @@ The following options allow you to tweak the generated code more precisely (see
     optimization of LyX. The compile may be much quicker with some
     compilers, but LyX will run more slowly.
 
+  o --disable-cxx11 forces the compiler in C++98 mode. The default is
+    to use C++11 mode for known good compilers.
+
   o --enable-debug will add debug information to your binary. This
     requires a lot more disk space, but is a must if you want to try
     to debug problems in LyX. There is no run-time penalty.
@@ -227,11 +230,6 @@ The following options allow you to tweak the generated code more precisely (see
   o --enable-concept-checks adds some compile-time checks. There is no
     run-time penalty.
 
-  o --without-latex-config that disables the automatic detection of your
-    latex configuration.  This detection is automatically disabled if
-    latex cannot be found.  If you find that you have to use this
-    flag, please report it as a bug.
-
   o --enable-monolithic-build[=boost,client,insets,mathed,core,tex2lyx,frontend-qt4]
     that enables monolithic build of the given parts of the source
     code. This should reduce the compilation time provided you have
diff --git a/config/lyxinclude.m4 b/config/lyxinclude.m4
index db4709a..18e2b33 100644
--- a/config/lyxinclude.m4
+++ b/config/lyxinclude.m4
@@ -160,9 +160,10 @@ AC_DEFUN([LYX_LIB_STDCXX],
 
 
 dnl Usage: LYX_CXX_USE_CXX11(STD): pass option -std=STD to the C++ compiler
-dnl        and update lyxflags
+dnl        set lyx_use_cxx11 to "yes" and update lyxflags
 AC_DEFUN([LYX_CXX_USE_CXX11],
 [lyx_flags="$lyx_flags c++11-mode"
+ lyx_use_cxx11=yes
  AM_CXXFLAGS="$AM_CXXFLAGS -std=$1"
 ])
 
@@ -257,8 +258,8 @@ AC_ARG_ENABLE(pch,
 lyx_pch_comp=no
 
 AC_ARG_ENABLE(cxx11,
-  AC_HELP_STRING([--enable-cxx11],[enable C++11 mode]),,
-  enable_cxx11=no;)
+  AC_HELP_STRING([--enable-cxx11],[enable C++11 mode (default: enabled for known good compilers)]),,
+  enable_cxx11=auto;)
 
 AC_ARG_ENABLE(assertions,
   AC_HELP_STRING([--enable-assertions],[add runtime sanity checks in the program]),,
@@ -333,9 +334,14 @@ if test x$GXX = xyes; then
 	;;
     esac
   fi
-  if test x$enable_cxx11 = xyes ; then
+  dnl enable_cxx11 can be yes/no/auto.
+  dnl By default, it is auto and we enable C++11 when possible
+  if test x$enable_cxx11 != xno ; then
     case $gxx_version in
-      4.0*|4.1*|4.2*) AC_ERROR([There is no C++11 support in gcc 4.2 or older]);;
+      4.0*|4.1*|4.2*) 
+         if x$enable_cxx11 = xyes; then
+            AC_ERROR([There is no C++11 support in gcc 4.2 or older])
+         fi;;
       4.3*|4.4*|4.5*|4.6*)
         dnl Note that this will define __GXX_EXPERIMENTAL_CXX0X__.
         dnl The source code relies on that.
@@ -347,21 +353,22 @@ if test x$GXX = xyes; then
       *)
         LYX_CXX_USE_CXX11(c++11);;
     esac
+  fi
+
+  if test -n "$lyx_use_cxx11" ; then
     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.0*|4.1*|4.2*|4.3*|4.4*|4.5*|4.6*|4.7*|4.8*) ;;
-	*) lyx_flags="$lyx_flags stdregex"
-	   lyx_std_regex=yes
-           ;;
+        *) lyx_std_regex=yes ;;
       esac
     else
-      lyx_flags="$lyx_flags stdregex"
       lyx_std_regex=yes
     fi
 
     if test $lyx_std_regex = yes ; then
+      lyx_flags="$lyx_flags stdregex"
       AC_DEFINE([LYX_USE_STD_REGEX], 1, [define to 1 if std::regex should be preferred to boost::regex])
     fi
   fi
-- 
1.7.9.5

Reply via email to