project(LomiriOnlineAccountsQt LANGUAGES CXX)

set(LOA_QT_LIB lomiri-online-accounts-qt${QT_VERSION})

include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_SOURCE_DIR}/online-accounts-daemon/lib
)

set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined")
set(CMAKE_CXX_VISIBILITY_PRESET hidden)

add_definitions(
    -DBUILDING_ONLINE_ACCOUNTS
)

add_library(${LOA_QT_LIB} SHARED
    account.cpp
    account_info.cpp
    authentication_data.cpp
    authentication_reply.cpp
    dbus_interface.cpp
    error.cpp
    manager.cpp
    pending_call.cpp
    request_access_reply.cpp
    service.cpp
)
set_target_properties(${LOA_QT_LIB} PROPERTIES
    VERSION 1.0.0
    SOVERSION 1
    LINK_FLAGS -Wl,--no-undefined
)

target_link_libraries(${LOA_QT_LIB}
    Qt${QT_VERSION}::DBus
    lomiri-online-accounts-daemon
)

set_target_properties(${LOA_QT_LIB} PROPERTIES AUTOMOC TRUE)

# Library install

install(TARGETS ${LOA_QT_LIB} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})

# Development files

configure_file(${PROJECT_NAME}.pc.in ${PROJECT_NAME}${QT_VERSION}.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}${QT_VERSION}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

install(FILES
    Account account.h
    AuthenticationData authentication_data.h
    AuthenticationReply
    Error error.h
    global.h
    Manager manager.h
    OAuth1Data
    OAuth2Data
    PasswordData
    PendingCall pending_call.h
    PendingCallWatcher
    Service service.h
    DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}/${LOA_QT_LIB}/${PROJECT_NAME}
)
