@@ -46,19 +46,14 @@ endfunction( )
4646
4747function ( common_compiler_flags )
4848
49- target_compile_features (${TARGET_NAME}
50- PUBLIC
51- cxx_std_17
52- )
53-
49+ # gersemi: off
5450 # These compiler options reflect what is in godot/SConstruct.
55- target_compile_options ( ${TARGET_NAME}
51+ target_compile_options (
52+ ${TARGET_NAME}
5653 PUBLIC
5754 # Disable exception handling. Godot doesn't use exceptions anywhere, and this
5855 # saves around 20% of binary size and very significant build time.
59- $<${DISABLE_EXCEPTIONS} :
60- $<${NOT_MSVC} :-fno-exceptions>
61- >
56+ $<${DISABLE_EXCEPTIONS} :$<${NOT_MSVC} :-fno-exceptions>>
6257
6358 # Enabling Debug Symbols
6459 $<${DEBUG_SYMBOLS} :
@@ -70,78 +65,75 @@ function( common_compiler_flags )
7065 >
7166 >
7267
73- $<${IS_DEV_BUILD} :
74- $<${NOT_MSVC} :-fno-omit-frame-pointer -O0>
68+ $<${IS_DEV_BUILD} :$<${NOT_MSVC} :-fno-omit-frame-pointer -O0>>
69+
70+ $<${HOT_RELOAD} :$<${IS_GNU} :-fno-gnu-unique>>
71+
72+ # MSVC only
73+ $<${IS_MSVC} :
74+ # /MP isn't valid for clang-cl with msvc frontend
75+ $<$<CXX_COMPILER_ID:MSVC >:/MP${PROC_N} >
76+ /W4
77+
78+ # Disable warnings which we don't plan to fix.
79+ /wd4100 # C4100 (unreferenced formal parameter): Doesn't play nice with polymorphism.
80+ /wd4127 # C4127 (conditional expression is constant)
81+ /wd4201 # C4201 (non-standard nameless struct/union): Only relevant for C89.
82+ /wd4244 # C4244 C4245 C4267 (narrowing conversions): Unavoidable at this scale.
83+ /wd4245
84+ /wd4267
85+ /wd4305 # C4305 (truncation): double to float or real_t, too hard to avoid.
86+ /wd4514 # C4514 (unreferenced inline function has been removed)
87+ /wd4714 # C4714 (function marked as __forceinline not inlined)
88+ /wd4820 # C4820 (padding added after construct)
89+
90+ /utf-8
91+ >
92+
93+ # Clang and GNU common options
94+ $<$<OR :${IS_CLANG} ,${IS_GNU} >:
95+ -Wall
96+ -Wctor-dtor-privacy
97+ -Wextra
98+ -Wno-unused-parameter
99+ -Wnon-virtual-dtor
100+ -Wwrite-strings
75101 >
76102
77- $<${HOT_RELOAD} :
78- $<${IS_GNU} :-fno-gnu-unique>
103+ # Clang only
104+ $<${IS_CLANG} :
105+ -Wimplicit-fallthrough
106+ -Wno-ordered-compare-function-pointers
79107 >
80108
81- # MSVC only
82- $<${IS_MSVC} :
83- # /MP isn't valid for clang-cl with msvc frontend
84- $<$<CXX_COMPILER_ID:MSVC >:/MP${PROC_N} >
85- /W4
86-
87- # Disable warnings which we don't plan to fix.
88- /wd4100 # C4100 (unreferenced formal parameter): Doesn't play nice with polymorphism.
89- /wd4127 # C4127 (conditional expression is constant)
90- /wd4201 # C4201 (non-standard nameless struct/union): Only relevant for C89.
91- /wd4244 # C4244 C4245 C4267 (narrowing conversions): Unavoidable at this scale.
92- /wd4245
93- /wd4267
94- /wd4305 # C4305 (truncation): double to float or real_t, too hard to avoid.
95- /wd4514 # C4514 (unreferenced inline function has been removed)
96- /wd4714 # C4714 (function marked as __forceinline not inlined)
97- /wd4820 # C4820 (padding added after construct)
98-
99- /utf-8
100- >
101-
102- # Clang and GNU common options
103- $<$<OR :${IS_CLANG} ,${IS_GNU} >:
104- -Wall
105- -Wctor-dtor-privacy
106- -Wextra
107- -Wno-unused-parameter
108- -Wnon-virtual-dtor
109- -Wwrite-strings
110- >
111-
112- # Clang only
113- $<${IS_CLANG} :
114- -Wimplicit-fallthrough
115- -Wno-ordered-compare-function-pointers
116- >
117-
118- # GNU only
119- $<${IS_GNU} :
120- -Walloc-zero
121- -Wduplicated-branches
122- -Wduplicated-cond
123- -Wno-misleading-indentation
124- -Wplacement-new=1
125- -Wshadow-local
126- -Wstringop-overflow=4
127-
128- # Bogus warning fixed in 8+.
129- $<${GNU_LT_V8} :-Wno-strict-overflow>
130-
131- $<${GNU_GE_V9} :-Wattribute-alias=2>
132-
133- # Broke on MethodBind templates before GCC 11.
134- $<${GNU_GT_V11} :-Wlogical-op>
135-
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>
138-
139- # False positives in our error macros, see GH-58747.
140- $<${GNU_GE_V12} :-Wno-return-type >
141- >
109+ # GNU only
110+ $<${IS_GNU} :
111+ -Walloc-zero
112+ -Wduplicated-branches
113+ -Wduplicated-cond
114+ -Wno-misleading-indentation
115+ -Wplacement-new=1
116+ -Wshadow-local
117+ -Wstringop-overflow=4
118+
119+ # Bogus warning fixed in 8+.
120+ $<${GNU_LT_V8} :-Wno-strict-overflow>
121+
122+ $<${GNU_GE_V9} :-Wattribute-alias=2>
123+
124+ # Broke on MethodBind templates before GCC 11.
125+ $<${GNU_GT_V11} :-Wlogical-op>
126+
127+ # Regression in GCC 9/10, spams so much in our variadic templates that we need to outright disable it.
128+ $<${GNU_LT_V11} :-Wno-type -limits>
129+
130+ # False positives in our error macros, see GH-58747.
131+ $<${GNU_GE_V12} :-Wno-return-type >
132+ >
142133 )
143134
144- target_compile_definitions (${TARGET_NAME}
135+ target_compile_definitions (
136+ ${TARGET_NAME}
145137 PUBLIC
146138 GDEXTENSION
147139
@@ -159,19 +151,21 @@ function( common_compiler_flags )
159151 $<${THREADS_ENABLED} :THREADS_ENABLED>
160152 )
161153
162- target_link_options ( ${TARGET_NAME}
154+ target_link_options (
155+ ${TARGET_NAME}
163156 PUBLIC
164157 $<${IS_MSVC} :
165158 /WX # treat link warnings as errors.
166159 /MANIFEST:NO # We dont need a manifest
167160 >
168161
169162 $<${DEBUG_SYMBOLS} :$<${IS_MSVC} :/DEBUG:FULL>>
163+
170164 $<$<NOT :${DEBUG_SYMBOLS} >:
171165 $<${IS_GNU} :-s>
172166 $<${IS_CLANG} :-s>
173167 $<${IS_APPLECLANG} :-Wl,-S -Wl,-x -Wl,-dead_strip>
174168 >
175169 )
176-
170+ # gersemi: on
177171endfunction ()
0 commit comments