
add_subdirectory( mymoney )
add_subdirectory( widgets )
add_subdirectory( dialogs )
add_subdirectory( wizards )
add_subdirectory( views )
add_subdirectory( converter )
add_subdirectory( pics )
add_subdirectory( icons )
add_subdirectory( html )
add_subdirectory( plugins )
add_subdirectory( reports )
add_subdirectory( misc )


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

link_directories(
  ${TQT_LIBRARY_DIRS}
)


##### kmymoneysettings (static)

tde_add_library( kmymoneysettings STATIC_PIC AUTOMOC
  SOURCES
    kmymoneysettings.kcfgc
    kmymoneyglobalsettings.cpp
    kmymoneyutils.cpp

  LINK
    dialogs-static

  DEPENDENCIES
    kmm-includes
)


##### kmymoney2 (executable) ####################

tde_add_executable( kmymoney2 AUTOMOC
  SOURCES
    kstartuplogo.cpp
    kmymoney2.cpp
    main.cpp
    kmymoney2.stub
    kmymoney2.skel

  LINK
    kmymoneysettings-static kgpgfile-static
    settings-static views-static interfaces-static
    newaccountwizard-static newuserwizard-static wizardpages-static
    kmm_mymoney-shared kmm_plugin-shared kmm_kdchart-shared
    tdecore-shared tdeui-shared tdeio-shared tdehtml-shared tdeabc-shared

  DESTINATION ${BIN_INSTALL_DIR}
)

tde_install_symlink( kmymoney2 ${BIN_INSTALL_DIR}/kmymoney )


##### kmymoneytest (test) #######################

tde_add_check_executable( kmymoneytest AUTOMOC
  SOURCES
    kmymoneytest.cpp

  LINK
    kmymoneysettings-static
    convertertest-static
    mymoneytest-static
    reportstest-static
    storagetest-static
    kmm_mymoney-shared
    tdeio-shared
    ${CPPUNIT_LIBRARY}
)


##### other data

tde_install_icons()

file( GLOB mimetype_icons RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} mimetype*.png )
list( SORT mimetype_icons )
foreach( mimetype_icon IN LISTS mimetype_icons )
  string( REGEX MATCH "^([0-9a-zA-Z]+)_([a-z]+)_(.*)\\.png$" _dummy "${mimetype_icon}" )
  set( _type  "${CMAKE_MATCH_1}" )
  set( _name  "${CMAKE_MATCH_2}" )
  set( _size  "${CMAKE_MATCH_3}" )
  install(
    FILES ${mimetype_icon}
    DESTINATION ${ICON_INSTALL_DIR}/hicolor/${_size}/mimetypes RENAME ${_name}.png
  )
endforeach()

tde_create_translated_desktop( kmymoney2.desktop )

tde_create_translated_desktop(
  SOURCE x-kmymoney2.desktop
  DESTINATION ${MIME_INSTALL_DIR}/application
)

install(
  FILES kmymoney2ui.rc tips
  DESTINATION ${DATA_INSTALL_DIR}/kmymoney2
)

install(
  FILES kmymoney2.kcfg
  DESTINATION ${KCFG_INSTALL_DIR}
)

install(
  DIRECTORY templates/
  DESTINATION ${DATA_INSTALL_DIR}/kmymoney2/templates
  PATTERN "Makefile.am" EXCLUDE
)

kmm_install_includes(
  FILES
    export.h
    kmymoneyutils.h
    kmymoneyglobalsettings.h
    ${CMAKE_CURRENT_BINARY_DIR}/kmymoneysettings.h
  DESTINATION ${INCLUDE_INSTALL_DIR}/kmymoney
)
