@@ -19,11 +19,11 @@ set( IS_GNU "$<CXX_COMPILER_ID:GNU>" )
1919set ( IS_MSVC "$<CXX_COMPILER_ID:MSVC>" )
2020set ( NOT_MSVC "$<NOT:$<CXX_COMPILER_ID:MSVC>>" )
2121
22- set ( GNU_LT_V8 "$<VERSION_LESS:$<CXX_COMPILER_VERSION>,8>" )
23- set ( GNU_GE_V9 "$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,9>" )
24- set ( GNU_GT_V11 "$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,11>" )
25- set ( GNU_LT_V11 "$<VERSION_LESS:$<CXX_COMPILER_VERSION>,11>" )
26- set ( GNU_GE_V12 "$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,12>" )
22+ set ( GNU_LT_V8 "$<${IS_GNU} :$< VERSION_LESS:$<CXX_COMPILER_VERSION>,8> >" )
23+ set ( GNU_GE_V9 "$<${IS_GNU} :$< VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,9> >" )
24+ set ( GNU_GT_V11 "$<${IS_GNU} :$< VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,11> >" )
25+ set ( GNU_LT_V11 "$<${IS_GNU} :$< VERSION_LESS:$<CXX_COMPILER_VERSION>,11> >" )
26+ set ( GNU_GE_V12 "$<${IS_GNU} :$< VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,12> >" )
2727
2828#[[ Check for clang-cl with MSVC frontend
2929The compiler is tested and set when the project command is called.
@@ -46,19 +46,12 @@ endfunction( )
4646
4747function ( common_compiler_flags TARGET_NAME )
4848
49- target_compile_features (${TARGET_NAME}
50- PUBLIC
51- cxx_std_17
52- )
53-
5449 # These compiler options reflect what is in godot/SConstruct.
5550 target_compile_options ( ${TARGET_NAME}
56- PUBLIC
51+ PRIVATE
5752 # Disable exception handling. Godot doesn't use exceptions anywhere, and this
5853 # saves around 20% of binary size and very significant build time.
59- $<${DISABLE_EXCEPTIONS} :
60- $<${NOT_MSVC} :-fno-exceptions>
61- >
54+ $<${DISABLE_EXCEPTIONS} :$<${NOT_MSVC} : -fno-exceptions >>
6255
6356 # Enabling Debug Symbols
6457 $<${DEBUG_SYMBOLS} :
@@ -74,16 +67,16 @@ function( common_compiler_flags TARGET_NAME )
7467 $<${NOT_MSVC} :-fno-omit-frame-pointer -O0>
7568 >
7669
77- $<${HOT_RELOAD} :
78- $<${IS_GNU} :-fno-gnu-unique>
79- >
70+ $<${HOT_RELOAD} :$<${IS_GNU} : -fno-gnu-unique>>
8071
8172 # MSVC only
8273 $<${IS_MSVC} :
8374 # /MP isn't valid for clang-cl with msvc frontend
8475 $<$<CXX_COMPILER_ID:MSVC >:/MP${PROC_N} >
8576 /W4
8677
78+ /W4 # Warning level 4 (informational) warnings that aren't off by default.
79+
8780 # Disable warnings which we don't plan to fix.
8881 /wd4100 # C4100 (unreferenced formal parameter): Doesn't play nice with polymorphism.
8982 /wd4127 # C4127 (conditional expression is constant)
@@ -95,8 +88,6 @@ function( common_compiler_flags TARGET_NAME )
9588 /wd4514 # C4514 (unreferenced inline function has been removed)
9689 /wd4714 # C4714 (function marked as __forceinline not inlined)
9790 /wd4820 # C4820 (padding added after construct)
98-
99- /utf-8
10091 >
10192
10293 # Clang and GNU common options
@@ -124,51 +115,50 @@ function( common_compiler_flags TARGET_NAME )
124115 -Wplacement-new=1
125116 -Wshadow-local
126117 -Wstringop-overflow=4
118+ >
127119
128- # Bogus warning fixed in 8+.
129- $<${GNU_LT_V8} :-Wno-strict-overflow>
120+ # Bogus warning fixed in 8+.
121+ $<${GNU_LT_V8} : -Wno-strict-overflow >
130122
131- $<${GNU_GE_V9} :-Wattribute-alias=2>
123+ $<${GNU_GE_V9} : -Wattribute-alias=2 >
132124
133- # Broke on MethodBind templates before GCC 11.
134- $<${GNU_GT_V11} :-Wlogical-op>
125+ # Broke on MethodBind templates before GCC 11.
126+ $<${GNU_GT_V11} : -Wlogical-op >
135127
136- # Regression in GCC 9/10, spams so much in our variadic templates that we need to outright disable it.
137- $<${GNU_LT_V11} :-Wno-type -limits>
128+ # Regression in GCC 9/10, spams so much in our variadic templates that we need to outright disable it.
129+ $<${GNU_LT_V11} : -Wno-type -limits >
130+
131+ # False positives in our error macros, see GH-58747.
132+ $<${GNU_GE_V12} : -Wno-return-type >
138133
139- # False positives in our error macros, see GH-58747.
140- $<${GNU_GE_V12} :-Wno-return-type >
141- >
142134 )
143135
144136 target_compile_definitions (${TARGET_NAME}
145137 PUBLIC
146138 GDEXTENSION
147139
148140 # features
149- $<${DEBUG_FEATURES} :DEBUG_ENABLED DEBUG_METHODS_ENABLED>
141+ $<${DEBUG_FEATURES} : DEBUG_ENABLED DEBUG_METHODS_ENABLED >
150142
151143 $<${IS_DEV_BUILD} :DEV_ENABLED>
152144
153145 $<${HOT_RELOAD} :HOT_RELOAD_ENABLED>
154146
155- $<$<STREQUAL :${GODOT_PRECISION} ,double>:REAL_T_IS_DOUBLE>
147+ $<$<STREQUAL :${GODOT_PRECISION} ,double>: REAL_T_IS_DOUBLE >
156148
157- $<${IS_MSVC} :$<${DISABLE_EXCEPTIONS} :_HAS_EXCEPTIONS=0>>
149+ $<${IS_MSVC} :$<${DISABLE_EXCEPTIONS} : _HAS_EXCEPTIONS=0 >>
158150 )
159151
160152 target_link_options ( ${TARGET_NAME}
161- PUBLIC
162- $<${IS_MSVC} :
163- /WX # treat link warnings as errors.
164- /MANIFEST:NO # We dont need a manifest
165- >
153+ PRIVATE
154+ $<${IS_MSVC} : /WX /MANIFEST:NO >
155+ # /WX # treat link warnings as errors.
156+ # /MANIFEST:NO # We dont need a manifest
166157
167- $<${DEBUG_SYMBOLS} :$<${IS_MSVC} :/DEBUG:FULL>>
168158 $<$<NOT :${DEBUG_SYMBOLS} >:
169- $<${IS_GNU} :-s >
170- $<${IS_CLANG} :-s >
171- $<${IS_APPLECLANG} :-Wl,-S -Wl,-x -Wl,-dead_strip>
159+ $<${IS_GNU} : -s >
160+ $<${IS_CLANG} : -s >
161+ $<${IS_APPLECLANG} : -Wl,-S -Wl,-x -Wl,-dead_strip >
172162 >
173163 )
174164
0 commit comments