From a413d667cae0dfcae585298e6ac4707313cb32e3 Mon Sep 17 00:00:00 2001 From: Kornel Benko Date: Thu, 11 Feb 2016 09:03:07 +0100 Subject: [PATCH] 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. --- CMakeLists.txt | 25 ++++++++++++++++++++++++- development/cmake/scripts/xmingw | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a121f4fcb..43a0345c0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,6 +140,7 @@ LYX_OPTION(ENABLE_EXPORT_TESTS "Enable for export tests" OFF ALL) LYX_OPTION(ASAN "Use address sanitizer" OFF ALL) LYX_COMBO(USE_QT "Use Qt version as frontend" QT4 QT5) 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 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(STDLIB_DEBUG "Use debug stdlib" 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 LYX_OPTION(CONSOLE "Show console on Windows, enforce with =FORCE" ON MSVC) @@ -252,6 +252,29 @@ else() 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) if(UNIX OR MINGW) execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) diff --git a/development/cmake/scripts/xmingw b/development/cmake/scripts/xmingw index f08c1e75a8..b1a859a10c 100755 --- a/development/cmake/scripts/xmingw +++ b/development/cmake/scripts/xmingw @@ -106,7 +106,7 @@ cmake $lyxsrcdir \ -DLYX_XMINGW=$compiler \ -DLYX_USE_QT=QT5 \ -DLYX_QUIET=1 \ - -DLYX_ENABLE_CXX11=1 \ + -DLYX_ENABLE_CXX11=ON \ -DLYX_HUNSPELL=1 \ -DLYX_3RDPARTY_BUILD=1 \ $pch $mergefile