From 7f053d0d45686ac21ae0036dd81698d8edd0f888 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 7 May 2019 14:02:29 -0400 Subject: [PATCH 1/3] src/CMakeLists: Vertically order compilation flags Makes it much nicer to visually scan the options. This also starts the flag descriptions from the same column for the same reason. --- src/CMakeLists.txt | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d3dffb496d..aac88a8c67 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,16 +18,25 @@ if (MSVC) # Avoid windows.h from including some usually unused libs like winsocks.h, since this might cause some redefinition errors. add_definitions(-DWIN32_LEAN_AND_MEAN) - # /W3 - Level 3 warnings - # /MP - Multi-threaded compilation - # /Zi - Output debugging information - # /Zo - enhanced debug info for optimized builds - # /permissive- - enables stricter C++ standards conformance checks - # /EHsc - C++-only exception handling semantics - # /std:c++latest - Latest available C++ standard - # /Zc:throwingNew - let codegen assume `operator new` will never return null - # /Zc:inline - let codegen omit inline functions in object files - add_compile_options(/W3 /MP /Zi /Zo /permissive- /EHsc /std:c++latest /Zc:throwingNew,inline) + # /W3 - Level 3 warnings + # /MP - Multi-threaded compilation + # /Zi - Output debugging information + # /Zo - Enhanced debug info for optimized builds + # /permissive- - Enables stricter C++ standards conformance checks + # /EHsc - C++-only exception handling semantics + # /Zc:inline - Let codegen omit inline functions in object files + # /Zc:throwingNew - Let codegen assume `operator new` (without std::nothrow) will never return null + add_compile_options( + /W3 + /MP + /Zi + /Zo + /permissive- + /EHsc + /std:c++latest + /Zc:inline + /Zc:throwingNew + ) # /GS- - No stack buffer overflow checks add_compile_options("$<$:/GS->") From e860a0ae5951fcd2c6bacdd62e7edf92a8a1d9d1 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 7 May 2019 14:06:20 -0400 Subject: [PATCH 2/3] src/CMakeLists: Add /Zc:externConstexpr to the MSVC build flags The C++ standard allows constexpr variables declared with the extern keyword to have external linkage. Previously MSVC wasn't abiding by this. This just makes the compiler more standards compliant during builds. Given we currently don't make use of anything that would break by this, this is safe to enable. --- src/CMakeLists.txt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index aac88a8c67..00dd419b98 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,14 +18,15 @@ if (MSVC) # Avoid windows.h from including some usually unused libs like winsocks.h, since this might cause some redefinition errors. add_definitions(-DWIN32_LEAN_AND_MEAN) - # /W3 - Level 3 warnings - # /MP - Multi-threaded compilation - # /Zi - Output debugging information - # /Zo - Enhanced debug info for optimized builds - # /permissive- - Enables stricter C++ standards conformance checks - # /EHsc - C++-only exception handling semantics - # /Zc:inline - Let codegen omit inline functions in object files - # /Zc:throwingNew - Let codegen assume `operator new` (without std::nothrow) will never return null + # /W3 - Level 3 warnings + # /MP - Multi-threaded compilation + # /Zi - Output debugging information + # /Zo - Enhanced debug info for optimized builds + # /permissive- - Enables stricter C++ standards conformance checks + # /EHsc - C++-only exception handling semantics + # /Zc:externConstexpr - Allow extern constexpr variables to have external linkage, like the standard mandates + # /Zc:inline - Let codegen omit inline functions in object files + # /Zc:throwingNew - Let codegen assume `operator new` (without std::nothrow) will never return null add_compile_options( /W3 /MP @@ -34,6 +35,7 @@ if (MSVC) /permissive- /EHsc /std:c++latest + /Zc:externConstexpr /Zc:inline /Zc:throwingNew ) From 8e79188ca510d5b365724dc4b2582618c02fcfdd Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 9 May 2019 15:49:27 -0400 Subject: [PATCH 3/3] CMakeLists: Specify /volatile:iso for MSVC By default, MSVC doesn't use standards-compliant volatile semantics. This makes it behave in a standards-compliant manner, making expectations more uniform across compilers. --- src/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 00dd419b98..ceef048fce 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,6 +24,7 @@ if (MSVC) # /Zo - Enhanced debug info for optimized builds # /permissive- - Enables stricter C++ standards conformance checks # /EHsc - C++-only exception handling semantics + # /volatile:iso - Use strict standards-compliant volatile semantics. # /Zc:externConstexpr - Allow extern constexpr variables to have external linkage, like the standard mandates # /Zc:inline - Let codegen omit inline functions in object files # /Zc:throwingNew - Let codegen assume `operator new` (without std::nothrow) will never return null @@ -35,6 +36,7 @@ if (MSVC) /permissive- /EHsc /std:c++latest + /volatile:iso /Zc:externConstexpr /Zc:inline /Zc:throwingNew