@@ -37,7 +37,6 @@ if c.get_id().contains('gcc') or c.get_id().contains('clang')
3737 ' -Wundef' ,
3838 ' -Wformat' ,
3939 ' -Wformat=2' ,
40- ' -Wsign-conversion' ,
4140 ' -Wint-conversion' ,#-Warith-conversion
4241 ' -Wenum-conversion' ,
4342 ' -Wfloat-conversion' ,
@@ -79,6 +78,11 @@ if c.get_id().contains('gcc') or c.get_id().contains('clang')
7978 ' -fvisibility=hidden' , #to work similarly to Window's DLL import/export
8079 ]
8180
81+ if c.get_id().contains(' gcc' ) and c.version().version_compare(' >=10.0' )
82+ #only enable the sign conversion warning on versions 10 and up because it is way too noisy on earlier GCC versions than it is useful-TJE
83+ warning_flags += ' -Wsign-conversion'
84+ endif
85+
8286 if c.get_id().contains(' gcc' ) and target_machine .system() == ' windows'
8387 #According to the link below, this is not needed in Windows...it also causes a bug in some versions of GCC for Windows.
8488 #https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90458
@@ -105,6 +109,15 @@ if c.get_id().contains('gcc') or c.get_id().contains('clang')
105109 ' -Wl,-z,relro' ,
106110 ' -Wl,-z,now'
107111 ]
112+ fortifytest = ''' #include <stdio.h>
113+ int main() {
114+ return 0;
115+ }
116+ '''
117+ fortifyresult = c.compiles(fortifytest, name : ' _FORTIFY_SOURCE override' , args : [' -U_FORTIFY_SOURCE' , ' -D_FORTIFY_SOURCE=5' , ' -Werror' ])
118+ if fortifyresult == true
119+ warning_flags += [' -U_FORTIFY_SOURCE' , ' -D_FORTIFY_SOURCE=3' ]
120+ endif
108121elif c.get_id().contains(' msvc' )
109122 #See here for enabling/disabling msvc warnings:
110123 #https://learn.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level?view=msvc-170
@@ -167,7 +180,6 @@ elif c.get_id().contains('msvc')
167180 ' /we4628' , # digraphs not supported with -Ze. Character sequence 'digraph' not interpreted as alternate token for 'char'
168181 ' /we4289' , # nonstandard extension used : 'var' : loop control variable declared in the for-loop is used outside the for-loop scope
169182 ' /we4464' , # relative include path contains '..'
170- ' /std:c17' , #NOTE: It would be better to specify for the project settings above for all compilers, but currently still supporting MSVC and GCC compilers that may not be C11 compatible.-TJE
171183 ' /GS' , #security cookie for stack protection
172184 ' /sdl' , #adds recommended security development lifecycle checks
173185 ' /Qspectre' ,
@@ -179,6 +191,10 @@ elif c.get_id().contains('msvc')
179191 # https://learn.microsoft.com/en-us/cpp/build/reference/qintel-jcc-erratum?view=msvc-170
180192 warning_flags += ' /QIntel-jcc-erratum'
181193 endif
194+
195+ if c.has_argument(' /std:c17' )
196+ c_std = ' c17'
197+ endif
182198
183199 linker_flags += [
184200 ' /guard:cf' , #control flow guard
@@ -219,9 +235,18 @@ if (c.get_id() == 'gcc' or c.get_id() == 'clang') and target_machine.system() !=
219235 #skipping sunos since this was a compatibility issue that was reported earlier. May be able to find a better way to handle this in the future.
220236 if not (target_machine .system() == ' sunos' ) and c.get_id().contains(' gcc' )
221237 if c.version().version_compare(' <5.0' )
222- if c.has_argument(' -std=gnu99' )
238+ #4.7.4+ has C11 support, but c89 is the default standard so we need to change it.
239+ if c.has_argument(' -std=gnu11' )
240+ c_std = ' gnu11'
241+ if meson .version().version_compare(' <1.0.0' )
242+ add_project_arguments (' -std=gnu11' , language : ' c' )
243+ endif
244+ elif c.has_argument(' -std=gnu99' )
223245 #Add this argument to the list since C99 is a minimum required C compiler standard
224- add_global_arguments (' -std=gnu99' , language : ' c' ,)
246+ c_std = ' gnu99'
247+ if meson .version().version_compare(' <1.0.0' )
248+ add_project_arguments (' -std=gnu99' , language : ' c' )
249+ endif
225250 else
226251 error (' C99/GNU99 standard is required but was not able to be set!' )
227252 endif
@@ -284,6 +309,11 @@ opensea_common_dep = opensea_common.get_variable('opensea_common_dep')
284309opensea_transport = subproject (' opensea-transport' )
285310opensea_transport_dep = opensea_transport.get_variable (' opensea_transport_dep' )
286311
312+ csmisupport = opensea_transport.get_variable (' csmisupport' )
313+ if csmisupport.enabled()
314+ add_project_arguments (' -DENABLE_CSMI' , language : ' c' )
315+ endif
316+
287317opensea_operations = subproject (' opensea-operations' )
288318opensea_operations_dep = opensea_operations.get_variable (' opensea_operations_dep' )
289319
0 commit comments