#
# $Id$
# $HeadURL$
# $Author$
#

ADD_SUBDIRECTORY(SituationMap)

IF(BUILD_SITMAP_UNIT_TESTS)
# Configure Google Test - required before any test targets
find_package(GTest QUIET)
if(NOT TARGET GTest::gtest_main)
    include(FetchContent)
    FetchContent_Declare(
      googletest
      GIT_REPOSITORY https://github.com/google/googletest.git
      GIT_TAG v1.14.0
    )
    FetchContent_MakeAvailable(googletest)
endif()
#  ADD_SUBDIRECTORY(SitMapTestApp)
ADD_SUBDIRECTORY(exampleSvgRenderer)
ADD_SUBDIRECTORY(LineOfSightEvaluation)

# Qt6 Migration Unit Tests
# Test naming convention per ci/check_pr_policies.py: test_{name}.cpp

# Get absolute path to tests directory
GET_FILENAME_COMPONENT(TESTS_DIR "${CMAKE_SOURCE_DIR}/tests" ABSOLUTE)

# Qt6 API Migrations Test
SET(TEST_QT6_API_SRCS
  ${TESTS_DIR}/test_qt6_api_migrations.cpp
)
NGL_ADD_EXECUTABLE(WS NO_TRANSLATION test_qt6_api_migrations ${TEST_QT6_API_SRCS})
NGL_TARGET_LINK_LIBRARIES(test_qt6_api_migrations
  Qt6::Test
  Qt6::Core
  Qt6::Gui
  Qt6::Concurrent
  GTest::gtest
  GTest::gtest_main
  situationMap
)
ADD_TEST(NAME Qt6ApiMigrationsTest COMMAND test_qt6_api_migrations)

# GraphicalObjects Module Test
SET(TEST_GRAPHICAL_OBJECTS_SRCS
  ${TESTS_DIR}/test_graphical_objects.cpp
)
NGL_ADD_EXECUTABLE(WS NO_TRANSLATION test_graphical_objects ${TEST_GRAPHICAL_OBJECTS_SRCS})
NGL_TARGET_LINK_LIBRARIES(test_graphical_objects
  Qt6::Test
  Qt6::Core
  Qt6::Gui
  GTest::gtest
  GTest::gtest_main
  situationMapObjects
)
ADD_TEST(NAME GraphicalObjectsTest COMMAND test_graphical_objects)

# Rubberbands Module Test
SET(TEST_RUBBERBANDS_SRCS
  ${TESTS_DIR}/test_rubberbands.cpp
)
NGL_ADD_EXECUTABLE(WS NO_TRANSLATION test_rubberbands ${TEST_RUBBERBANDS_SRCS})
NGL_TARGET_LINK_LIBRARIES(test_rubberbands
  Qt6::Test
  Qt6::Core
  Qt6::Gui
  Qt6::Concurrent
  GTest::gtest
  GTest::gtest_main
  situationMap
)
ADD_TEST(NAME RubberbandsTest COMMAND test_rubberbands)

# MathUtils Module Test
SET(TEST_MATHUTILS_SRCS
  ${TESTS_DIR}/test_mathutils.cpp
)
NGL_ADD_EXECUTABLE(WS NO_TRANSLATION test_mathutils ${TEST_MATHUTILS_SRCS})
NGL_TARGET_LINK_LIBRARIES(test_mathutils
  Qt6::Test
  Qt6::Core
  Qt6::Gui
  GTest::gtest
  GTest::gtest_main
  situationMap
)
ADD_TEST(NAME MathUtilsTest COMMAND test_mathutils)

# MapImpl Module Test
SET(TEST_MAPIMPL_SRCS
  ${TESTS_DIR}/test_mapimpl.cpp
)
NGL_ADD_EXECUTABLE(WS NO_TRANSLATION test_mapimpl ${TEST_MAPIMPL_SRCS})
NGL_TARGET_LINK_LIBRARIES(test_mapimpl
  Qt6::Test
  Qt6::Core
  Qt6::Gui
  GTest::gtest
  GTest::gtest_main
  situationMap
)
ADD_TEST(NAME MapImplTest COMMAND test_mapimpl)

# SymbologyImpl Module Test
SET(TEST_SYMBOLOGYIMPL_SRCS
  ${TESTS_DIR}/test_symbologyimpl.cpp
)
NGL_ADD_EXECUTABLE(WS NO_TRANSLATION test_symbologyimpl ${TEST_SYMBOLOGYIMPL_SRCS})
NGL_TARGET_LINK_LIBRARIES(test_symbologyimpl
  Qt6::Test
  Qt6::Core
  Qt6::Gui
  Qt6::Concurrent
  GTest::gtest
  GTest::gtest_main
  advancedSymbology
)
ADD_TEST(NAME SymbologyImplTest COMMAND test_symbologyimpl)

# Viewshed3D Module Test
SET(TEST_VIEWSHED3D_SRCS
  ${TESTS_DIR}/test_viewshed3d.cpp
)
NGL_ADD_EXECUTABLE(WS NO_TRANSLATION test_viewshed3d ${TEST_VIEWSHED3D_SRCS})
NGL_TARGET_LINK_LIBRARIES(test_viewshed3d
  Qt6::Test
  Qt6::Core
  Qt6::Gui
  GTest::gtest
  GTest::gtest_main
  situationMap
)
ADD_TEST(NAME Viewshed3DTest COMMAND test_viewshed3d)

ENDIF()

