#
# Unit tests for the nglapplication module (nglcoreapplication).
# One test executable per module, each registered with ctest.
#
if (NOT BUILD_TESTING)
  return()
endif()

# --- nglapplication: nglcoreapplication logger handler
# --- (Log4Qt-independent; works in the Log4Qt-less (stub) build)
if (TARGET nglcoreapplication)
  ADD_EXECUTABLE(nglcoreapplication_unit_test nglcoreapplication_unit_test.cpp)
  # NGLLogger.h (the AlreadyCreatedError type thrown by createNGLRootLogger)
  # refuses to be included outside the NGLLogger library unless
  # BUILDING_NGLLOGGER is defined (same pattern as NGLLogger/CMakeLists.txt)
  TARGET_COMPILE_DEFINITIONS(nglcoreapplication_unit_test PRIVATE BUILDING_NGLLOGGER)
  TARGET_LINK_LIBRARIES(nglcoreapplication_unit_test
    nglcoreapplication
    NGLLogger
    Qt6::Core
    Qt6::Test
  )
  ADD_TEST(NAME nglcoreapplication_unit_test COMMAND $<TARGET_FILE:nglcoreapplication_unit_test>)
endif()
