project(kcalcore)


set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
cmake_minimum_required(VERSION 2.6)

# only available from cmake-2.8.0
if(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 7)
    cmake_policy(SET CMP0012 NEW)
endif()

# only available from cmake-2.8.4
if(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 7 AND
    ${CMAKE_PATCH_VERSION} GREATER 3)
    cmake_policy(SET CMP0017 NEW)
endif()



find_package(Qt4 4.6.0 REQUIRED)

include_directories(${QT_INCLUDES})

#include(GenerateExportHeader)

############### Build Options ###############

# The following macros can be defined to alter how KCalCore is built.
# For example, cmake -DKCALCORE_FOR_MEEGO=true

# KCALCORE_FOR_MEEGO - builds KCalCore with some special features for the MeeGo platform.
# option(KCALCORE_FOR_MEEGO "Build KCalCore especially for the MeeGo." FALSE)

# KCALCORE_FOR_SYMBIAN - builds KCalCore with some special features for the Symbian platform.
# option(KCALCORE_FOR_SYMBIAN "Build KCalCore especially for the Symbian." FALSE)

# add C++ macro definitions for options passed to CMake
# if(KCALCORE_FOR_MEEGO)
#   add_definitions(-DKCALCORE_FOR_MEEGO)
# endif()
# if(KCALCORE_FOR_SYMBIAN)
#   add_definitions(-DKCALCORE_FOR_SYMBIAN)
# endif()

############### Find packages ###############
# FIXME KDE5PORT needed: kdatetime which belongs to kdecore
# find_package(kcoreaddons REQUIRED)
# include_directories(${kcoreaddons_INCLUDE_DIR} ${kcoreaddons_INCLUDE_DIR}/KDE)


find_package(Libical "0.42" REQUIRED)


include_directories( ../kdecore )




###########################################################

add_definitions(-DKDE_DEFAULT_DEBUG_AREA=5810)

include(ConfigureChecks.cmake)
configure_file(config-kcalcore.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kcalcore.h)

if(KDE4_BUILD_TESTS)
  add_definitions(-DCOMPILING_TESTS)
endif()

include_directories(
  ${LIBICAL_INCLUDE_DIRS}
  ${LIBICAL_INCLUDE_DIRS}/libical
  ${CMAKE_CURRENT_SOURCE_DIR}/versit
  ${KDE4_INCLUDE_DIR}
  ${CMAKE_CURRENT_BINARY_DIR}
)

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

set(libversit_SRCS
  ${CMAKE_CURRENT_SOURCE_DIR}/versit/vcc.c
  ${CMAKE_CURRENT_SOURCE_DIR}/versit/vobject.c
)

set(kcalcore_LIB_SRCS ${libversit_SRCS}
  alarm.cpp
  attachment.cpp
  attendee.cpp
  calendar.cpp
  calfilter.cpp
  calformat.cpp
  calstorage.cpp
  compat.cpp
  customproperties.cpp
  duration.cpp
  event.cpp
  exceptions.cpp
  filestorage.cpp
  freebusy.cpp
  freebusycache.cpp
  freebusyurlstore.cpp
  freebusyperiod.cpp
  icalformat.cpp
  icalformat_p.cpp
  icaltimezones.cpp
  incidence.cpp
  incidencebase.cpp
  journal.cpp
  memorycalendar.cpp
  period.cpp
  person.cpp
  recurrence.cpp
  recurrencerule.cpp
  schedulemessage.cpp
  sorting.cpp
  todo.cpp
  vcalformat.cpp
  visitor.cpp
)

QT4_AUTOMOC("${kcalcore_LIB_SRCS}")

add_library(calendaring-kcalcore ${LIBRARY_TYPE} ${kcalcore_LIB_SRCS})
# generate_export_header(kcalcore)

#${KDE4_KDECORE_LIBRARY}
target_link_libraries(calendaring-kcalcore calendaring-kdecore ${QT_QTGUI_LIBRARY} ${LIBICAL_LIBRARIES})

if(HAVE_UUID_LIBRARY)
  target_link_libraries(calendaring-kcalcore uuid)
endif()

# set(libcalendaring-kcalcore ${libcalendaring-kcalcore} PARENT_SCOPE)
# message("${libcalendaring-kcalcore}")
set_target_properties(calendaring-kcalcore PROPERTIES
    VERSION ${ECM_VERSION_STRING}
    SOVERSION ${ECM_SOVERSION}
)

install(TARGETS calendaring-kcalcore EXPORT kdepimlibsLibraryTargets ${INSTALL_TARGETS_DEFAULT_ARGS})

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

#add_subdirectory(tests)

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

install(FILES
  kcalcore_export.h
  alarm.h
  attachment.h
  attendee.h
  calendar.h
  calfilter.h
  calformat.h
  calstorage.h
  compat.h
  customproperties.h
  duration.h
  event.h
  exceptions.h
  filestorage.h
  freebusy.h
  freebusycache.h
  freebusyperiod.h
  freebusyurlstore.h
  icalformat.h
  icaltimezones.h
  incidence.h
  incidencebase.h
  journal.h
  memorycalendar.h
  period.h
  person.h
  recurrence.h
  recurrencerule.h
  schedulemessage.h
  sortablelist.h
  sorting.h
  supertrait.h
  todo.h
  vcalformat.h
  visitor.h
  DESTINATION ${INCLUDE_INSTALL_DIR}/kcalcore COMPONENT Devel)
