
project(kabc)

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_directories( ${KDE4_KIO_INCLUDES} )

add_definitions(${QDBUS_DEFINITIONS} -DKDE_DEFAULT_DEBUG_AREA=5700)
add_definitions( -DQT_NO_CAST_FROM_ASCII )
add_definitions( -DQT_NO_CAST_TO_ASCII )
add_definitions( -DWANT_DEPRECATED_KABC_API )

# these apply also for all subdirs
include_directories(
 ${CMAKE_CURRENT_SOURCE_DIR}
 ${CMAKE_CURRENT_BINARY_DIR}
 ${CMAKE_CURRENT_SOURCE_DIR}/vcardparser
)

# kabc/vcardparser/Makefile.am: vcards

set(vcards_STAT_SRCS
  vcardparser/vcard.cpp
  vcardparser/vcardline.cpp
  vcardparser/vcardparser.cpp
)

# add_subdirectory( vcardparser )
# add_subdirectory( tests )
#add_subdirectory( scripts )
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/scripts)



add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/field.cpp ${CMAKE_CURRENT_BINARY_DIR}/addressee.h ${CMAKE_CURRENT_BINARY_DIR}/addressee.cpp
   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/scripts
   COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/makeaddressee
   DEPENDS
   scripts/makeaddressee
   scripts/addressee.src.cpp
   scripts/addressee.src.h
   scripts/entrylist
   scripts/field.src.cpp
   )


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

set(kabc_LIB_SRCS
   address.cpp
   ${CMAKE_CURRENT_BINARY_DIR}/addressee.cpp
   ${CMAKE_CURRENT_BINARY_DIR}/addressee.h
   ${CMAKE_CURRENT_BINARY_DIR}/field.cpp
   contactgroup.cpp
   contactgrouptool.cpp
   errorhandler.cpp
   geo.cpp
   key.cpp
#    ldapdn.cpp
#    ldif.cpp
   phonenumber.cpp
   picture.cpp
   plugin.cpp
   secrecy.cpp
   sound.cpp
   timezone.cpp
#    ldifconverter.cpp
   addresseelist.cpp
   vcardconverter.cpp
   vcardtool.cpp
   addresseehelper.cpp
#    lock.cpp
#    locknull.cpp
   sortmode.cpp
#    vcarddrag.cpp
   ${vcards_STAT_SRCS}
)

QT4_AUTOMOC("${kabc_LIB_SRCS}")

# if (NOT WINCE)
#   set(kabc_LIB_SRCS
#     ${kabc_LIB_SRCS}
#    #disabled due to no QTreeWidget
#    emailselectdialog.cpp
#   )
# endif()

add_library(calendaring-kabc ${LIBRARY_TYPE} ${kabc_LIB_SRCS})

target_link_libraries(calendaring-kabc ${KDE4_KDEUI_LIBS} ${KDE4_KDECORE_LIBS}
${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} calendaring-kdecore)
target_link_libraries(calendaring-kabc LINK_INTERFACE_LIBRARIES ${KDE4_KDEUI_LIBS})

set_target_properties(calendaring-kabc PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} )
install(TARGETS calendaring-kabc EXPORT kdepimlibsLibraryTargets ${INSTALL_TARGETS_DEFAULT_ARGS})

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

# install( FILES countrytransl.map  DESTINATION  ${DATA_INSTALL_DIR}/kabc )
install( FILES
   kabc_export.h
   address.h
   ${CMAKE_CURRENT_BINARY_DIR}/addressee.h
   addresseelist.h
   contactgroup.h
   contactgrouptool.h
#    emailselectdialog.h
   errorhandler.h
   field.h
   geo.h
   key.h
#    ldifconverter.h
#    lock.h
#    locknull.h
   phonenumber.h
   picture.h
   plugin.h
   secrecy.h
   sortmode.h
   sound.h
   timezone.h
   vcardconverter.h
#    vcarddrag.h
   DESTINATION ${INCLUDE_INSTALL_DIR}/kabc COMPONENT Devel
)
