Alexander Afanasyev | 5cda2e0 | 2014-04-11 13:58:44 -0700 | [diff] [blame] | 1 | # encoding: utf-8 |
| 2 | |
| 3 | from waflib import Options, Logs |
| 4 | from waflib.Configure import conf |
| 5 | |
| 6 | def addDependencyOptions(self, opt, name, extraHelp=''): |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 7 | opt.add_option('--with-%s' % name, metavar='PATH', |
Alexander Afanasyev | 5cda2e0 | 2014-04-11 13:58:44 -0700 | [diff] [blame] | 8 | help='Path to %s, e.g., /usr/local %s' % (name, extraHelp)) |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 9 | |
| 10 | setattr(Options.OptionsContext, 'addDependencyOptions', addDependencyOptions) |
Alexander Afanasyev | 5cda2e0 | 2014-04-11 13:58:44 -0700 | [diff] [blame] | 11 | |
| 12 | @conf |
| 13 | def checkDependency(self, name, **kw): |
| 14 | root = kw.get('path', getattr(Options.options, 'with_%s' % name)) |
| 15 | kw['msg'] = kw.get('msg', 'Checking for %s library' % name) |
| 16 | kw['uselib_store'] = kw.get('uselib_store', name.upper()) |
| 17 | kw['define_name'] = kw.get('define_name', 'HAVE_%s' % kw['uselib_store']) |
| 18 | kw['mandatory'] = kw.get('mandatory', True) |
| 19 | |
| 20 | if root: |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 21 | isOk = self.check_cxx(includes='%s/include' % root, |
| 22 | libpath='%s/lib' % root, |
Alexander Afanasyev | 5cda2e0 | 2014-04-11 13:58:44 -0700 | [diff] [blame] | 23 | **kw) |
| 24 | else: |
| 25 | isOk = self.check_cxx(**kw) |
| 26 | |
| 27 | if isOk: |
| 28 | self.env[kw['define_name']] = True |