Issue
I want to use CMake to run some tests. One of the test should call a validator script on all files matching fixtures/*.ext
. How can transform the following pseudo-CMake into real CMake?
i=0
for file in fixtures/*.ext; do
ADD_TEST(validate_${i}, "validator", $file)
let "i=i+1"
done
Solution
Like this:
file(GLOB files "fixtures/*.ext")
foreach(file ${files})
... calculate ${i} to get the test name
add_test(validate_${i}, "validator", ${file})
endforeach()
But this does not calculate i
for you. Is it important that you have an integer suffix to the test? Otherwise you could use file(...)
to extract the filename (without extension) to use.
Answered By - JesperE Answer Checked By - David Marino (WPSolving Volunteer)