qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] meson.build: Don't look for libudev for static builds


From: Paolo Bonzini
Subject: Re: [PATCH] meson.build: Don't look for libudev for static builds
Date: Fri, 2 Oct 2020 15:05:21 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0

On 02/10/20 14:35, Peter Maydell wrote:
> 
> It would be better to do the "see if a static library is present"
> test. This isn't too hard to do in configure (compare that
> six line fix to the detection of libgio). Hopefully it is
> not too hard to do in meson ?

Yes, something like:

if enable_static
  skeleton = 'int main(void) { return 0; }'
  if not cc.links(skeleton, dependencies: libudev)
    if get_option('mpath').enabled()
        error('Cannot link with libudev')
      else
        warning('Cannot link with libudev, disabling')
        libudev = not_found
      endif
    endif
  endif
endif

It can be done in meson.build also for dependencies that are still
detected in configure, and we can place it in a loop if we want to do
many tests like these:

if enable_static
  dependencies = {'libudev': 'mpath', ...}
  skeleton = 'int main(void) { return 0; }'
  foreach var, option: dependencies
    if 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
endif

This way we don't have 500 lines of this kind of test.

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]