zxing/cpp/SConscript
smparkes@smparkes.net 1a53f4f875 Fix a few issues in test raised by the stricter gcc flags. Closes issue 1085.
- Some of the cpp tests still fail to compile, but that's covered in issue 1066.
- I tweaked the SConscript to be a little happier with OS X and cppunit and imagemagick
in /opt/local.  These should be benign on other systems but let me know if they aren't
and I'll back tweak them or back them out.

git-svn-id: https://zxing.googlecode.com/svn/trunk@2057 59b500cc-1b3d-0410-9834-0bbf25fbcc57
2011-11-30 00:47:33 +00:00

59 lines
1.8 KiB
Python

# -*- python -*-
Decider('MD5')
vars = Variables()
vars.Add(BoolVariable('DEBUG', 'Set to disable optimizations', 1))
vars.Add(BoolVariable('PIC', 'Set to 1 for to always generate PIC code', 0))
env = Environment(variables = vars)
# env.Replace(CXX = "clang++")
debug = env['DEBUG']
compile_options = {}
flags = []
if debug:
#compile_options['CPPDEFINES'] = "-DDEBUG"
flags.append("-O0 -g3 -ggdb -Wall")
else:
flags.append("-Os -g3 -Wall")
if env['PIC']:
flags.append("-fPIC")
flags.append("-Wextra -Werror")
# Can't enable unless we get rid of the dynamic variable length arrays
# flags.append("-pedantic")
compile_options['CXXFLAGS'] = ' '.join(flags)
compile_options['LINKFLAGS'] = "-ldl -L/usr/lib -L/opt/local/lib"
def all_files(dir, ext='.cpp', level=6):
files = []
for i in range(1, level):
files += Glob(dir + ('/*' * i) + ext)
return files
magick_include = ['/usr/include/ImageMagick/', '/opt/local/include/ImageMagick/']
magick_libs = ['Magick++', 'MagickWand', 'MagickCore', 'iconv']
cppunit_include = ['/opt/local/include/']
cppunit_libs = ['cppunit']
zxing_files = all_files('core/src')
zxing_include = ['core/src']
zxing_libs = env.Library('zxing', source=zxing_files, CPPPATH=zxing_include, **compile_options)
app_files = ['magick/src/MagickBitmapSource.cpp', 'magick/src/main.cpp']
app_executable = env.Program('zxing', app_files, CPPPATH=magick_include + zxing_include, LIBS=zxing_libs + magick_libs, **compile_options)
test_files = all_files('core/tests/src')
test_executable = env.Program('testrunner', test_files, CPPPATH=zxing_include + cppunit_include, LIBS=zxing_libs + cppunit_libs, **compile_options)
Alias('lib', zxing_libs)
Alias('tests', test_executable)
Alias('zxing', app_executable)