if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
    cmake_minimum_required(VERSION 3.30)
    project(tst_locator)
endif()

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Find Qt6 Core and Test modules
find_package(Qt6 REQUIRED COMPONENTS Core Test)
# Enable AUTOMOC before add_executable
set(CMAKE_AUTOMOC ON)

# Collect test sources
file(GLOB TEST_SOURCES "*.cpp")
file(GLOB TEST_HEADERS "*.h")

# Create the test executable
add_executable(tst_locator
    ${TEST_SOURCES}
    ../../src/locator.cpp

    ${TEST_HEADERS}
    ../../src/locator.h
    ../../src/klogdefinitions.h
)

# Enable MOC for Qt signals/slots if needed
set(CMAKE_AUTOMOC ON)

# Link with Qt6 Core and Test
target_link_libraries(tst_locator
    Qt6::Core
    Qt6::Test
)

# Register the test with CTest
add_test(NAME tst_locator COMMAND tst_locator)
set_tests_properties(tst_locator PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=offscreen")

