include_directories(${CMAKE_CURRENT_SOURCE_DIR}
                    ${CMAKE_CURRENT_BINARY_DIR})

<%- Dir.glob(target_directory + '/*_tests.cpp').each do |test_file| %>
<%- basename = test_file[0..-5].gsub(target_directory + '/', '') %>
add_executable(<%= basename %> <%= basename + '.cpp' %>)
target_link_libraries(<%= basename %> ${TEST_LINK_LIBRARIES} QtTest)
add_test(<%= basename %> <%= basename %>)

<%- end %>

include_directories(${CMAKE_CURRENT_SOURCE_DIR}
                    ${CMAKE_CURRENT_BINARY_DIR})

<%- Dir.glob(target_directory + '/*_tests.cpp').each do |test_file| %>
<%- dirname = target_directory[(TESTS_DIR.length + 1)..-1] %>
<%- basename = test_file[(target_directory.length + 1)..-5] %>
add_executable(<%= basename %> <%= basename + '.cpp' %>)
target_link_libraries(<%= basename %>
                      ${TEST_LINK_LIBRARIES}
                      ${QT_QTTEST_LIBRARY})
add_test(<%= [dirname, basename].compact.join('/') %> <%= basename %>)

<%- end %>

Test names follow subdirectories; full QtTest library path used
Test names follow subdirectories; full QtTest library path used
