Am Tue, 5 May 2020 09:15:50 +0200
schrieb Kornel Benko <kor...@lyx.org>:

> Am Tue, 5 May 2020 08:34:48 +0200
> schrieb Yu Jin <technikma...@gmail.com>:
> 
> > > Eugene, could you please test the patch?
> > > Hmm, patch does not work for me, I get these errors:  
> 
> Thanks Eugene. Please try the next patch.
> If it also does not work, we have to decide on the msvc version
> what to do.
> 
> Could you also check the msvc-version (somewhere in the CMakeLists.txt)
> 
>       message(STATUS "MSVC_VERSION = ${MSVC_VERSION}")
> 
>       Kornel

Forgot to attach.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2a123e7c34..a59faf89c8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -655,11 +655,16 @@ if(LYX_SHARED_LIBRARIES)
 	set(library_type SHARED)
 else()
 	set(library_type STATIC)
 endif()
 
-if(NOT MSVC)
+if(MSVC)
+  if (CXX11_FLAG MATCHES "\\+\\+(14|17|20)")
+    set(CMAKE_CXX_STANDARD ${CMAKE_MATCH_1})
+    message(STATUS "CMAKE_CXX_STANDARD set to ${CMAKE_CXX_STANDARD}")
+  endif()
+else()
 	if(NOT LYX_QUIET)
 		set(CMAKE_VERBOSE_MAKEFILE ON)
 	endif()
 	set(LYX_CXX_FLAGS "-Wall -Wunused-parameter ${LYX_GCC11_MODE}")
 	if(LYX_CXX_FLAGS MATCHES "\\+\\+(14|11|98)")
diff --git a/development/cmake/modules/FindCXX11Compiler.cmake b/development/cmake/modules/FindCXX11Compiler.cmake
index 739d267bf0..1470a64bb2 100644
--- a/development/cmake/modules/FindCXX11Compiler.cmake
+++ b/development/cmake/modules/FindCXX11Compiler.cmake
@@ -42,11 +42,15 @@ else()
   else()
     if (MSVC)
       # MSVC does not have a general C++11 flag, one can only switch off
       # MS extensions with /Za in general or by extension with /Zc.
       # Use an empty flag to ensure that CXX11_STD_REGEX is correctly set.
-      set(CXX11_FLAG_CANDIDATES "noflagneeded")
+      set(CXX11_FLAG_CANDIDATES
+	"/std:c++20"
+	"/std:c++17"
+	"/std:c++14"
+	"noflagneeded")
     else()
       set(CXX11_FLAG_CANDIDATES
         "--std=c++14"
         "--std=c++11"
         "--std=gnu++11"
@@ -111,11 +115,13 @@ int main()
 # check c compiler
 set(SAFE_CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET})
 set(CMAKE_REQUIRED_QUIET ON)
 SET(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
 FOREACH(FLAG ${CXX11_FLAG_CANDIDATES})
-  IF(NOT "${FLAG}" STREQUAL "noflagneeded")
+  IF("${FLAG}" STREQUAL "noflagneeded")
+    UNSET(CMAKE_REQUIRED_FLAGS)
+  ELSE()
     SET(CMAKE_REQUIRED_FLAGS "${FLAG}")
   ENDIF()
   UNSET(CXX11_FLAG_DETECTED CACHE)
   CHECK_CXX_SOURCE_COMPILES("${CXX11_TEST_SOURCE}" CXX11_FLAG_DETECTED)
   IF(CXX11_FLAG_DETECTED)

Attachment: pgpH6BV4Z4Qe5.pgp
Description: Digitale Signatur von OpenPGP

-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to