Set C++11 option defaulting to 'AUTO' as it is on autotools too.

Nothing changes for already cached values.
With fresh build-dir and in 'AUTO'-mode we try to determine if the c++ compiler
is able to use this feature.
This commit is contained in:
Kornel Benko 2016-02-11 09:03:07 +01:00
parent 53d911b35d
commit a413d667ca
2 changed files with 25 additions and 2 deletions

View File

@ -140,6 +140,7 @@ LYX_OPTION(ENABLE_EXPORT_TESTS "Enable for export tests" OFF ALL)
LYX_OPTION(ASAN "Use address sanitizer" OFF ALL) LYX_OPTION(ASAN "Use address sanitizer" OFF ALL)
LYX_COMBO(USE_QT "Use Qt version as frontend" QT4 QT5) LYX_COMBO(USE_QT "Use Qt version as frontend" QT4 QT5)
LYX_OPTION(3RDPARTY_BUILD "Build 3rdparty libs" OFF ALL) LYX_OPTION(3RDPARTY_BUILD "Build 3rdparty libs" OFF ALL)
LYX_COMBO(ENABLE_CXX11 "Build with options for c++11-mode" AUTO ON OFF)
# GCC specific # GCC specific
LYX_OPTION(PROFILE "Build profile version" OFF GCC) LYX_OPTION(PROFILE "Build profile version" OFF GCC)
@ -149,7 +150,6 @@ LYX_OPTION(DEBUG_GLIBC "Enable libstdc++ debug mode" OFF GCC)
LYX_OPTION(DEBUG_GLIBC_PEDANTIC "Enable libstdc++ pedantic debug mode" OFF GCC) LYX_OPTION(DEBUG_GLIBC_PEDANTIC "Enable libstdc++ pedantic debug mode" OFF GCC)
LYX_OPTION(STDLIB_DEBUG "Use debug stdlib" OFF GCC) LYX_OPTION(STDLIB_DEBUG "Use debug stdlib" OFF GCC)
LYX_OPTION(PROFILE "Build with options for gprof" OFF GCC) LYX_OPTION(PROFILE "Build with options for gprof" OFF GCC)
LYX_OPTION(ENABLE_CXX11 "Build with options for c++11-mode" OFF GCC)
# MSVC specific # MSVC specific
LYX_OPTION(CONSOLE "Show console on Windows, enforce with =FORCE" ON MSVC) LYX_OPTION(CONSOLE "Show console on Windows, enforce with =FORCE" ON MSVC)
@ -252,6 +252,29 @@ else()
endif() endif()
if(LYX_ENABLE_CXX11 MATCHES "AUTO")
# Set to some meaningful default
find_package(CXX11Compiler)
if(NOT CXX11COMPILER_FOUND)
set(LYX_ENABLE_CXX11 OFF CACHE TYPE STRING FORCE)
else()
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT GCC_VERSION VERSION_LESS 4.3)
set(LYX_ENABLE_CXX11 ON CACHE TYPE STRING FORCE)
else()
set(LYX_ENABLE_CXX11 OFF CACHE TYPE STRING FORCE)
endif()
else()
# Not a gnu compiler
if(CMAKE_CXX_COMPILER_ID MATCHES "^[cC]lang$")
set(LYX_ENABLE_CXX11 ON CACHE TYPE STRING FORCE)
else()
set(LYX_ENABLE_CXX11 OFF CACHE TYPE STRING FORCE)
endif()
endif()
endif()
endif()
set(LYX_GCC11_MODE) set(LYX_GCC11_MODE)
if(UNIX OR MINGW) if(UNIX OR MINGW)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)

View File

@ -106,7 +106,7 @@ cmake $lyxsrcdir \
-DLYX_XMINGW=$compiler \ -DLYX_XMINGW=$compiler \
-DLYX_USE_QT=QT5 \ -DLYX_USE_QT=QT5 \
-DLYX_QUIET=1 \ -DLYX_QUIET=1 \
-DLYX_ENABLE_CXX11=1 \ -DLYX_ENABLE_CXX11=ON \
-DLYX_HUNSPELL=1 \ -DLYX_HUNSPELL=1 \
-DLYX_3RDPARTY_BUILD=1 \ -DLYX_3RDPARTY_BUILD=1 \
$pch $mergefile $pch $mergefile