project(ktimetracker)

macro_bool_to_01(X11_Xscreensaver_LIB HAVE_LIBXSS)
configure_file(config-karm.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-karm.h )


add_subdirectory( kcmconfigs ) 
add_subdirectory( support ) 
add_subdirectory( pics ) 
add_subdirectory( test ) 

include_directories( ${KDE4_INCLUDE_DIR}/kcal ${CMAKE_SOURCE_DIR}/kresources/remote  )


########### next target ###############
set(ktimetracker_shared_SRCS
	desktoptracker.cpp 
	edittaskdialog.cpp idletimedetector.cpp 
	timekard.cpp ktimetrackerutility.cpp ktimewidget.cpp
	karmstorage.cpp mainwindow.cpp preferences.cpp 
	task.cpp taskview.cpp tray.cpp focusdetector.cpp
	csvexportdialog.cpp plannerparser.cpp 
	treeviewheadercontextmenu.cpp edithistorydialog.cpp timetrackerwidget.cpp 
        focusdetectornotifier.cpp
 )

qt4_add_dbus_adaptor( ktimetracker_shared_SRCS
        org.kde.ktimetracker.ktimetracker.xml
        timetrackerwidget.h
        TimetrackerWidget
        mainadaptor
        MainAdaptor )

qt4_add_dbus_adaptor( ktimetracker_shared_SRCS
        org.kde.ktimetracker.storage.xml
        taskview.h
        TaskView
        storageadaptor
        StorageAdaptor )

kde4_add_ui_files( ktimetracker_shared_SRCS
        csvexportdialog_base.ui 
        cfgbehavior.ui 
        cfgdisplay.ui
        cfgstorage.ui )

kde4_add_kcfg_files( ktimetracker_shared_SRCS ktimetracker.kcfgc )

set(ktimetracker_SRCS main.cpp ${ktimetracker_shared_SRCS})


kde4_add_executable(karm karm.cpp)

kde4_add_app_icon(ktimetracker_SRCS "hi*-app-ktimetracker.png")

kde4_add_executable(ktimetracker ${ktimetracker_SRCS})


target_link_libraries(karm   ${KDE4_KIO_LIBS} ${KDE4_KCAL_LIBS} kdepim kcal_resourceremote)

target_link_libraries(ktimetracker   ${KDE4_KIO_LIBS} ${KDE4_KPARTS_LIBRARY} ${KDE4_KCAL_LIBS} kdepim  kcal_resourceremote ${X11_X11_LIB})
if(X11_Xscreensaver_LIB)
	target_link_libraries(ktimetracker  ${X11_Xscreensaver_LIB} )
endif(X11_Xscreensaver_LIB)

install( TARGETS karm  ${INSTALL_TARGETS_DEFAULT_ARGS} )
install( TARGETS ktimetracker  ${INSTALL_TARGETS_DEFAULT_ARGS} )


########### next target ###############

set(ktimetrackerpart_PART_SRCS ktimetrackerpart.cpp ${ktimetracker_shared_SRCS})

kde4_add_plugin(ktimetrackerpart ${ktimetrackerpart_PART_SRCS})

target_link_libraries(ktimetrackerpart  ${KDE4_KCAL_LIBS}  ${KDE4_KIO_LIBS} ${KDE4_KPARTS_LIBS} kdepim kcal_resourceremote ${X11_X11_LIB})
if(X11_Xscreensaver_LIB)
	target_link_libraries(ktimetrackerpart  ${X11_Xscreensaver_LIB})
endif(X11_Xscreensaver_LIB)


install(TARGETS ktimetrackerpart  DESTINATION ${PLUGIN_INSTALL_DIR})


########### install files ###############

install( FILES ktimetrackerpart.desktop  DESTINATION ${SERVICES_INSTALL_DIR} )
install( FILES ktimetrackerui.rc  DESTINATION ${DATA_INSTALL_DIR}/ktimetracker )

kde4_install_icons( ${ICON_INSTALL_DIR} )
install( FILES org.kde.ktimetracker.ktimetracker.xml DESTINATION ${KDE4_DBUS_INTERFACES_DIR} )
