project(korganizer)
add_subdirectory( tests )

include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/interfaces
                     ${CMAKE_SOURCE_DIR}/libkholidays
                     ${CMAKE_SOURCE_DIR}/mimelib
                     ${CMAKE_SOURCE_DIR}/korganizer/printing
                     ${CMAKE_SOURCE_DIR}/kdgantt1
		     ${CMAKE_BINARY_DIR}/libkdepim
                     ${QT_INCLUDES} ${ZLIB_INCLUDE_DIR} )

add_definitions (-DQT3_SUPPORT -DQT3_SUPPORT_WARNINGS)

add_subdirectory( printing )
add_subdirectory( korgac )
add_subdirectory( pixmaps )
add_subdirectory( sounds )
add_subdirectory( plugins )
add_subdirectory( interfaces )

set( PERL ${PERL_EXECUTABLE} )
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ical2vcal.cmake ${CMAKE_CURRENT_BINARY_DIR}/ical2vcal @ONLY)


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

set(korganizer_bin_SRCS
   main.cpp
   korganizer.cpp
   koapp.cpp
)


kde4_add_executable(korganizer_bin ${korganizer_bin_SRCS})

set_target_properties(korganizer_bin  PROPERTIES OUTPUT_NAME korganizer)

target_link_libraries(korganizer_bin ${KDE4_KDECORE_LIBS} korganizer)

install(TARGETS korganizer_bin  DESTINATION ${BIN_INSTALL_DIR} )


########### next target ###############   # FIXME to be removed! (only needed for testing before copying everything to korganizer)

set(theme_bin_SRCS
   thememain.cpp
   themeimporter.cpp
   theme.cpp
)


kde4_add_executable(theme_bin ${theme_bin_SRCS})

set_target_properties(theme_bin  PROPERTIES OUTPUT_NAME thememain)

target_link_libraries(theme_bin ${KDE4_KDECORE_LIBS} korganizer)

install(TARGETS theme_bin  DESTINATION ${BIN_INSTALL_DIR} )


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

set(kcm_korganizer_PART_SRCS koprefsdialog.cpp )


kde4_add_plugin(kcm_korganizer ${kcm_korganizer_PART_SRCS})



target_link_libraries(kcm_korganizer ${KDE4_KDECORE_LIBS} korganizer kdepim kholidays)

kde4_add_kcfg_files(kcm_korganizer_SRCS koprefs_base.kcfgc )

install(TARGETS kcm_korganizer  DESTINATION ${PLUGIN_INSTALL_DIR})


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

set(korganizerpart_PART_SRCS korganizer_part.cpp )


kde4_add_plugin(korganizerpart WITH_PREFIX ${korganizerpart_PART_SRCS})



target_link_libraries(korganizerpart  ${KDE4_KDECORE_LIBS} korganizer )

install(TARGETS korganizerpart  DESTINATION ${PLUGIN_INSTALL_DIR})


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

set(korganizer_eventviewer_LIB_SRCS koeventviewer.cpp urihandler.cpp koeventviewerdialog.cpp )


qt4_add_dbus_interfaces(korganizer_eventviewer_LIB_SRCS org.kde.korganizer.Korganizer.xml)
qt4_add_dbus_interfaces(korganizer_eventviewer_LIB_SRCS ${CMAKE_SOURCE_DIR}/kmail/org.kde.kmail.kmail.xml)
qt4_add_dbus_interfaces(korganizer_eventviewer_LIB_SRCS ${CMAKE_SOURCE_DIR}/knode/org.kde.knode.xml)
qt4_add_dbus_interfaces(korganizer_eventviewer_LIB_SRCS ${CMAKE_SOURCE_DIR}/kaddressbook/org.kde.KAddressbook.Core.xml)

kde4_add_library(korganizer_eventviewer SHARED ${korganizer_eventviewer_LIB_SRCS})

target_link_libraries(korganizer_eventviewer ${KDE4_KPARTS_LIBS} ${KDE4_KCAL_LIBS})

set_target_properties(korganizer_eventviewer PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} )
install(TARGETS korganizer_eventviewer  DESTINATION ${LIB_INSTALL_DIR})


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

set(korganizer_calendar_LIB_SRCS stdcalendar.cpp )


kde4_add_library(korganizer_calendar SHARED ${korganizer_calendar_LIB_SRCS})

target_link_libraries(korganizer_calendar ${KDE4_KPARTS_LIBS} kdepim ${KDE4_KCAL_LIBS})

set_target_properties(korganizer_calendar PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} )
install(TARGETS korganizer_calendar  DESTINATION ${LIB_INSTALL_DIR})


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

set(korganizer_LIB_SRCS
   ${libkdgantt1_SRCS}
   themeimporter.cpp
   theme.cpp
   komessagebox.cpp
   koalternatelabel.cpp
   kodecorationlabel.cpp
   koagendaview.cpp
   agendaview.cpp
   multiagendaview.cpp
   koagenda.cpp
   koagendaitem.cpp
   timelineitem.cpp
   datenavigator.cpp
   kdatenavigator.cpp
   datenavigatorcontainer.cpp
   datechecker.cpp
   komonthview.cpp
   searchdialog.cpp
   calendarview.cpp
   koviewmanager.cpp
   kodialogmanager.cpp
   archivedialog.cpp
   kohelper.cpp
   komailclient.cpp
   kotodoview.cpp
   kotodoviewitem.cpp
   kotodoviewquicksearch.cpp
   kolistview.cpp
   koincidenceeditor.cpp
   koeventeditor.cpp
   kotodoeditor.cpp
   kojournaleditor.cpp
   koprefs.cpp
   kowindowlist.cpp
   koeditorgeneral.cpp
   koeditorgeneralevent.cpp
   koeditorgeneraltodo.cpp
   koeditorgeneraljournal.cpp
   koeditordetails.cpp
   koeditoralarms.cpp
   koeditorrecurrence.cpp
   koeditorattachments.cpp
   koeventpopupmenu.cpp
   koeditorfreebusy.cpp
   publishdialog.cpp
   koeventview.cpp
   filtereditdialog.cpp
   kowhatsnextview.cpp
   kojournalview.cpp
   journalview.cpp
   kotimespentview.cpp
   kocore.cpp
   mailscheduler.cpp
   kodaymatrix.cpp
   docprefs.cpp
   statusdialog.cpp
   koglobals.cpp
   actionmanager.cpp
   resourceview.cpp
   navigatorbar.cpp
   kogroupware.cpp
   history.cpp
   aboutdata.cpp
   importdialog.cpp
   korganizerifaceimpl.cpp
   freebusymanager.cpp
   freebusyurldialog.cpp
   eventarchiver.cpp
   koidentitymanager.cpp
   exportwebdialog.cpp
   kocorehelper.cpp
   incidencechanger.cpp
   kotimelineview.cpp
   templatemanagementdialog.cpp )


kde4_add_kcfg_files(korganizer_LIB_SRCS koprefs_base.kcfgc )

kde4_add_ui_files(korganizer_LIB_SRCS filteredit_base.ui koeditoralarms_base.ui publishdialog_base.ui template_management_dialog_base.ui kogroupwareprefspage.ui searchdialog_base.ui timescaleedit_base.ui)

qt4_add_dbus_adaptor(korganizer_LIB_SRCS org.kde.korganizer.Korganizer.xml korganizerifaceimpl.h KOrganizerIfaceImpl )
qt4_add_dbus_adaptor(korganizer_LIB_SRCS org.kde.Korganizer.Calendar.xml actionmanager.h ActionManager )
qt4_add_dbus_interfaces(korganizer_LIB_SRCS org.kde.korganizer.Korganizer.xml )

kde4_add_library(korganizer SHARED ${korganizer_LIB_SRCS})

target_link_libraries(korganizer ${KDE4_KNEWSTUFF2_LIBS} ${KDE4_KDEPRINT_LIBRARY} ${KDE4_KABC_LIBRARY} ${KDE4_KUTILS_LIBRARY} ${KDE4_KCAL_LIBRARY} ${KDE4_KPIMIDENTITIES_LIBRARY} ${KDE4_KMIME_LIBRARY}
                                                      kdepim korganizer_eventviewer korganizer_calendar kocorehelper
                                                      korg_stdprinting kholidays korganizer_interfaces )

set_target_properties(korganizer PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} )

install(TARGETS korganizer  DESTINATION ${LIB_INSTALL_DIR})


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

install( FILES korganizer.knsrc  DESTINATION  ${CONFIG_INSTALL_DIR})
install( FILES korganizer.desktop  DESTINATION ${XDG_APPS_INSTALL_DIR})
install( FILES korganizer-import.desktop  DESTINATION ${XDG_APPS_INSTALL_DIR})
install( FILES korganizer.kcfg  DESTINATION ${KCFG_INSTALL_DIR})
install( FILES korganizer_part.rc  DESTINATION ${DATA_INSTALL_DIR}/korganizer)
install( FILES dbuscalendar.desktop  DESTINATION ${SERVICETYPES_INSTALL_DIR})
install( FILES tips  DESTINATION ${DATA_INSTALL_DIR}/korganizer)
install( FILES korganizer_configmain.desktop                      korganizer_configtime.desktop                      korganizer_configviews.desktop                      korganizer_configcolorsandfonts.desktop                      korganizer_configplugins.desktop                      korganizer_configgroupscheduling.desktop                      korganizer_configfreebusy.desktop                      korganizer_configdesignerfields.desktop                      webcal.protocol  DESTINATION ${SERVICES_INSTALL_DIR})
install( FILES korganizerui.rc  DESTINATION ${DATA_INSTALL_DIR}/korganizer)
install( FILES korganizer.upd  DESTINATION ${KCONF_UPDATE_INSTALL_DIR})
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/ical2vcal DESTINATION ${BIN_INSTALL_DIR})

install( FILES org.kde.Korganizer.Calendar.xml org.kde.korganizer.Korganizer.xml DESTINATION ${DBUS_INTERFACES_INSTALL_DIR})
install( FILES korganizer_export.h  DESTINATION ${INCLUDE_INSTALL_DIR}/korganizer)

kde4_install_icons( ${ICON_INSTALL_DIR}   )
