@@ -29,11 +29,11 @@ set(IS_GNU "$<CXX_COMPILER_ID:GNU>")
2929set (IS_MSVC "$<CXX_COMPILER_ID:MSVC>" )
3030set (NOT_MSVC "$<NOT:$<CXX_COMPILER_ID:MSVC>>" )
3131
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>" )
3737
3838#[===========================[ compiler_detection ]===========================]
3939#[[ Check for clang-cl with MSVC frontend
@@ -63,6 +63,8 @@ function(common_compiler_flags)
6363 # These compiler options reflect what is in godot/SConstruct.
6464 target_compile_options (
6565 godot-cpp
66+ # The public flag tells CMake that the following options are transient,
67+ # and will propagate to consumers.
6668 PUBLIC
6769 # Disable exception handling. Godot doesn't use exceptions anywhere, and this
6870 # saves around 20% of binary size and very significant build time.
@@ -86,7 +88,15 @@ function(common_compiler_flags)
8688 $<${IS_MSVC} :
8789 # /MP isn't valid for clang-cl with msvc frontend
8890 $<$<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.
90100
91101 # Disable warnings which we don't plan to fix.
92102 /wd4100 # C4100 (unreferenced formal parameter): Doesn't play nice with polymorphism.
@@ -99,8 +109,6 @@ function(common_compiler_flags)
99109 /wd4514 # C4514 (unreferenced inline function has been removed)
100110 /wd4714 # C4714 (function marked as __forceinline not inlined)
101111 /wd4820 # C4820 (padding added after construct)
102-
103- /utf-8
104112 >
105113
106114 # Clang and GNU common options
@@ -130,18 +138,18 @@ function(common_compiler_flags)
130138 -Wstringop-overflow=4
131139
132140 # Bogus warning fixed in 8+.
133- $<${GNU_LT_V8 } :-Wno-strict-overflow>
141+ $<${LT_V8 } :-Wno-strict-overflow>
134142
135- $<${GNU_GE_V9 } :-Wattribute-alias=2>
143+ $<${GE_V9 } :-Wattribute-alias=2>
136144
137145 # Broke on MethodBind templates before GCC 11.
138- $<${GNU_GT_V11 } :-Wlogical-op>
146+ $<${GT_V11 } :-Wlogical-op>
139147
140148 # 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>
142150
143151 # False positives in our error macros, see GH-58747.
144- $<${GNU_GE_V12 } :-Wno-return-type >
152+ $<${GE_V12 } :-Wno-return-type >
145153 >
146154 )
147155
@@ -167,18 +175,18 @@ function(common_compiler_flags)
167175 target_link_options (
168176 godot-cpp
169177 PUBLIC
170- $<${IS_MSVC} :
171- /WX # treat link warnings as errors.
172- /MANIFEST:NO # We dont need a manifest
173- >
174-
175178 $<${DEBUG_SYMBOLS} :$<${IS_MSVC} :/DEBUG:FULL>>
176179
177180 $<$<NOT :${DEBUG_SYMBOLS} >:
178181 $<${IS_GNU} :-s>
179182 $<${IS_CLANG} :-s>
180183 $<${IS_APPLECLANG} :-Wl,-S -Wl,-x -Wl,-dead_strip>
181184 >
185+ PRIVATE
186+ $<${IS_MSVC} :
187+ /WX # treat link warnings as errors.
188+ /MANIFEST:NO # We dont need a manifest
189+ >
182190 )
183191 # gersemi: on
184192endfunction ()
0 commit comments