#
# SPDX-FileCopyrightText: 2026 by Christian McHugh <mchugh19@users.noreply.github.com>
#
# SPDX-License-Identifier: BSD-3-Clause
#

APPLY_COMMON_POLICIES()

set(IMMICH_PLUGIN_DIR ${CMAKE_SOURCE_DIR}/core/dplugins/generic/webservices/immich)

include_directories(${IMMICH_PLUGIN_DIR})

# The plugin builds as a loadable module, so there is no library
# for the tests to link against: the talker test compiles the
# plugin's network layer directly.

add_library(immichtalker STATIC ${IMMICH_PLUGIN_DIR}/immichtalker.cpp
                                ${IMMICH_PLUGIN_DIR}/immichsession.cpp)

target_link_libraries(immichtalker ${COMMON_TEST_LINK}
                                   digikamcore
                                   KF6::Wallet
                                   KF6::KIOWidgets)

# ----------------------------------------------------------------------------------

macro(immich_executable_tests)

    foreach(_testname ${ARGN})

        ecm_add_tests(${CMAKE_CURRENT_SOURCE_DIR}/${_testname}.cpp

                      NAME_PREFIX

                      "digikam-"

                      LINK_LIBRARIES

                      digikamcore
                      immichtalker

                      ${COMMON_TEST_LINK}
        )

    endforeach()

endmacro()

immich_executable_tests(
    immichlogic_utest
    immichtalker_utest
)
