#################################################
#
#  (C) 2010-2011 Serghei Amelian
#  serghei (DOT) amelian (AT) gmail.com
#
#  Improvements and feedback are welcome
#
#  This file is released under GPL >= 2
#
#################################################

include_directories(
  ${CMAKE_CURRENT_BINARY_DIR}
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${CMAKE_CURRENT_SOURCE_DIR}/private
  ${QT_INCLUDE_DIR}
)

link_directories(
  ${QT_LIBRARY_DIR}
)


##### headers ###################################

configure_file( tqt.h.cmake tqt.h @ONLY )

install( FILES
    ${CMAKE_CURRENT_BINARY_DIR}/tqt.h tqtglobaldefines.h tqaccel.h tqaccessible.h
    tqaction.h tqapplication.h tqasyncio.h tqbuttongroup.h tqbutton.h tqcanvas.h
    tqcdestyle.h tqcheckbox.h tqclipboard.h tqcolordialog.h tqcombobox.h
    tqcommonstyle.h tqdatabrowser.h tqdatatable.h tqdataview.h tqdatetimeedit.h
    tqdesktopwidget.h tqdial.h tqdialog.h tqdns.h tqdockarea.h tqdockwindow.h
    tqdragobject.h tqerrormessage.h tqeventloop.h tqfiledialog.h tqfontdialog.h
    tqframe.h tqftp.h tqgl.h tqgplugin.h tqgrid.h tqgridview.h tqgroupbox.h
    tqguardedptr.h tqhbox.h tqhbuttongroup.h tqheader.h tqhgroupbox.h
    tqhttp.h tqiconview.h tqimageformatplugin.h tqinputdialog.h tqlabel.h
    tqlayout.h tqlcdnumber.h tqlineedit.h tqlistbox.h tqlistview.h tqlocalfs.h
    tqmainwindow.h tqmenubar.h tqmessagebox.h tqmotifplusstyle.h tqmotifstyle.h
    tqmultilineedit.h tqnetworkprotocol.h tqnp.h tqobjectcleanuphandler.h
    tqobject.h tqplatinumstyle.h tqpopupmenu.h tqprintdialog.h tqprocess.h
    tqprogressbar.h tqprogressdialog.h tqpushbutton.h tqradiobutton.h
    tqrangecontrol.h tqscrollbar.h tqscrollview.h tqsemimodal.h tqserversocket.h
    tqsessionmanager.h tqsgistyle.h tqsignal.h tqsignalmapper.h tqsizegrip.h
    tqslider.h tqsocket.h tqsocketnotifier.h tqsound.h tqspinbox.h tqsplashscreen.h
    tqsplitter.h tqsqldatabase.h tqsqldriver.h tqsqldriverplugin.h tqsqlform.h
    tqsqlquery.h tqstatusbar.h tqstyle.h tqstyleplugin.h tqstylesheet.h tqtabbar.h
    tqtabdialog.h tqtable.h tqtabwidget.h tqtextbrowser.h tqtextcodecplugin.h
    tqtextedit.h tqtextview.h tqtimer.h tqtoolbar.h tqtoolbox.h tqtoolbutton.h
    tqtooltip.h tqtranslator.h tqurloperator.h tqvalidator.h tqvbox.h
    tqvbuttongroup.h tqvgroupbox.h tqwidget.h tqwidgetplugin.h tqwidgetstack.h
    tqwindowsstyle.h tqwizard.h tqworkspace.h tqapp.h tqarray.h tqassistantclient.h
    tqbitarry.h tqbttngrp.h tqchkbox.h tqclipbrd.h tqcollect.h tqcollection.h tqcombo.h
    tqconfig.h tqconnect.h tqdatetm.h tqdrawutl.h tqdstream.h tqfeatures.h
    tqfiledef.h tqfiledlg.h tqfileinf.h tqfontinf.h tqfontmet.h tqgbkcodec.h
    tqgeneric.h tqgif.h tqglobal.h tqgrpbox.h tqintcach.h tqiodev.h tqjpegio.h
    tqkeycode.h tqlined.h tqlist.h tqmenudta.h tqmetaobj.h tqmlined.h tqmngio.h
    tqmodules.h tqmsgbox.h tqmultilinedit.h tqnetwork.h tqobjcoll.h tqobjdefs.h
    tqpaintdc.h tqpaintd.h tqpdevmet.h tqpmcache.h tqpntarry.h tqpopmenu.h
    tqprndlg.h tqprogbar.h tqprogdlg.h tqpushbt.h tqqueue.h tqradiobt.h tqrangect.h
    tqscrbar.h tqsession.h tqsocknot.h tqstack.h tqtabdlg.h tqtstream.h tqvector.h
    tqwidcoll.h tqwindefs.h tqwindowdefs.h tqwinexport.h tq1xcompatibility.h
    tqabstractlayout.h tqasciicache.h tqasciidict.h tqasyncimageio.h tqbig5codec.h
    tqbitarray.h tqbitmap.h tqbrush.h tqbuffer.h tqcache.h tqcleanuphandler.h
    tqcolor.h tqcompactstyle.h tqconnection.h tqcstring.h tqcursor.h tqdatastream.h
    tqdatetime.h tqdeepcopy.h tqdict.h tqdir.h tqdom.h tqdrawutil.h tqdropsite.h
    tqeditorfactory.h tqeucjpcodec.h tqeuckrcodec.h tqevent.h tqfile.h tqfileinfo.h
    tqfocusdata.h tqfontdatabase.h tqfont.h tqfontinfo.h tqfontmetrics.h
    tqgarray.h tqgb18030codec.h tqgcache.h tqgdict.h tqglcolormap.h tqglist.h
    tqgvector.h tqhostaddress.h tqiconset.h tqimage.h tqintcache.h tqintdict.h
    tqinterlacestyle.h tqiodevice.h tqjiscodec.h tqjpunicode.h tqkeysequence.h
    tqlibrary.h tqlocale.h tqmap.h tqmemarray.h tqmenudata.h tqmetaobject.h
    tqmime.h tqmovie.h tqmutex.h tqnamespace.h tqobjectdict.h tqobjectlist.h
    tqpaintdevice.h tqpaintdevicemetrics.h tqpainter.h tqpair.h tqpalette.h tqpen.h
    tqpicture.h tqpixmapcache.h tqpixmap.h tqpngio.h tqpointarray.h tqpoint.h
    tqpolygonscanner.h tqprinter.h tqptrcollection.h tqptrdict.h tqptrlist.h
    tqptrqueue.h tqptrstack.h tqptrvector.h tqrect.h tqregexp.h tqregion.h
    tqrtlcodec.h tqsemaphore.h tqsettings.h tqshared.h tqsignalslotimp.h
    tqsimplerichtext.h tqsize.h tqsizepolicy.h tqsjiscodec.h tqsocketdevice.h
    tqsortedlist.h tqsqlcursor.h tqsqleditorfactory.h tqsqlerror.h tqsqlfield.h
    tqsql.h tqsqlindex.h tqsqlpropertymap.h tqsqlrecord.h tqsqlresult.h
    tqsqlselectcursor.h tqstring.h tqstringlist.h tqstrlist.h tqstrvec.h
    tqstylefactory.h tqsyntaxhighlighter.h tqtextcodecfactory.h tqtextcodec.h
    tqtextstream.h tqthread.h tqthreadstorage.h tqtl.h tqtsciicodec.h tqurl.h
    tqurlinfo.h tqutfcodec.h tquuid.h tqvaluelist.h tqvaluestack.h tqvaluevector.h
    tqvariant.h tqvfbhdr.h tqwaitcondition.h tqwhatsthis.h tqwidgetfactory.h
    tqwidgetintdict.h tqwidgetlist.h tqwmatrix.h tqxml.h private/tqucomextra_p.h
    private/tqlayoutengine_p.h private/tqinternal_p.h private/tqeffects_p.h
    private/tqrichtext_p.h private/tqpluginmanager_p.h private/tqcom_p.h
    private/tqucom_p.h private/tqwidgetinterface_p.h private/tqtextengine_p.h
    tqlistiterator.h
  DESTINATION ${INCLUDE_INSTALL_DIR} )

install(
  DIRECTORY tqt4/Qt
  DESTINATION ${INCLUDE_INSTALL_DIR}
  PATTERN ".svn" EXCLUDE )


##### tqt tools #################################

configure_file( tmoc.cmake tmoc @ONLY )
configure_file( tqt-replace.cmake tqt-replace @ONLY )
configure_file( tqt-replace-stream.cmake tqt-replace-stream @ONLY )

install( PROGRAMS
    moc-tqt uic-tqt mcopidl-tqt dcopidl-tqt dcopidlng-tqt
    dcopidl2cpp-tqt convert_qt_tqt1 convert_qt_tqt2
    convert_qt_tqt3 ${CMAKE_CURRENT_BINARY_DIR}/tmoc
    ${CMAKE_CURRENT_BINARY_DIR}/tqt-replace
    ${CMAKE_CURRENT_BINARY_DIR}/tqt-replace-stream
  DESTINATION ${BIN_INSTALL_DIR} )


##### tqt pkgconfig #############################

string( REGEX REPLACE "^${CMAKE_INSTALL_PREFIX}" "\${prefix}" PC_EXEC_PREFIX ${EXEC_INSTALL_PREFIX} )
string( REGEX REPLACE "^${CMAKE_INSTALL_PREFIX}" "\${prefix}" PC_INCLUDE_DIR ${INCLUDE_INSTALL_DIR} )
string( REGEX REPLACE "^${CMAKE_INSTALL_PREFIX}" "\${prefix}" PC_LIB_DIR ${LIB_INSTALL_DIR} )

unset( PC_QT_LIBRARIES )
foreach( _lib ${QT_LIBRARIES} )
  set( PC_QT_LIBRARIES "${PC_QT_LIBRARIES} -l${_lib}" )
endforeach( )

configure_file( tqt.pc.cmake tqt.pc @ONLY )

install( FILES ${CMAKE_CURRENT_BINARY_DIR}/tqt.pc DESTINATION ${PKGCONFIG_INSTALL_DIR} )


##### tqt (shared) ##############################


tde_add_library( tqt SHARED
  SOURCES
    tqt.cpp tqaccel.cpp tqaccessible.cpp tqaction.cpp tqapplication.cpp
    tqasyncio.cpp tqbuttongroup.cpp tqbutton.cpp tqcanvas.cpp tqcdestyle.cpp
    tqcheckbox.cpp tqclipboard.cpp tqcolordialog.cpp tqcombobox.cpp
    tqcommonstyle.cpp tqdatabrowser.cpp tqdatatable.cpp tqdataview.cpp
    tqdatetimeedit.cpp tqdesktopwidget.cpp tqdial.cpp tqdialog.cpp tqdns.cpp
    tqdockarea.cpp tqdockwindow.cpp tqdragobject.cpp tqerrormessage.cpp
    tqeventloop.cpp tqframe.cpp tqftp.cpp tqfiledialog.cpp tqfontdialog.cpp
    tqgl.cpp tqgplugin.cpp tqgrid.cpp tqgridview.cpp tqgroupbox.cpp
    tqguardedptr.cpp tqhbox.cpp tqhbuttongroup.cpp tqheader.cpp
    tqhgroupbox.cpp tqhttp.cpp tqiconview.cpp tqimageformatplugin.cpp
    tqinputdialog.cpp tqlabel.cpp tqlayout.cpp tqlcdnumber.cpp tqlineedit.cpp
    tqlistbox.cpp tqlistview.cpp tqlocalfs.cpp tqmainwindow.cpp tqmenubar.cpp
    tqmessagebox.cpp tqmotifplusstyle.cpp tqmotifstyle.cpp tqmultilineedit.cpp
    tqnetworkprotocol.cpp tqnp.cpp tqobjectcleanuphandler.cpp tqobject.cpp
    tqplatinumstyle.cpp tqpopupmenu.cpp tqprintdialog.cpp tqprocess.cpp
    tqprogressbar.cpp tqprogressdialog.cpp tqpushbutton.cpp tqradiobutton.cpp
    tqrangecontrol.cpp tqscrollbar.cpp tqscrollview.cpp tqsemimodal.cpp
    tqserversocket.cpp tqsessionmanager.cpp tqsgistyle.cpp tqsignal.cpp
    tqsignalmapper.cpp tqsizegrip.cpp tqslider.cpp tqsocket.cpp
    tqsocketnotifier.cpp tqsound.cpp tqspinbox.cpp tqsplashscreen.cpp
    tqsplitter.cpp tqsqldatabase.cpp tqsqldriver.cpp tqsqldriverplugin.cpp
    tqsqlform.cpp tqsqlquery.cpp tqstatusbar.cpp tqstyle.cpp tqstyleplugin.cpp
    tqstylesheet.cpp tqtabbar.cpp tqtabdialog.cpp tqtable.cpp tqtabwidget.cpp
    tqtextbrowser.cpp tqtextcodecplugin.cpp tqtextedit.cpp tqtextview.cpp
    tqtimer.cpp tqtoolbar.cpp tqtoolbox.cpp tqtoolbutton.cpp tqtooltip.cpp
    tqtranslator.cpp tqurloperator.cpp tqvalidator.cpp tqvbox.cpp
    tqvbuttongroup.cpp tqvgroupbox.cpp tqwidget.cpp tqwidgetplugin.cpp
    tqwidgetstack.cpp tqwindowsstyle.cpp tqwizard.cpp tqworkspace.cpp
    tq1xcompatibility.cpp tqabstractlayout.cpp tqasciicache.cpp tqasciidict.cpp
    tqasyncimageio.cpp tqbig5codec.cpp tqbitarray.cpp tqbitmap.cpp tqbrush.cpp
    tqbuffer.cpp tqcache.cpp tqcleanuphandler.cpp tqcolor.cpp tqcompactstyle.cpp
    tqconnection.cpp tqcstring.cpp tqcursor.cpp tqdatastream.cpp tqdatetime.cpp
    tqdeepcopy.cpp tqdict.cpp tqdir.cpp tqdom.cpp tqdrawutil.cpp tqdropsite.cpp
    tqeditorfactory.cpp tqeucjpcodec.cpp tqeuckrcodec.cpp tqevent.cpp tqfile.cpp
    tqfileinfo.cpp tqfocusdata.cpp tqfontdatabase.cpp tqfont.cpp tqfontinfo.cpp
    tqfontmetrics.cpp tqgarray.cpp tqgb18030codec.cpp tqgcache.cpp tqgdict.cpp
    tqglcolormap.cpp tqglist.cpp tqgvector.cpp tqhostaddress.cpp tqiconset.cpp
    tqimage.cpp tqintcache.cpp tqintdict.cpp tqinterlacestyle.cpp tqiodevice.cpp
    tqjiscodec.h tqjpunicode.cpp tqkeysequence.cpp tqlibrary.cpp tqlocale.cpp
    tqmap.cpp tqmemarray.cpp tqmenudata.cpp tqmetaobject.cpp tqmime.cpp tqmovie.cpp
    tqmutex.cpp tqnamespace.cpp tqobjectdict.cpp tqobjectlist.cpp tqpaintdevice.cpp
    tqpaintdevicemetrics.cpp tqpainter.cpp tqpair.cpp tqpalette.cpp tqpen.cpp
    tqpicture.cpp tqpixmapcache.cpp tqpixmap.cpp tqpngio.cpp tqpointarray.cpp
    tqpoint.cpp tqpolygonscanner.cpp tqprinter.cpp tqptrcollection.cpp
    tqptrdict.cpp tqptrlist.cpp tqptrqueue.cpp tqptrstack.cpp tqptrvector.cpp
    tqrect.cpp tqregexp.cpp tqregion.cpp tqrtlcodec.cpp tqsemaphore.cpp
    tqsettings.cpp tqshared.cpp tqsignalslotimp.cpp tqsimplerichtext.cpp tqsize.cpp
    tqsizepolicy.cpp tqsjiscodec.cpp tqsocketdevice.cpp tqsortedlist.cpp
    tqsqlcursor.cpp tqsqleditorfactory.cpp tqsqlerror.cpp tqsqlfield.cpp
    tqsql.cpp tqsqlindex.cpp tqsqlpropertymap.cpp tqsqlrecord.cpp tqsqlresult.cpp
    tqsqlselectcursor.cpp tqstring.cpp tqstringlist.cpp tqstrlist.cpp tqstrvec.cpp
    tqstylefactory.cpp tqsyntaxhighlighter.cpp tqtextcodecfactory.cpp
    tqtextcodec.cpp tqtextstream.cpp tqthread.cpp tqthreadstorage.cpp
    tqtl.cpp tqtsciicodec.cpp tqurl.cpp tqurlinfo.cpp tqutfcodec.cpp tquuid.cpp
    tqvaluelist.cpp tqvaluestack.cpp tqvaluevector.cpp tqvariant.cpp tqvfbhdr.cpp
    tqwaitcondition.cpp tqwhatsthis.cpp tqwidgetfactory.cpp tqwidgetintdict.cpp
    tqwidgetlist.cpp tqwmatrix.cpp tqxml.cpp private/tqucomextra_p.cpp
    tqlistiterator.cpp
  VERSION 4.2.0
  LINK ${QT_LIBRARIES}
  DESTINATION ${LIB_INSTALL_DIR}
)

##### tqassistantclient (shared) ##############################


  find_library( QASSISTANTCLIENT_STATIC libqassistantclient.a )

  if ( QASSISTANTCLIENT_STATIC )

    add_library(qassistantclient STATIC IMPORTED)
    set_property(TARGET qassistantclient PROPERTY
                 IMPORTED_LOCATION ${QASSISTANTCLIENT_STATIC})

    tde_add_library( tqassistantclient SHARED
      SOURCES
        tqassistantclient.cpp
      VERSION 4.2.0
      LINK ${QT_LIBRARIES}
      EMBED qassistantclient
      DESTINATION ${LIB_INSTALL_DIR}
    )

  else ( QASSISTANTCLIENT_STATIC )

    tde_add_library( tqassistantclient SHARED
      SOURCES
        tqassistantclient.cpp
      VERSION 4.2.0
      LINK ${QT_LIBRARIES} -lqassistantclient
      DESTINATION ${LIB_INSTALL_DIR}
    )

  endif ( QASSISTANTCLIENT_STATIC )
