meson: honor --enable-rbd if cc.links test fails

If the link test failed, compilation proceeded with RBD disabled,
even if --enable-rbd was used on the configure command line.
Fix that.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2021-01-26 11:20:35 +01:00
parent d7dedf428f
commit c518d6c2bf

View file

@ -690,15 +690,21 @@ if not get_option('rbd').auto() or have_block
librbd = cc.find_library('rbd', has_headers: ['rbd/librbd.h'], librbd = cc.find_library('rbd', has_headers: ['rbd/librbd.h'],
required: get_option('rbd'), required: get_option('rbd'),
kwargs: static_kwargs) kwargs: static_kwargs)
if librados.found() and librbd.found() and cc.links(''' if librados.found() and librbd.found()
#include <stdio.h> if cc.links('''
#include <rbd/librbd.h> #include <stdio.h>
int main(void) { #include <rbd/librbd.h>
rados_t cluster; int main(void) {
rados_create(&cluster, NULL); rados_t cluster;
return 0; rados_create(&cluster, NULL);
}''', dependencies: [librbd, librados]) return 0;
rbd = declare_dependency(dependencies: [librbd, librados]) }''', dependencies: [librbd, librados])
rbd = declare_dependency(dependencies: [librbd, librados])
elif get_option('rbd').enabled()
error('could not link librados')
else
warning('could not link librados, disabling')
endif
endif endif
endif endif