@@ -29,11 +29,11 @@ set(IS_GNU "$<CXX_COMPILER_ID:GNU>")
29
29
set (IS_MSVC "$<CXX_COMPILER_ID:MSVC>" )
30
30
set (NOT_MSVC "$<NOT:$<CXX_COMPILER_ID:MSVC>>" )
31
31
32
- set (GNU_LT_V8 "$<VERSION_LESS:$<CXX_COMPILER_VERSION>,8>" )
33
- set (GNU_GE_V9 "$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,9>" )
34
- set (GNU_GT_V11 "$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,11>" )
35
- set (GNU_LT_V11 "$<VERSION_LESS:$<CXX_COMPILER_VERSION>,11>" )
36
- set (GNU_GE_V12 "$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,12>" )
32
+ set (LT_V8 "$<VERSION_LESS:$<CXX_COMPILER_VERSION>,8>" )
33
+ set (GE_V9 "$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,9>" )
34
+ set (GT_V11 "$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,11>" )
35
+ set (LT_V11 "$<VERSION_LESS:$<CXX_COMPILER_VERSION>,11>" )
36
+ set (GE_V12 "$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,12>" )
37
37
38
38
#[===========================[ compiler_detection ]===========================]
39
39
#[[ Check for clang-cl with MSVC frontend
@@ -63,6 +63,8 @@ function(common_compiler_flags)
63
63
# These compiler options reflect what is in godot/SConstruct.
64
64
target_compile_options (
65
65
godot-cpp
66
+ # The public flag tells CMake that the following options are transient,
67
+ # and will propagate to consumers.
66
68
PUBLIC
67
69
# Disable exception handling. Godot doesn't use exceptions anywhere, and this
68
70
# saves around 20% of binary size and very significant build time.
@@ -86,7 +88,15 @@ function(common_compiler_flags)
86
88
$<${IS_MSVC} :
87
89
# /MP isn't valid for clang-cl with msvc frontend
88
90
$<$<CXX_COMPILER_ID:MSVC >:/MP${PROC_N} >
89
- /W4
91
+
92
+ # Interpret source files as utf-8
93
+ /utf-8
94
+ >
95
+
96
+ # Warnings below, these do not need to propagate to consumers.
97
+ PRIVATE
98
+ $<${IS_MSVC} :
99
+ /W4 # Warning level 4 (informational) warnings that aren't off by default.
90
100
91
101
# Disable warnings which we don't plan to fix.
92
102
/wd4100 # C4100 (unreferenced formal parameter): Doesn't play nice with polymorphism.
@@ -99,8 +109,6 @@ function(common_compiler_flags)
99
109
/wd4514 # C4514 (unreferenced inline function has been removed)
100
110
/wd4714 # C4714 (function marked as __forceinline not inlined)
101
111
/wd4820 # C4820 (padding added after construct)
102
-
103
- /utf-8
104
112
>
105
113
106
114
# Clang and GNU common options
@@ -130,18 +138,18 @@ function(common_compiler_flags)
130
138
-Wstringop-overflow=4
131
139
132
140
# Bogus warning fixed in 8+.
133
- $<${GNU_LT_V8 } :-Wno-strict-overflow>
141
+ $<${LT_V8 } :-Wno-strict-overflow>
134
142
135
- $<${GNU_GE_V9 } :-Wattribute-alias=2>
143
+ $<${GE_V9 } :-Wattribute-alias=2>
136
144
137
145
# Broke on MethodBind templates before GCC 11.
138
- $<${GNU_GT_V11 } :-Wlogical-op>
146
+ $<${GT_V11 } :-Wlogical-op>
139
147
140
148
# Regression in GCC 9/10, spams so much in our variadic templates that we need to outright disable it.
141
- $<${GNU_LT_V11 } :-Wno-type -limits>
149
+ $<${LT_V11 } :-Wno-type -limits>
142
150
143
151
# False positives in our error macros, see GH-58747.
144
- $<${GNU_GE_V12 } :-Wno-return-type >
152
+ $<${GE_V12 } :-Wno-return-type >
145
153
>
146
154
)
147
155
@@ -167,18 +175,18 @@ function(common_compiler_flags)
167
175
target_link_options (
168
176
godot-cpp
169
177
PUBLIC
170
- $<${IS_MSVC} :
171
- /WX # treat link warnings as errors.
172
- /MANIFEST:NO # We dont need a manifest
173
- >
174
-
175
178
$<${DEBUG_SYMBOLS} :$<${IS_MSVC} :/DEBUG:FULL>>
176
179
177
180
$<$<NOT :${DEBUG_SYMBOLS} >:
178
181
$<${IS_GNU} :-s>
179
182
$<${IS_CLANG} :-s>
180
183
$<${IS_APPLECLANG} :-Wl,-S -Wl,-x -Wl,-dead_strip>
181
184
>
185
+ PRIVATE
186
+ $<${IS_MSVC} :
187
+ /WX # treat link warnings as errors.
188
+ /MANIFEST:NO # We dont need a manifest
189
+ >
182
190
)
183
191
# gersemi: on
184
192
endfunction ()
0 commit comments