Davide Pesavento | 936205d | 2024-02-27 21:42:44 -0500 | [diff] [blame^] | 1 | from waflib import Options |
Alexander Afanasyev | 5cda2e0 | 2014-04-11 13:58:44 -0700 | [diff] [blame] | 2 | from waflib.Configure import conf |
| 3 | |
| 4 | def addDependencyOptions(self, opt, name, extraHelp=''): |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 5 | opt.add_option('--with-%s' % name, metavar='PATH', |
Alexander Afanasyev | 5cda2e0 | 2014-04-11 13:58:44 -0700 | [diff] [blame] | 6 | help='Path to %s, e.g., /usr/local %s' % (name, extraHelp)) |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 7 | |
| 8 | setattr(Options.OptionsContext, 'addDependencyOptions', addDependencyOptions) |
Alexander Afanasyev | 5cda2e0 | 2014-04-11 13:58:44 -0700 | [diff] [blame] | 9 | |
| 10 | @conf |
| 11 | def 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 Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 19 | isOk = self.check_cxx(includes='%s/include' % root, |
| 20 | libpath='%s/lib' % root, |
Alexander Afanasyev | 5cda2e0 | 2014-04-11 13:58:44 -0700 | [diff] [blame] | 21 | **kw) |
| 22 | else: |
| 23 | isOk = self.check_cxx(**kw) |
| 24 | |
| 25 | if isOk: |
| 26 | self.env[kw['define_name']] = True |