blob: d978ba9a255ce5eb8efb944a55adb4a3f8951122 [file] [log] [blame]
Davide Pesavento936205d2024-02-27 21:42:44 -05001from waflib import Options
Alexander Afanasyev5cda2e02014-04-11 13:58:44 -07002from waflib.Configure import conf
3
4def addDependencyOptions(self, opt, name, extraHelp=''):
Davide Pesavento0064c1d2018-03-03 18:43:53 -05005 opt.add_option('--with-%s' % name, metavar='PATH',
Alexander Afanasyev5cda2e02014-04-11 13:58:44 -07006 help='Path to %s, e.g., /usr/local %s' % (name, extraHelp))
Davide Pesavento0064c1d2018-03-03 18:43:53 -05007
8setattr(Options.OptionsContext, 'addDependencyOptions', addDependencyOptions)
Alexander Afanasyev5cda2e02014-04-11 13:58:44 -07009
10@conf
11def checkDependency(self, name, **kw):
12 root = kw.get('path', getattr(Options.options, 'with_%s' % name))
13 kw['msg'] = kw.get('msg', 'Checking for %s library' % name)
14 kw['uselib_store'] = kw.get('uselib_store', name.upper())
15 kw['define_name'] = kw.get('define_name', 'HAVE_%s' % kw['uselib_store'])
16 kw['mandatory'] = kw.get('mandatory', True)
17
18 if root:
Davide Pesavento0064c1d2018-03-03 18:43:53 -050019 isOk = self.check_cxx(includes='%s/include' % root,
20 libpath='%s/lib' % root,
Alexander Afanasyev5cda2e02014-04-11 13:58:44 -070021 **kw)
22 else:
23 isOk = self.check_cxx(**kw)
24
25 if isOk:
26 self.env[kw['define_name']] = True