set(CMAKE_AUTOMOC ON)

foreach(QT_TEST_NAME animation audio events filter frame image playlist producer properties repository service tractor xml)
  add_executable(test_${QT_TEST_NAME} test_${QT_TEST_NAME}/test_${QT_TEST_NAME}.cpp)
  target_compile_options(test_${QT_TEST_NAME} PRIVATE ${MLT_COMPILE_OPTIONS})
  target_link_libraries(test_${QT_TEST_NAME} PRIVATE Qt${QT_MAJOR_VERSION}::Core Qt${QT_MAJOR_VERSION}::Test mlt++)
  add_test(NAME "QtTest:${QT_TEST_NAME}" COMMAND test_${QT_TEST_NAME})
  if(NOT WIN32)
    set_tests_properties("QtTest:${QT_TEST_NAME}" PROPERTIES ENVIRONMENT "LANG=en_US")
  endif()
endforeach()

file(GLOB YML_FILES "${CMAKE_SOURCE_DIR}/src/modules/*/*.yml")
foreach(YML_FILE ${YML_FILES})
  get_filename_component(FILE_NAME ${YML_FILE} NAME)
  file(RELATIVE_PATH KWALIFY_TEST_NAME "${CMAKE_SOURCE_DIR}/src/modules" ${YML_FILE})
  if(NOT FILE_NAME MATCHES "resolution_scale.yml")
    add_test(NAME "kwalify:${KWALIFY_TEST_NAME}" COMMAND ${Kwalify_EXECUTABLE} -f "${CMAKE_SOURCE_DIR}/src/framework/metaschema.yaml" ${YML_FILE})
  endif()
endforeach()
