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

project( cervisia )

add_subdirectory( cvsservice )
add_subdirectory( pics )

add_definitions( -D_BSD_SOURCE )

include_directories(
  ${CMAKE_CURRENT_BINARY_DIR}
  ${CMAKE_BINARY_DIR}/cervisia/cvsservice
  ${TDE_INCLUDE_DIR}
  ${TQT_INCLUDE_DIRS}
)

link_directories(
  ${TQT_LIBRARY_DIRS}
)


##### other data ################################

tde_install_icons( )

tde_create_translated_desktop(
  SOURCE cervisia.desktop
  PO_DIR cervisia-desktops
)

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

install( FILES
    cervisiaui.rc
  DESTINATION ${DATA_INSTALL_DIR}/cervisiapart )

install(
  FILES cervisiashellui.rc
  DESTINATION ${DATA_INSTALL_DIR}/cervisia
)

tde_create_translated_desktop(
  SOURCE eventsrc
  DESTINATION ${DATA_INSTALL_DIR}/cervisia
  PO_DIR cervisia-eventsrc
)

install( FILES
    cervisia.upd
  DESTINATION ${KCONF_UPDATE_INSTALL_DIR} )

install( PROGRAMS
    move_repositories.pl change_colors.pl
    cervisia-normalize_cvsroot.pl cervisia-change_repos_list.pl
  DESTINATION ${KCONF_UPDATE_INSTALL_DIR} )


macro( _pod2man )
  foreach( _pod ${ARGN} )
    add_custom_command(
      OUTPUT ${_pod}.1
      COMMAND pod2man ${CMAKE_CURRENT_SOURCE_DIR}/${_pod}.pod > ${_pod}.1.in
      COMMAND
        sed -e 's%_KDEHTMLDIR_%'${HTML_INSTALL_DIR}'%g;'
            -e 's%_KDECONFDIR_%'${CONFIG_INSTALL_DIR}'%g;'
            < ${_pod}.1.in > ${_pod}.1
      DEPENDS ${_pod}.pod )
    add_custom_target( "${_pod}-man" ALL DEPENDS ${_pod}.1 )
    install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${_pod}.1 DESTINATION ${MAN_INSTALL_DIR}/man1 )
  endforeach( )
endmacro()

_pod2man( cervisia )


##### cervisia (static) #########################

tde_add_library( cervisia STATIC_PIC AUTOMOC
  SOURCES
    annotatedlg.cpp diffdlg.cpp patchoptiondlg.cpp logdlg.cpp
    progressdlg.cpp progressdlg.skel resolvedlg.cpp resolvedlg_p.cpp
    annotateview.cpp diffview.cpp loglist.cpp logplainview.cpp
    logtree.cpp annotatectl.cpp loginfo.cpp misc.cpp qttableview.cpp
    tooltip.cpp cervisiasettings.kcfgc settingsdlg.cpp
    settingsdlg_advanced.ui
  DEPENDENCIES cvsservice-shared
)


##### libcervisiapart (module) ##################

tde_add_kpart( libcervisiapart AUTOMOC
  SOURCES
    updateview.cpp protocolview.cpp protocolview.skel watchdlg.cpp
    changelogdlg.cpp historydlg.cpp repositorydlg.cpp commitdlg.cpp
    checkoutdlg.cpp updatedlg.cpp tagdlg.cpp mergedlg.cpp cvsdir.cpp
    repositories.cpp cervisiapart.cpp addrepositorydlg.cpp
    addremovedlg.cpp watchersdlg.cpp updateview_items.cpp
    updateview_visitors.cpp entry.cpp entry_status.cpp stringmatcher.cpp
    cvsinitdlg.cpp ignorelistbase.cpp dirignorelist.cpp
    globalignorelist.cpp editwithmenu.cpp logmessageedit.cpp
  LINK cervisia-static cvsservice-shared tdeutils-shared
  DESTINATION ${PLUGIN_INSTALL_DIR}
)


##### cervisia (tdeinit) ########################

tde_add_tdeinit_executable( cervisia AUTOMOC
  SOURCES
    main.cpp cervisiashell.cpp
  LINK cervisia-static cvsservice-shared tdeutils-shared
)


##### install import cmake modules ###############

tde_install_export( )
