On 02/10/20 15:09, Peter Maydell wrote: > This duplicates the information that the thing that depends > on libudev is mpath. Can we put this in a wrapper around > dependency() so that we could just say something like > libudev = compile_checked_dependency('libudev', > required: get_option('mpath').enabled(), > static: enable_static) > > for those dependencies that want to do the "does this compile" > check ?
No, there's no functions at all. You can of course put the detection and test in a single loop: dependencies = {} ... if targetos == 'linux' and (have_system or have_tools) dependencies += {'libudev': 'mpath'} endif ... skeleton = 'int main(void) { return 0; }' foreach var, option: dependencies dep = dependency(var, required: get_option(option).enabled(), static: enable_static) if dep.found() and enable_static and not cc.links(skeleton, dependencies: get_variable(var)) if get_option(option).enabled() error('Cannot link with @0@'.format(var)) else warning('Cannot link with @0@, disabling'.format(skeleton)) set_variable(var, not_found) endif endif endif endforeach Doing this check for all libraries is certainly a good idea. Paolo