diff options
Diffstat (limited to 'src/CMakeLists.txt')
-rw-r--r-- | src/CMakeLists.txt | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0696201df..d7f68618c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,7 +24,7 @@ if (MSVC) # Ensure that projects build with Unicode support. add_definitions(-DUNICODE -D_UNICODE) - # /W3 - Level 3 warnings + # /W4 - Level 4 warnings # /MP - Multi-threaded compilation # /Zi - Output debugging information # /Zm - Specifies the precompiled header memory allocation limit @@ -35,6 +35,7 @@ if (MSVC) # /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:preprocessor - Enable standards-conforming preprocessor # /Zc:throwingNew - Let codegen assume `operator new` (without std::nothrow) will never return null # /GT - Supports fiber safety for data allocated using static thread-local storage add_compile_options( @@ -48,6 +49,7 @@ if (MSVC) /volatile:iso /Zc:externConstexpr /Zc:inline + /Zc:preprocessor /Zc:throwingNew /GT @@ -59,7 +61,7 @@ if (MSVC) /external:W0 # Sets the default warning level to 0 for external headers, effectively turning off warnings for external headers # Warnings - /W3 + /W4 /WX /we4062 # Enumerator 'identifier' in a switch of enum 'enumeration' is not handled @@ -82,12 +84,17 @@ if (MSVC) /wd4100 # 'identifier': unreferenced formal parameter /wd4324 # 'struct_name': structure was padded due to __declspec(align()) + /wd4201 # nonstandard extension used : nameless struct/union + /wd4702 # unreachable code (when used with LTO) ) if (USE_CCACHE OR YUZU_USE_PRECOMPILED_HEADERS) # when caching, we need to use /Z7 to downgrade debug info to use an older but more cacheable format # Precompiled headers are deleted if not using /Z7. See https://github.com/nanoant/CMakePCHCompiler/issues/21 add_compile_options(/Z7) + # Avoid D9025 warning + string(REPLACE "/Zi" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") + string(REPLACE "/Zi" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") else() add_compile_options(/Zi) endif() @@ -103,6 +110,8 @@ if (MSVC) set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG /MANIFEST:NO /INCREMENTAL:NO /OPT:REF,ICF" CACHE STRING "" FORCE) else() add_compile_options( + -fwrapv + -Werror=all -Werror=extra -Werror=missing-declarations @@ -112,19 +121,21 @@ else() -Wno-attributes -Wno-invalid-offsetof -Wno-unused-parameter - - $<$<CXX_COMPILER_ID:Clang>:-Wno-braced-scalar-init> - $<$<CXX_COMPILER_ID:Clang>:-Wno-unused-private-field> - $<$<CXX_COMPILER_ID:Clang>:-Werror=shadow-uncaptured-local> - $<$<CXX_COMPILER_ID:Clang>:-Werror=implicit-fallthrough> - $<$<CXX_COMPILER_ID:Clang>:-Werror=type-limits> - $<$<CXX_COMPILER_ID:AppleClang>:-Wno-braced-scalar-init> - $<$<CXX_COMPILER_ID:AppleClang>:-Wno-unused-private-field> ) + if (CMAKE_CXX_COMPILER_ID MATCHES Clang) # Clang or AppleClang + add_compile_options( + -Wno-braced-scalar-init + -Wno-unused-private-field + -Wno-nullability-completeness + -Werror=shadow-uncaptured-local + -Werror=implicit-fallthrough + -Werror=type-limits + ) + endif() + if (ARCHITECTURE_x86_64) add_compile_options("-mcx16") - add_compile_options("-fwrapv") endif() if (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL Clang) @@ -132,7 +143,7 @@ else() endif() # GCC bugs - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "11" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # These diagnostics would be great if they worked, but are just completely broken # and produce bogus errors on external libraries like fmt. add_compile_options( |