Import('qt_env')

env = qt_env.Clone()

modules = [
    'Script',
    'Core',
    'Gui',
    'Declarative'
]

if env['QT_MAJOR_VERSION'] > 4:
    modules += [
        'Widgets',
        'Qml',
        'QuickWidgets',
        'WinExtras'
    ]

env.EnableQtModules(*modules)

env.Uic(Glob('*.ui'))

env.AppendUnique(LIBS = ['user32', 'shell32', 'ole32'])

# We have to 'persuade' moc to generate certain other targets and inject them
# into the list of cpps
targets = env.AddExtraMoc(env.Glob('*.h'))

# Note the order of this is important, or you can pick up the wrong report.h...
env.AppendUnique(CPPPATH = [
    '.',            # Why is this necessary?
    '${BOOSTPATH}',
])

env.AppendUnique(CPPDEFINES = [
    'UIBASE_LIBRARY',
    'UIBASE_EXPORT'
])

#CONFIG(debug, debug|release) {
#} else {
#  QMAKE_CXXFLAGS += /Zi /GL
#  QMAKE_LFLAGS += /DEBUG /LTCG /LARGEADDRESSAWARE /OPT:REF /OPT:ICF
#}

lib = env.SharedLibrary('uibase', env.Glob('*.cpp') + targets)

env.InstallModule(lib)

res = env['QT_USED_MODULES']
Return('res')
