# fcdCompile and fcdEdit

import os.path

Import('*')

sources = Glob('*.cpp')
headers = Glob('*.h')

uis = Glob('*.ui')
new_sources, new_headers = GetUiSources(uis)

AppendFilesUnique(sources, new_sources)
AppendFilesUnique(headers, new_headers)

AppendFilesUnique(sources, GetMocSources(headers))

sources_term = Split("""
    FieldContainer.cpp
    Field.cpp
    main.cpp
    ParseComandLine.cpp
""")

def custom(env):

    # ok we are building two different executables fcdCompile and fcdEdit from
    # the same source so we need to create the obj files in two different directories.
    env['OSG_OBJDIR']  += 'qt'

    env.Append(CPPPATH=env.get('QTCPPPATH'))
    env.Append(LIBPATH=env.get('QTLIBPATH'))
    env.Append(LIBS=env.get('OSG_WINDOW_QT_LIBS'))

    CreateUiSources(env, uis)
    CreateMocSources(env, headers)

if tc.is_win32():
    dep_LIBS = ['OSGWindowWIN32']
else:
    dep_LIBS = ['OSGWindowX']


BuildProgram(tc, 'fcdCompile', sources_term, tools=[],
             updates=[OpenSGLibrary(['OSGBase'])],
             CPPPATH=[Dir('.'), Dir('$OSG_OBJDIR'), env['PREFIX'].Dir('include')],
             CPPDEFINES=['FCD_TERM', 'OSG_BUILD_DLL'])

if _po.getOption('qt'):
    BuildProgram(tc, 'fcdEdit', sources, tools=[],
                 updates=[custom, OpenSGLibrary(['OSGWindowQT', 'OSGSystem', 'OSGBase'] + dep_LIBS)],
                 CPPPATH=[Dir('.'), Dir('$OSG_OBJDIR'), env['PREFIX'].Dir('include')],
                 CPPDEFINES=['OSG_WITH_QT', 'OSG_BUILD_DLL'])
