-
Notifications
You must be signed in to change notification settings - Fork 0
/
Minimal_SConstruct_to_build_with_CLAM_and_Qt4.mw
89 lines (68 loc) · 3.09 KB
/
Minimal_SConstruct_to_build_with_CLAM_and_Qt4.mw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
If you don't want to use SCons to build your application with clam, you can use pkg-config command in most of the platforms to get the proper compiler and library options.
For convenience we provide this minimal SContruct that builds any cxx file in the container directory and subdirectories. To build several binaries or changing the file containing the main or the name of the program, check the mainSources variable value.
You can enable or disable Qt4 and CLAM modules by uncommenting lines for the EnableQt4Modules and EnableClamModules calls.
Note: Due to a bug on the qt4 scons tool, If you have a class with the Q_OBJECT macro defined inline on the hxx file, you should create a cxx, even if empty, for the moc compiler to be run. Otherwise you'll get undefined symbols errors.
== SConstruct (for your own project) ==
import os, glob, sys
def scanFiles(pattern, paths) :
files = []
for path in paths :
files+=glob.glob(os.path.join(path,pattern))
return files
def recursiveDirs(root) :
return filter( (lambda a : a.rfind( ".svn")==-1 ), [ a[0] for a in os.walk(root)] )
options = Options('options.cache', ARGUMENTS)
options.Add(PathOption('clam_prefix', 'The prefix where CLAM was installed', '''''''))
env = Environment(ENV=os.environ, options=options)
options.Save('options.cache', env)
Help(options.GenerateHelpText(env))
env.SConsignFile() # Single signature file
CLAMInstallDir = env['clam_prefix']
clam_sconstoolspath = os.path.join(CLAMInstallDir,'share','clam','sconstools')
env.Tool('qt4', toolpath=[clam_sconstoolspath])
env.EnableQt4Modules([
'QtCore',
'QtGui',
# 'QtOpenGL',
# 'QtSql',
# 'QtNetwork',
# 'QtTest',
# 'QtXml',
# 'QtSvg',
# 'QtUiTools',
# 'QtDesigner',
# 'Qt3Support',
], debug=False)
env['CXXFILESUFFIX'] = '.cxx'
env['QT4_UICDECLSUFFIX'] = '.hxx'
env['QT4_MOCHPREFIX'] = os.path.join('generated','moc_')
env['QT4_UICDECLPREFIX'] = os.path.join('generated','uic_')
env['QT4_QRCCXXPREFIX'] = os.path.join('generated','qrc_')
env.Tool('clam', toolpath=[clam_sconstoolspath])
env.EnableClamModules([
'clam_core',
'clam_audioio',
'clam_processing',
] , CLAMInstallDir)
mainSources = {
'MyProgram' :'./main.cxx',
}
sourcePaths = recursiveDirs(".")
sources = scanFiles('*.cxx', sourcePaths)
sources = filter( (lambda a : a.rfind( "moc_")==-1 ), sources )
sources = filter( (lambda a : a.rfind( "qrc_")==-1 ), sources )
sources = dict.fromkeys(sources).keys()
for mainSource in mainSources.values() :
sources.remove(mainSource)
qrcfiles = scanFiles("*.qrc", sourcePaths)
if qrcfiles : sources += env.Qrc(source=qrcfiles)
uifiles = scanFiles("*.ui", sourcePaths)
if uifiles: uiheaders = env.Uic4(source=uifiles)
if sys.platform=='win32' :
env.Append(CPPFLAGS=['-D_USE_MATH_DEFINES']) # to have M_PI defined
if sys.platform=='linux2' :
env.Append( CCFLAGS=['-g','-O3','-Wall'] )
programs = [ env.Program(target=program, source = [main] + sources)
for program, main in mainSources.items()]
env.Default(programs)
You can try this SConstruct with the main available in [[Constructing and playing a simple network]].