# This is a copy of the normal LightDM plugin, but instead of statically
# linking in the lightdm bits, this one uses shared libraries so we can swap
# out different sets of users for different tests.  When we finally switch to
# actually using the system liblightdm in the normal plugin, this version can
# be deleted.

add_subdirectory(demo)
add_subdirectory(full)
add_subdirectory(single)
add_subdirectory(single-pin)
add_subdirectory(single-passphrase)

include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_BINARY_DIR}
    ${CMAKE_SOURCE_DIR}/plugins/Utils
    ${CMAKE_SOURCE_DIR}/tests/mocks/libusermetrics
)

set(QMLPLUGIN_SRC
    ${CMAKE_SOURCE_DIR}/plugins/LightDM/DBusGreeterList.cpp
    ${CMAKE_SOURCE_DIR}/plugins/LightDM/Greeter.cpp
    ${CMAKE_SOURCE_DIR}/plugins/LightDM/plugin.cpp
    ${CMAKE_SOURCE_DIR}/plugins/LightDM/UsersModel.cpp
    ${CMAKE_SOURCE_DIR}/plugins/Utils/qsortfilterproxymodelqml.cpp
    )

add_library(MockLightDM-qml MODULE
    ${QMLPLUGIN_SRC}
    )

# We want to link to liblightdm-qt5-2, but we don't want to depend on it being
# installed on the system.  So we make sure we link to our full fake version
# At run time, we can point to whichever version we happen to be using via
# LD_LIBRARY_PATH.
add_dependencies(MockLightDM-qml MockLightDM-full MockUserMetrics)
target_link_libraries(MockLightDM-qml
    -L${CMAKE_CURRENT_BINARY_DIR}/full
    -llightdm-qt5-2
    -L${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics
    -lusermetricsoutput
    )

qt5_use_modules(MockLightDM-qml DBus Gui Qml)

# copy qmldir file into build directory for shadow builds
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/qmldir"
    DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
    )

install(TARGETS MockLightDM-qml
    DESTINATION ${SHELL_INSTALL_QML}/mocks/LightDM
    )

install(FILES qmldir
    DESTINATION ${SHELL_INSTALL_QML}/mocks/LightDM
    )
