function(createTest NAME FILE)
    add_executable(${NAME} EXCLUDE_FROM_ALL ${FILE})
    add_test(NAME ${NAME} COMMAND $<TARGET_FILE:${NAME}>)
    add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --verbose -C $<CONFIGURATION>
        DEPENDS ${NAME})
endfunction(createTest)

file(GLOB_RECURSE TEST_SRCS
     RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/src
     *Test.cpp)

foreach(FILE "${TEST_SRCS}")
    get_filename_component(FILENAME ${FILE} NAME_WE)
    createTest(${FILENAME} "${CMAKE_CURRENT_SOURCE_DIR}/src/${FILE}")
endforeach()

include_directories(${CMAKE_CURRENT_SOURCE_DIR})

function(createTest NAME FILE)
    add_executable(${NAME} EXCLUDE_FROM_ALL ${FILE})
    add_dependencies(${NAME} ${ENGINE_LIB_NAME})
    add_test(NAME ${NAME} COMMAND $<TARGET_FILE:${NAME}>)
    add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --verbose -C $<CONFIGURATION>
        DEPENDS ${NAME})
endfunction(createTest)

file(GLOB_RECURSE TEST_SRCS
     RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/src
     *Test.cpp)

foreach(FILE "${TEST_SRCS}")
    get_filename_component(FILENAME ${FILE} NAME_WE)
    createTest(${FILENAME} "${CMAKE_CURRENT_SOURCE_DIR}/src/${FILE}")
endforeach()

include_directories(${CMAKE_CURRENT_SOURCE_DIR})

Make sure the library gets built so it can link with the tests
Make sure the library gets built so it can link with the tests
