CMakeLists: Specify /std:c++latest on MSVC

Makes use of the latest standards on MSVC, allowing potential
compilation issues to be diagnosed as soon as possible
This commit is contained in:
Lioncash 2020-04-07 07:28:43 -04:00
parent 139d290d7d
commit d5043fc319
1 changed files with 10 additions and 2 deletions

View File

@ -36,8 +36,15 @@ endif()
project(urde VERSION 0.1.0) project(urde VERSION 0.1.0)
set(CMAKE_CXX_STANDARD 17) # MSVC has a "latest" flag, which always uses the newest standard
set(CMAKE_CXX_STANDARD_REQUIRED ON) # when available. GCC and Clang posess no such flag, and must be
# manually enforced. CMake, curiously, also doesn't have a "latest"
# standard flag either.
if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Force shared libs off" FORCE) set(BUILD_SHARED_LIBS OFF CACHE BOOL "Force shared libs off" FORCE)
set(BUILD_STATIC_LIBS ON CACHE BOOL "Force static libs on" FORCE) set(BUILD_STATIC_LIBS ON CACHE BOOL "Force static libs on" FORCE)
@ -88,6 +95,7 @@ if(MSVC)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
add_compile_options( add_compile_options(
/std:c++latest # Use latest C++ standard.
/permissive- # Enforce various standards compliance features. /permissive- # Enforce various standards compliance features.
/Zc:externConstexpr # Allow extern constexpr variables according to the standard. /Zc:externConstexpr # Allow extern constexpr variables according to the standard.
/Zc:throwingNew # Assume new throws, allowing for better code generation. /Zc:throwingNew # Assume new throws, allowing for better code generation.