4 # written by Sylvain Rouquette, 2011
7 To add the freeimage tool to the waf file:
8 $ ./waf-light --tools=compat15,freeimage
9 or, if you have waf >= 1.6.2
10 $ ./waf update --files=freeimage
12 The wscript will look like:
15 opt.load('compiler_cxx freeimage')
18 conf.load('compiler_cxx freeimage')
20 # you can call check_freeimage with some parameters.
21 # It's optional on Linux, it's 'mandatory' on Windows if
22 # you didn't use --fi-path on the command-line
24 # conf.check_freeimage(path='FreeImage/Dist', fip=True)
27 bld(source='main.cpp', target='app', use='FREEIMAGE')
30 from waflib import Utils
31 from waflib.Configure import conf
35 opt.add_option('--fi-path', type='string', default='', dest='fi_path',
36 help='''path to the FreeImage directory \
37 where the files are e.g. /FreeImage/Dist''')
38 opt.add_option('--fip', action='store_true', default=False, dest='fip',
39 help='link with FreeImagePlus')
40 opt.add_option('--fi-static', action='store_true',
41 default=False, dest='fi_static',
42 help="link as shared libraries")
46 def check_freeimage(self, path=None, fip=False):
47 self.start_msg('Checking FreeImage')
48 if not self.env['CXX']:
49 self.fatal('you must load compiler_cxx before loading freeimage')
50 prefix = self.options.fi_static and 'ST' or ''
51 platform = Utils.unversioned_sys_platform()
52 if platform == 'win32':
54 self.fatal('you must specify the path to FreeImage. \
55 use --fi-path=/FreeImage/Dist')
57 self.env['INCLUDES_FREEIMAGE'] = path
58 self.env['%sLIBPATH_FREEIMAGE' % prefix] = path
61 libs.append('FreeImagePlus')
62 if platform == 'win32':
63 self.env['%sLIB_FREEIMAGE' % prefix] = libs
65 self.env['%sLIB_FREEIMAGE' % prefix] = [i.lower() for i in libs]
70 platform = Utils.unversioned_sys_platform()
71 if platform == 'win32' and not conf.options.fi_path:
73 conf.check_freeimage(conf.options.fi_path, conf.options.fip)