add_subdirectory(test_utils)

add_subdirectory(core)
add_subdirectory(database)
add_subdirectory(fonts)
add_subdirectory(geometry)
add_subdirectory(graphics)
add_subdirectory(network)
add_subdirectory(publishing)
add_subdirectory(ui_controls)

file(COPY data/ DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_data)

set(TEST_MODULES 
    audio 
    compiler 
    compression 
    image 
    ipc   
	mesh 
    video
    web
    windows)

foreach(module ${TEST_MODULES})
    add_subdirectory(${module})
    string(TOUPPER ${module} MODULE_UPPER)
    list(APPEND UNIT_TEST_FILES ${${MODULE_UPPER}_UNIT_TEST_FILES})
    list(APPEND UNIT_TEST_DEPENDENCIES ${${MODULE_UPPER}_UNIT_TEST_DEPENDENCIES})
    
    list(APPEND INTEGRATION_TEST_FILES ${${MODULE_UPPER}_INTEGRATION_TEST_FILES})
    list(APPEND INTEGRATION_TEST_DEPENDENCIES ${${MODULE_UPPER}_INTEGRATION_TEST_DEPENDENCIES})

    list(APPEND UI_TEST_FILES ${${MODULE_UPPER}_UI_TEST_FILES})
    list(APPEND UI_TEST_DEPENDENCIES ${${MODULE_UPPER}_UI_TEST_DEPENDENCIES})
endforeach()

add_executable(unit_tests test_runner.cpp ${UNIT_TEST_FILES})
target_link_libraries(unit_tests PUBLIC test_utils ${UNIT_TEST_DEPENDENCIES})
set_property(TARGET unit_tests PROPERTY FOLDER test)

add_executable(integration_tests test_runner.cpp ${INTEGRATION_TEST_FILES})
target_link_libraries(integration_tests PUBLIC test_utils ${INTEGRATION_TEST_DEPENDENCIES})
set_property(TARGET integration_tests PROPERTY FOLDER test)

add_executable(ui_tests WIN32 ui_test_runner.cpp ${UI_TEST_FILES})
target_link_libraries(ui_tests PUBLIC test_utils ${UI_TEST_DEPENDENCIES})
set_property(TARGET ui_tests PROPERTY FOLDER test)

