
include_directories(
  ${CMAKE_BINARY_DIR}
  ${CMAKE_SOURCE_DIR}
  ${CMAKE_BINARY_DIR}/include
  ${CMAKE_CURRENT_BINARY_DIR}
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${TDE_INCLUDE_DIR}
  ${TQT_INCLUDE_DIRS}
)

link_directories(
  ${TQT_LIBRARY_DIRS}
)


##### generate kmmwidgets.cpp

add_custom_command(
  OUTPUT kmmwidgets.cpp
  COMMENT "Generating kmymoney2/widgets/kmmwidgets.cpp"
  COMMAND ${KDE3_MAKETDEWIDGETS_EXECUTABLE}
    -g KMyMoney -n CustomWidgetPlugin -o kmmwidgets.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/kmymoney.widgets
  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/kmymoney.widgets
)


##### widgets (static)

tde_add_library( widgets STATIC_PIC AUTOMOC
  SOURCES
    kbudgetvalues.cpp
    kbudgetvaluesdecl.ui
    kguiutils.cpp
    tdelistviewsearchline.cpp
    kmymoneyaccountcombo.cpp
    kmymoneyaccountcompletion.cpp
    kmymoneyaccountselector.cpp
    kmymoneyaccounttreebase.cpp
    kmymoneyaccounttree.cpp
    kmymoneyaccounttreebudget.cpp
    kmymoneyaccounttreeforecast.cpp
    kmymoneybriefschedule.cpp
    kmymoneycalculator.cpp
    kmymoneycalendar.cpp
    kmymoneycategory.cpp
    kmymoneychecklistitem.cpp
    kmymoneycombo.cpp
    kmymoneycompletion.cpp
    kmymoneycurrencyselector.cpp
    kmymoneydateinput.cpp
    kmymoneydatetbl.cpp
    kmymoneyedit.cpp
    kmymoneyforecastlistviewitem.cpp
    kmymoneygpgconfig.cpp
    kmymoneygpgconfigdecl.ui
    kmymoneylineedit.cpp
    kmymoneylistviewitem.cpp
    kmymoneyonlinequoteconfig.cpp
    kmymoneyonlinequoteconfigdecl.ui
    kmymoneypriceview.cpp
    kmymoneyreportconfigtab1decl.ui
    kmymoneyreportconfigtab2decl.ui
    kmymoneyreportconfigtab3decl.ui
    kmymoneyreportconfigtabchartdecl.ui
    kmymoneyreportcontroldecl.ui
    kmymoneyscheduledcalendar.cpp
    kmymoneyscheduleddatetbl.cpp
    kmymoneyselector.cpp
    kmymoneytitlelabel.cpp
    kmymoneywizard.cpp
    kschedulebriefwidget.ui
    register.cpp
    registeritem.cpp
    registersearchline.cpp
    transaction.cpp
    scheduledtransaction.cpp
    stdtransactiondownloaded.cpp
    stdtransactionmatched.cpp
    transactioneditorcontainer.cpp
    transactionform.cpp
    kaccounttemplateselectordecl.ui
    kaccounttemplateselector.cpp
    transactionsortoption.ui
    selectedtransaction.cpp

  LINK
    tdeui-shared

  DEPENDENCIES
    kmm-includes
)


##### kmymoney (shared)

if( BUILD_DESIGNER_PLUGIN )

  add_custom_target( kmm-widgets-generated
    DEPENDS
      ${CMAKE_CURRENT_BINARY_DIR}/kbudgetvaluesdecl.cpp
      ${CMAKE_CURRENT_BINARY_DIR}/kbudgetvaluesdecl.h
      ${CMAKE_CURRENT_BINARY_DIR}/kaccounttemplateselectordecl.cpp
      ${CMAKE_CURRENT_BINARY_DIR}/kaccounttemplateselectordecl.h
      ${CMAKE_CURRENT_BINARY_DIR}/kmmwidgets.cpp
      ${CMAKE_CURRENT_BINARY_DIR}/transactionsortoption.cpp
      ${CMAKE_CURRENT_BINARY_DIR}/transactionsortoption.h
  )

  tde_add_library( kmymoney SHARED AUTOMOC
    SOURCES
      kmymoneycompletion.cpp
      kmymoneyaccountcombo.cpp
      kmymoneyaccountcompletion.cpp
      kmymoneycurrencyselector.cpp
      kmymoneyaccountselector.cpp
      kmymoneydatetbl.cpp
      kmymoneycalculator.cpp
      kmymoneycategory.cpp
      kmymoneycombo.cpp
      kmymoneylineedit.cpp
      kmymoneyedit.cpp
      kmymoneydateinput.cpp
      kmymoneyaccounttree.cpp
      kmymoneytitlelabel.cpp
      kguiutils.cpp
      kmymoneyaccounttreebase.cpp
      kmymoneyaccounttreebudget.cpp
      kmymoneyaccounttreeforecast.cpp
      register.cpp
      registeritem.cpp
      transaction.cpp
      scheduledtransaction.cpp
      selectedtransaction.cpp
      stdtransactiondownloaded.cpp
      stdtransactionmatched.cpp
      transactionform.cpp
      kmymoneychecklistitem.cpp
      kmymoneylistviewitem.cpp
      kmymoneyselector.cpp
      kbudgetvalues.cpp
      kaccounttemplateselector.cpp

      ${CMAKE_CURRENT_BINARY_DIR}/kbudgetvaluesdecl.cpp
      ${CMAKE_CURRENT_BINARY_DIR}/kaccounttemplateselectordecl.cpp
      ${CMAKE_CURRENT_BINARY_DIR}/kmmwidgets.cpp
      ${CMAKE_CURRENT_BINARY_DIR}/transactionsortoption.cpp

      void-timetrace.cpp

    LINK
      kmymoneysettings-static
      kmm_mymoney-static
      kmm_kdchart-static
      converter-static
      dialogs-static
      reports-static
      storage-static
      tdecore-shared tdeui-shared tdeio-shared

    DEPENDENCIES
      kmm-includes
      kmm-widgets-generated

    DESTINATION "${TQT_PLUGINS_DIR}/designer"
  )

  # Make sure to compile the TQt designer version.
  set_property(
    TARGET kmymoney-shared
    APPEND PROPERTY COMPILE_DEFINITIONS KMM_DESIGNER
  )

endif()


##### other data

kmm_install_includes(
  FILES
    kmymoneydateinput.h
    kmymoneyedit.h
    kmymoneytitlelabel.h
    kmymoneyaccountselector.h
    kmymoneycategory.h
    kmymoneyaccounttreebase.h
    kmymoneyaccounttree.h
    kmymoneycurrencyselector.h
    kguiutils.h
    kmymoneywizard.h
    kmymoneyaccounttreebudget.h
    kmymoneyaccounttreeforecast.h
    kmymoneyaccountcombo.h
    register.h
    registeritem.h
    transaction.h
    scheduledtransaction.h
    stdtransactiondownloaded.h
    stdtransactionmatched.h
    selectedtransaction.h
    transactionform.h
    transactioneditorcontainer.h
    kmymoneylineedit.h
    kmymoneychecklistitem.h
    kmymoneylistviewitem.h
    kmymoneyforecastlistviewitem.h
    kmymoneyselector.h
    kmymoneyaccountcompletion.h
    kmymoneycompletion.h
    kmymoneycombo.h
    kbudgetvalues.h
    kaccounttemplateselector.h
    ${CMAKE_CURRENT_BINARY_DIR}/kbudgetvaluesdecl.h
    ${CMAKE_CURRENT_BINARY_DIR}/transactionsortoption.h
  DESTINATION ${INCLUDE_INSTALL_DIR}/kmymoney
)
