MSVC Changes. Leave CMake to set /std:. Only set /Zc:__cplusplus for VS2019+. Updated README.md

v0.27.3
clanmills 5 years ago
parent 529ffdc418
commit 4511817028

@ -714,6 +714,8 @@ $ make
The option -DCMAKE\_CXX\_FLAGS=-Wno-deprecated suppresses warnings from C++11 concerning auto\_ptr and other deprecated features. The option -DCMAKE\_CXX\_FLAGS=-Wno-deprecated suppresses warnings from C++11 concerning auto\_ptr and other deprecated features.
**Caution:** Visual Studio users should not use -DCMAKE\_CXX\_STANDARD=11 or -DCMAKE\_CXX\_FLAGS=-Wno-deprecated.
[TOC](#TOC) [TOC](#TOC)
<div id="3"> <div id="3">
@ -1187,4 +1189,4 @@ $ sudo pkg install developer/gcc-7
[TOC](#TOC) [TOC](#TOC)
Written by Robin Mills<br>robin@clanmills.com<br>Updated: 2020-05-02 Written by Robin Mills<br>robin@clanmills.com<br>Updated: 2020-05-04

@ -138,35 +138,9 @@ if(MSVC)
add_compile_options(/MP) add_compile_options(/MP)
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN) add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN)
# https://stackoverflow.com/questions/44960715/how-to-enable-stdc17-in-vs2017-with-cmake # https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
if (MSVC_VERSION GREATER_EQUAL "1700") # VS2015 and up if (MSVC_VERSION GREATER_EQUAL "1900") # VS2019 and up
include(CheckCXXCompilerFlag)
# MSVC doesn't have a setting for C++11 as it's a subset of C++14
if ( ${CMAKE_CXX_STANDARD} STREQUAL "11" OR ${CMAKE_CXX_STANDARD} STREQUAL "14" )
CHECK_CXX_COMPILER_FLAG("/std:c++14" _cpp_14)
if (_cpp_14)
add_compile_options("/std:c++14")
else()
message(WARNING "Cannot set compiler option /std:c++14")
endif()
endif()
if ( ${CMAKE_CXX_STANDARD} STREQUAL "17" )
CHECK_CXX_COMPILER_FLAG("/std:c++17" _cpp_17)
if (_cpp_17)
add_compile_options("/std:c++17")
else()
message(WARNING "Cannot set compiler option /std:c++17")
endif()
endif()
if ( ${CMAKE_CXX_STANDARD} STREQUAL "20" )
CHECK_CXX_COMPILER_FLAG("/std:c++11" _cpp_20)
if (_cpp_20)
add_compile_options("/std:c++20")
else()
message(WARNING "Cannot set compiler option /std:c++20")
endif()
endif()
# https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
add_compile_options("/Zc:__cplusplus") add_compile_options("/Zc:__cplusplus")
endif() endif()
endif() endif()

Loading…
Cancel
Save