commit 39996524060581c3360c7a582552c98a895232d5
Author: Kornel Benko <kor...@lyx.org>
Date:   Thu Oct 22 18:53:53 2020 +0200

    Amend d954a6b0: use cxx-standard supported by cmake
---
 CMakeLists.txt |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 42b7399..3840cc9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,13 +6,11 @@
 
 cmake_minimum_required(VERSION 3.1.0)
 
-set(CMAKE_CXX_STANDARD 20)
 set(GNUWIN32_DIR D:/LyX/lyx-unstable/lyx-windows-deps-msvc2017)
 set(LYX_USE_QT "QT5")
 set(LYX_REQUIRE_SPELLCHECK true)
 
 set(LYX_PROJECT LyX)
-
 # Instruct cmake to not use gnu extensions,
 # this prevents the mix of '-std=c++*' and '-std=gnu++*' flags
 set(CMAKE_CXX_EXTENSIONS OFF)
@@ -697,7 +695,17 @@ else()
          # for the pointer to 
https://cmake.org/cmake/help/v3.6/variable/CMAKE_CXX_STANDARD.html
          # This allows us to use QT5.7 with recent g++ (version >= 4.9) 
compilers
          # and still use our own c++ extension tests
-         set(CMAKE_CXX_STANDARD ${CMAKE_MATCH_1})
+         set(std_num ${CMAKE_MATCH_1})
+         # Try to find a std-cxx-feature supported by this cmake version
+         while (std_num GREATER 0)
+           list(FIND CMAKE_CXX_COMPILE_FEATURES "cxx_std_${std_num}" 
stdfeature)
+           if (stdfeature GREATER_EQUAL 0)
+             set(CMAKE_CXX_STANDARD ${std_num})
+             break()
+           endif()
+           math(EXPR std_num "${std_num}-1")
+         endwhile()
+
          message(STATUS "CMAKE_CXX_STANDARD set to ${CMAKE_CXX_STANDARD}")
          set(LYX_CXX_FLAGS "-Wall -Wunused-parameter ${LYX_CXX_FLAGS}")
        else()
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to