diff mbox series

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

Message ID 20210126102748.341403-2-pbonzini@redhat.com
State New
Headers show
Series meson: honor --enable-rbd if cc.links test fails | expand

Commit Message

Paolo Bonzini Jan. 26, 2021, 10:27 a.m. UTC
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>
---
 meson.build | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

Comments

Peter Lieven Jan. 26, 2021, 10:42 a.m. UTC | #1
Am 26.01.21 um 11:27 schrieb Paolo Bonzini:
> 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>
> ---
>  meson.build | 24 +++++++++++++++---------
>  1 file changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/meson.build b/meson.build
> index f991d4274d..5943aa8a51 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -690,15 +690,21 @@ if not get_option('rbd').auto() or have_block
>    librbd = cc.find_library('rbd', has_headers: ['rbd/librbd.h'],
>                             required: get_option('rbd'),
>                             kwargs: static_kwargs)
> -  if librados.found() and librbd.found() and cc.links('''
> -    #include <stdio.h>
> -    #include <rbd/librbd.h>
> -    int main(void) {
> -      rados_t cluster;
> -      rados_create(&cluster, NULL);
> -      return 0;
> -    }''', dependencies: [librbd, librados])
> -    rbd = declare_dependency(dependencies: [librbd, librados])
> +  if librados.found() and librbd.found()
> +    if cc.links('''
> +      #include <stdio.h>
> +      #include <rbd/librbd.h>
> +      int main(void) {
> +        rados_t cluster;
> +        rados_create(&cluster, NULL);
> +        return 0;
> +      }''', 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
>  


That was fast, tank you.


Tested-by: Peter Lieven <pl@kamp.de>


Peter
diff mbox series

Patch

diff --git a/meson.build b/meson.build
index f991d4274d..5943aa8a51 100644
--- a/meson.build
+++ b/meson.build
@@ -690,15 +690,21 @@  if not get_option('rbd').auto() or have_block
   librbd = cc.find_library('rbd', has_headers: ['rbd/librbd.h'],
                            required: get_option('rbd'),
                            kwargs: static_kwargs)
-  if librados.found() and librbd.found() and cc.links('''
-    #include <stdio.h>
-    #include <rbd/librbd.h>
-    int main(void) {
-      rados_t cluster;
-      rados_create(&cluster, NULL);
-      return 0;
-    }''', dependencies: [librbd, librados])
-    rbd = declare_dependency(dependencies: [librbd, librados])
+  if librados.found() and librbd.found()
+    if cc.links('''
+      #include <stdio.h>
+      #include <rbd/librbd.h>
+      int main(void) {
+        rados_t cluster;
+        rados_create(&cluster, NULL);
+        return 0;
+      }''', 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