1project('static dynamic', 'c') 2 3# Solaris does not ship static libraries 4if host_machine.system() == 'sunos' 5 has_static = false 6else 7 has_static = true 8endif 9 10cc = meson.get_compiler('c') 11 12z_default = cc.find_library('z') 13if has_static 14 z_static = cc.find_library('z', static: true) 15endif 16z_dynamic = cc.find_library('z', static: false) 17 18exe_default = executable('main_default', 'main.c', dependencies: [z_default]) 19if has_static 20 exe_static = executable('main_static', 'main.c', dependencies: [z_static]) 21endif 22exe_dynamic = executable('main_dynamic', 'main.c', dependencies: [z_dynamic]) 23 24test('test default', exe_default) 25if has_static 26 test('test static', exe_static) 27endif 28test('test dynamic', exe_dynamic) 29 30if has_static 31 test('verify static linking', find_program('verify_static.py'), 32 args: ['--platform=' + host_machine.system(), exe_static.full_path()]) 33endif 34test('verify dynamic linking', find_program('verify_static.py'), 35 args: ['--platform=' + host_machine.system(), exe_dynamic.full_path()], 36 should_fail: true) 37