diff options
Diffstat (limited to 'src/CMakeLists.txt')
| -rw-r--r-- | src/CMakeLists.txt | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2da983cad..d7f68618c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt | |||
| @@ -24,7 +24,7 @@ if (MSVC) | |||
| 24 | # Ensure that projects build with Unicode support. | 24 | # Ensure that projects build with Unicode support. |
| 25 | add_definitions(-DUNICODE -D_UNICODE) | 25 | add_definitions(-DUNICODE -D_UNICODE) |
| 26 | 26 | ||
| 27 | # /W3 - Level 3 warnings | 27 | # /W4 - Level 4 warnings |
| 28 | # /MP - Multi-threaded compilation | 28 | # /MP - Multi-threaded compilation |
| 29 | # /Zi - Output debugging information | 29 | # /Zi - Output debugging information |
| 30 | # /Zm - Specifies the precompiled header memory allocation limit | 30 | # /Zm - Specifies the precompiled header memory allocation limit |
| @@ -61,7 +61,7 @@ if (MSVC) | |||
| 61 | /external:W0 # Sets the default warning level to 0 for external headers, effectively turning off warnings for external headers | 61 | /external:W0 # Sets the default warning level to 0 for external headers, effectively turning off warnings for external headers |
| 62 | 62 | ||
| 63 | # Warnings | 63 | # Warnings |
| 64 | /W3 | 64 | /W4 |
| 65 | /WX | 65 | /WX |
| 66 | 66 | ||
| 67 | /we4062 # Enumerator 'identifier' in a switch of enum 'enumeration' is not handled | 67 | /we4062 # Enumerator 'identifier' in a switch of enum 'enumeration' is not handled |
| @@ -84,12 +84,17 @@ if (MSVC) | |||
| 84 | 84 | ||
| 85 | /wd4100 # 'identifier': unreferenced formal parameter | 85 | /wd4100 # 'identifier': unreferenced formal parameter |
| 86 | /wd4324 # 'struct_name': structure was padded due to __declspec(align()) | 86 | /wd4324 # 'struct_name': structure was padded due to __declspec(align()) |
| 87 | /wd4201 # nonstandard extension used : nameless struct/union | ||
| 88 | /wd4702 # unreachable code (when used with LTO) | ||
| 87 | ) | 89 | ) |
| 88 | 90 | ||
| 89 | if (USE_CCACHE OR YUZU_USE_PRECOMPILED_HEADERS) | 91 | if (USE_CCACHE OR YUZU_USE_PRECOMPILED_HEADERS) |
| 90 | # when caching, we need to use /Z7 to downgrade debug info to use an older but more cacheable format | 92 | # when caching, we need to use /Z7 to downgrade debug info to use an older but more cacheable format |
| 91 | # Precompiled headers are deleted if not using /Z7. See https://github.com/nanoant/CMakePCHCompiler/issues/21 | 93 | # Precompiled headers are deleted if not using /Z7. See https://github.com/nanoant/CMakePCHCompiler/issues/21 |
| 92 | add_compile_options(/Z7) | 94 | add_compile_options(/Z7) |
| 95 | # Avoid D9025 warning | ||
| 96 | string(REPLACE "/Zi" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") | ||
| 97 | string(REPLACE "/Zi" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") | ||
| 93 | else() | 98 | else() |
| 94 | add_compile_options(/Zi) | 99 | add_compile_options(/Zi) |
| 95 | endif() | 100 | endif() |
| @@ -105,6 +110,8 @@ if (MSVC) | |||
| 105 | set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG /MANIFEST:NO /INCREMENTAL:NO /OPT:REF,ICF" CACHE STRING "" FORCE) | 110 | set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG /MANIFEST:NO /INCREMENTAL:NO /OPT:REF,ICF" CACHE STRING "" FORCE) |
| 106 | else() | 111 | else() |
| 107 | add_compile_options( | 112 | add_compile_options( |
| 113 | -fwrapv | ||
| 114 | |||
| 108 | -Werror=all | 115 | -Werror=all |
| 109 | -Werror=extra | 116 | -Werror=extra |
| 110 | -Werror=missing-declarations | 117 | -Werror=missing-declarations |
| @@ -114,19 +121,21 @@ else() | |||
| 114 | -Wno-attributes | 121 | -Wno-attributes |
| 115 | -Wno-invalid-offsetof | 122 | -Wno-invalid-offsetof |
| 116 | -Wno-unused-parameter | 123 | -Wno-unused-parameter |
| 117 | |||
| 118 | $<$<CXX_COMPILER_ID:Clang>:-Wno-braced-scalar-init> | ||
| 119 | $<$<CXX_COMPILER_ID:Clang>:-Wno-unused-private-field> | ||
| 120 | $<$<CXX_COMPILER_ID:Clang>:-Werror=shadow-uncaptured-local> | ||
| 121 | $<$<CXX_COMPILER_ID:Clang>:-Werror=implicit-fallthrough> | ||
| 122 | $<$<CXX_COMPILER_ID:Clang>:-Werror=type-limits> | ||
| 123 | $<$<CXX_COMPILER_ID:AppleClang>:-Wno-braced-scalar-init> | ||
| 124 | $<$<CXX_COMPILER_ID:AppleClang>:-Wno-unused-private-field> | ||
| 125 | ) | 124 | ) |
| 126 | 125 | ||
| 126 | if (CMAKE_CXX_COMPILER_ID MATCHES Clang) # Clang or AppleClang | ||
| 127 | add_compile_options( | ||
| 128 | -Wno-braced-scalar-init | ||
| 129 | -Wno-unused-private-field | ||
| 130 | -Wno-nullability-completeness | ||
| 131 | -Werror=shadow-uncaptured-local | ||
| 132 | -Werror=implicit-fallthrough | ||
| 133 | -Werror=type-limits | ||
| 134 | ) | ||
| 135 | endif() | ||
| 136 | |||
| 127 | if (ARCHITECTURE_x86_64) | 137 | if (ARCHITECTURE_x86_64) |
| 128 | add_compile_options("-mcx16") | 138 | add_compile_options("-mcx16") |
| 129 | add_compile_options("-fwrapv") | ||
| 130 | endif() | 139 | endif() |
| 131 | 140 | ||
| 132 | if (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL Clang) | 141 | if (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL Clang) |
| @@ -134,7 +143,7 @@ else() | |||
| 134 | endif() | 143 | endif() |
| 135 | 144 | ||
| 136 | # GCC bugs | 145 | # GCC bugs |
| 137 | if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | 146 | if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "11" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") |
| 138 | # These diagnostics would be great if they worked, but are just completely broken | 147 | # These diagnostics would be great if they worked, but are just completely broken |
| 139 | # and produce bogus errors on external libraries like fmt. | 148 | # and produce bogus errors on external libraries like fmt. |
| 140 | add_compile_options( | 149 | add_compile_options( |