You need enable_testing
to activate CMake's test machinery. The add_test
function needs the name of the test and the command to run and the syntax is as below.
To add a counter, you can use the math()
function. The following will let you also run out of source builds by specifying the complete path to the inputs.
cmake_minimum_required(VERSION 2.6)
enable_testing()
file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/fixtures/*.ext")
set(validator ${CMAKE_CURRENT_SOURCE_DIR}/validator)
set(i 0)
foreach(filename ${files})
add_test(NAME "validate_${i}"
COMMAND "${validator}" ${filename})
math(EXPR i "${i} + 1")
endforeach()