Use C++11 by default when possible

Compiler that are known to support C++11 (gcc >= 4.3 and clang) are
now used in this mode by default. It is still possible to override
this choice using --(en|dis)able-cxx11.

Moreover, c++11 mode is detected from the compiler itself, not from
the use of --enable-cxx11. This allows to support compilers other
than gcc or clang.

Update INSTALL file accordingly and clean it a little bit.
This commit is contained in:
Jean-Marc Lasgouttes 2015-08-31 18:17:35 +02:00
parent 211ac35314
commit 893ae612e4
2 changed files with 52 additions and 36 deletions

29
INSTALL
View File

@ -48,16 +48,18 @@ Requirements
------------
First of all, you will need a recent C++ compiler, where recent means
that the compilers are close to C++ standard conforming (gcc 4.x).
that the compilers are close to C++ standard conforming like gcc (at
least 4.x) or clang. Note that the compiler will be used in C++11 mode
when possible.
LyX makes great use of the C++ Standard Template Library (STL).
This means that gcc users will have to install the relevant libstdc++
library to be able to compile this version of LyX.
For full LyX usability we suggest to use Qt 4.x and at least Qt 4.8 which
For full LyX usability we suggest to use Qt 4.x and at least Qt 4.8 which
has been widely tested. For compilation you need to compile against at
least Qt 4.5.0 and at Windows we advise at highest Qt 4.8.4. The only
special point to make is that you must ensure that both LyX and the
special point to make is that you must ensure that both LyX and the
Qt libraries are compiled with the same C++ compiler.
To build LyX with spell checking capabilities included you have to
@ -69,17 +71,13 @@ libraries. See the RELEASE-NOTES for details.
If you make modifications to the source that affect any of the
translations or you change the translation files themselves (po/*.po)
files, you will need to have the GNU gettext package installed to
files, you will need to have the GNU gettext package installed to
compile LyX with up-to-date translations (at least gettext version
0.16.1 is needed). You can get the latest version from:
ftp://ftp.gnu.org/gnu/gettext/
The two following programs should be available at configuration time:
o LaTeX2e should be correctly setup for the user you are logged in
as. Otherwise, LyX will not be able to run a number of tests. Note
that users can run these tests manually with Tools>Reconfigure.
o Python 2.7 must be installed. Python is used for many simple tasks
that are executed by external scripts, such as the automatic
configuration step and the import of older LyX documents with the
@ -113,7 +111,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 +207,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 +228,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
@ -254,8 +250,9 @@ to strip the lyx binary. In this case replace "make install" with
make install-strip
BTW: in the images subdirectory there is also a small icon "lyx.png",
that can be used to display lyx-documents in filemanagers.
BTW: in the lib/images subdirectory there is also small icons
`lyx.png' and `lyx.svg', that can be used to display LyX documents in
filemanagers.
If configure fails for some strange reason
------------------------------------------

View File

@ -133,7 +133,7 @@ done
])dnl
dnl Usage: LYX_PROG_CLANG: set lyx_cv_prog_clang to yes if the compiler is clang.
dnl Usage: LYX_PROG_CLANG: set CLANG to yes if the compiler is clang.
AC_DEFUN([LYX_PROG_CLANG],
[AC_CACHE_CHECK([whether the compiler is clang],
[lyx_cv_prog_clang],
@ -146,6 +146,26 @@ AC_DEFUN([LYX_PROG_CLANG],
])
dnl Usage: LYX_CXX_CXX11: set lyx_use_cxx11 to yes if the compiler implements
dnl the C++11 standard.
AC_DEFUN([LYX_CXX_CXX11],
[AC_CACHE_CHECK([whether the compiler implements C++11],
[lyx_cv_cxx_cxx11],
[save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
AC_LANG_PUSH(C++)
AC_TRY_COMPILE([], [
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
this is a c++11 compiler
#endif
],
[lyx_cv_cxx_cxx11=no], [lyx_cv_cxx_cxx11=yes ; lyx_flags="$lyx_flags c++11"])
AC_LANG_POP(C++)
CXXFLAGS=$save_CXXFLAGS])
lyx_use_cxx11=$lyx_cv_cxx_cxx11
])
dnl Usage: LYX_LIB_STDCXX: set lyx_cv_lib_stdcxx to yes if the STL library is libstdc++.
AC_DEFUN([LYX_LIB_STDCXX],
[AC_CACHE_CHECK([whether STL is libstdc++],
@ -159,14 +179,6 @@ AC_DEFUN([LYX_LIB_STDCXX],
])
dnl Usage: LYX_CXX_USE_CXX11(STD): pass option -std=STD to the C++ compiler
dnl and update lyxflags
AC_DEFUN([LYX_CXX_USE_CXX11],
[lyx_flags="$lyx_flags c++11"
AM_CXXFLAGS="$AM_CXXFLAGS -std=$1"
])
dnl Usage: LYX_LIB_STDCXX_CXX11_ABI: set lyx_cv_lib_stdcxx_cxx11_abi to yes
dnl if the STL library is GNU libstdc++ and the C++11 ABI is used.
AC_DEFUN([LYX_LIB_STDCXX_CXX11_ABI],
@ -257,8 +269,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,35 +345,42 @@ 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.
LYX_CXX_USE_CXX11(c++0x);;
AM_CXXFLAGS="$AM_CXXFLAGS -std=c++0x";;
clang)
dnl presumably all clang version support c++11.
dnl the deprecated-register warning is very annoying with Qt4.x right now.
LYX_CXX_USE_CXX11(c++11 -Wno-deprecated-register);;
AM_CXXFLAGS="$AM_CXXFLAGS -std=c++11 -Wno-deprecated-register";;
*)
LYX_CXX_USE_CXX11(c++11);;
AM_CXXFLAGS="$AM_CXXFLAGS -std=c++11";;
esac
fi
LYX_CXX_CXX11
if test $lyx_use_cxx11 = yes ; 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