project(synq-src)
add_definitions(-std=c++11)

set(SYNQ_BIN lomiri-sync-monitor)
set(SYNQ_LIB synq-lib)

set(SYNQ_LIB_SRC
    eds-helper.h
    eds-helper.cpp
    notify-message.h
    notify-message.cpp
    repowerd-proxy.h
    repowerd-proxy.cpp
    provider-template.h
    provider-template.cpp
    sync-account.h
    sync-account.cpp
    sync-auth.h
    sync-auth.cpp
    sync-configure.h
    sync-configure.cpp
    sync-daemon.h
    sync-daemon.cpp
    sync-dbus.h
    sync-dbus.cpp
    sync-i18n.h
    sync-queue.h
    sync-queue.cpp
    sync-network.h
    sync-network.cpp
    syncevolution-server-proxy.h
    syncevolution-server-proxy.cpp
    syncevolution-session-proxy.h
    syncevolution-session-proxy.cpp
)

add_library(${SYNQ_LIB} STATIC
    ${SYNQ_LIB_SRC}
)

target_link_libraries(${SYNQ_LIB}
    ${ACCOUNTS_LIBRARIES}
    ${LIBNOTIFY_LIBRARIES}
    ${LIBSIGNON_LIBRARIES}
    ${URLDISPATCHER_LIBRARIES}
    ${LOMIRI_CONNECTIVITY_LIBRARIES}
    syncevolution-qt
)

qt5_use_modules(${SYNQ_LIB} Core DBus Organizer Contacts Network)

set(SYNQ_BIN_SRC
    main.cpp
)

add_executable(${SYNQ_BIN}
    ${SYNQ_BIN_SRC}
)

target_link_libraries(${SYNQ_BIN}
    ${SYNQ_LIB}
)

qt5_use_modules(${SYNQ_BIN} Core )

include_directories(
    ${CMAKE_SOURCE_DIR}
    ${CMAKE_BINARY_DIR}
    ${ACCOUNTS_INCLUDE_DIRS}
    ${LIBSIGNON_INCLUDE_DIRS}
    ${LIBNOTIFY_INCLUDE_DIRS}
    ${URLDISPATCHER_INCLUDE_DIRS}
    ${LOMIRI_CONNECTIVITY_INCLUDE_DIRS}
    ${syncevolution-qt_SOURCE_DIR}
)

install(TARGETS ${SYNQ_BIN}
        RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/lomiri-sync-monitor/)

set(DBUS_SERVICE_FILE com.lomiri.SyncMonitor.service)
configure_file(dbus/${DBUS_SERVICE_FILE}.in
               ${CMAKE_CURRENT_BINARY_DIR}/dbus/${DBUS_SERVICE_FILE}
               @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dbus/${DBUS_SERVICE_FILE}
        DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/dbus-1/services/)
