build: More robust compiler flag checks
Don't hardcode platforms but check if things actually link. This should fix cygwin.
This commit is contained in:
parent
806a0da258
commit
e68976ab39
39
meson.build
39
meson.build
@ -98,29 +98,36 @@ test_cflags = [
|
|||||||
'-Werror=missing-include-dirs',
|
'-Werror=missing-include-dirs',
|
||||||
'-Werror=date-time',
|
'-Werror=date-time',
|
||||||
]
|
]
|
||||||
if host_machine.system() != 'windows' and get_option('buildtype') != 'plain'
|
|
||||||
test_cflags += '-fstack-protector-strong'
|
|
||||||
endif
|
|
||||||
foreach cflag : test_cflags
|
foreach cflag : test_cflags
|
||||||
if cc.has_multi_arguments(cflag)
|
if cc.has_multi_arguments(cflag)
|
||||||
global_cflags += cflag
|
global_cflags += cflag
|
||||||
endif
|
endif
|
||||||
endforeach
|
endforeach
|
||||||
|
if get_option('buildtype') != 'plain'
|
||||||
|
if cc.has_argument('-fstack-protector-strong') and cc.links('''
|
||||||
|
int main (void) {
|
||||||
|
char buffer[16];
|
||||||
|
strcpy(buffer, "foo");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
''', args: '-fstack-protector-all')
|
||||||
|
global_cflags += '-fstack-protector-strong'
|
||||||
|
endif
|
||||||
|
endif
|
||||||
add_project_arguments(global_cflags, language: 'c')
|
add_project_arguments(global_cflags, language: 'c')
|
||||||
|
|
||||||
if host_machine.system() != 'windows'
|
|
||||||
global_ldflags = []
|
global_ldflags = []
|
||||||
test_ldflags = [
|
test_ldflags = [
|
||||||
'-Wl,-z,relro',
|
'-Wl,-z,relro',
|
||||||
'-Wl,-z,now',
|
'-Wl,-z,now',
|
||||||
]
|
]
|
||||||
foreach ldflag : test_ldflags
|
foreach ldflag : test_ldflags
|
||||||
if cc.has_argument(ldflag)
|
if cc.has_argument(ldflag) and cc.links('int main (void) { return 0; }', args: ldflag)
|
||||||
global_ldflags += ldflag
|
global_ldflags += ldflag
|
||||||
endif
|
endif
|
||||||
endforeach
|
endforeach
|
||||||
add_project_link_arguments(global_ldflags, language: 'c')
|
add_project_link_arguments(global_ldflags, language: 'c')
|
||||||
endif
|
|
||||||
|
|
||||||
subdir('src')
|
subdir('src')
|
||||||
if get_option('with-plugin')
|
if get_option('with-plugin')
|
||||||
|
Loading…
Reference in New Issue
Block a user