Răsfoiți Sursa

CMake: Set MSVC flags for improved C++ standards conformance

This makes the compiler stricter and also enables small optimizations.
Yuri Kunde Schlesner 9 ani în urmă
părinte
comite
2ef7450465
1 a modificat fișierele cu 6 adăugiri și 3 ștergeri
  1. 6 3
      CMakeLists.txt

+ 6 - 3
CMakeLists.txt

@@ -92,10 +92,13 @@ else()
     # /W3 - Level 3 warnings
     # /W3 - Level 3 warnings
     # /MP - Multi-threaded compilation
     # /MP - Multi-threaded compilation
     # /Zi - Output debugging information
     # /Zi - Output debugging information
-    # /Zo - enahnced debug info for optimized builds
-    set(CMAKE_C_FLAGS   "/W3 /MP /Zi /Zo" CACHE STRING "" FORCE)
+    # /Zo - enhanced debug info for optimized builds
+    # /permissive- - enables stricter C++ standards conformance checks
+    set(CMAKE_C_FLAGS   "/W3 /MP /Zi /Zo /permissive-" CACHE STRING "" FORCE)
     # /EHsc - C++-only exception handling semantics
     # /EHsc - C++-only exception handling semantics
-    set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} /EHsc" CACHE STRING "" FORCE)
+    # /Zc:throwingNew - let codegen assume `operator new` will never return null
+    # /Zc:inline - let codegen omit inline functions in object files
+    set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} /EHsc /Zc:throwingNew,inline" CACHE STRING "" FORCE)
 
 
     # /MDd - Multi-threaded Debug Runtime DLL
     # /MDd - Multi-threaded Debug Runtime DLL
     set(CMAKE_C_FLAGS_DEBUG   "/Od /MDd" CACHE STRING "" FORCE)
     set(CMAKE_C_FLAGS_DEBUG   "/Od /MDd" CACHE STRING "" FORCE)