Import('qt_env')

env = qt_env.Clone()

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

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

env.EnableQtModules(*modules)

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

env.RequireLibraries('uibase')

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

# Note the order of this is important, or you can pick up the wrong report.h...
# Doing appendunique seems to throw the moc code into a tizzy
env['CPPPATH'] += [
    '.',            # Why is this necessary?
    '${BOOSTPATH}',
]

env.AppendUnique(LINKFLAGS = [
    '/SUBSYSTEM:WINDOWS',
    '${EXE_MANIFEST_DEPENDENCY}'
])

ic_env = env.Clone()
ic_env.AppendUnique(CPPPATH = '../organizer')
ic_env.AppendUnique(CPPDEFINES = 'SCONS_BUILD')
icon = ic_env.RES('app_icon.rc')
# This extra cpp is just sad. It probably means something is set up wrong.
prog = env.Program('nxmhandler',
              env.Glob('*.cpp') + env.Object('json.obj', '../uibase/json.cpp') +
                                                                           icon)

env.InstallModule(prog)

#release:QMAKE_CXXFLAGS += /Zi /GL
#release:QMAKE_LFLAGS += /DEBUG /LTCG /OPT:REF /OPT:ICF

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