I want to write a CMakeLists.txt so that I can run my tests normally or with valgrind. I have seen much on integrating ctest with valgrind but all with the assumption that you w
It seems the following is sufficient. I wasn't using separate_arguments before, that was my stupidity.
function(add_memcheck_test name binary)
set(memcheck_command "${CMAKE_MEMORYCHECK_COMMAND} ${CMAKE_MEMORYCHECK_COMMAND_OPTIONS}")
separate_arguments(memcheck_command)
add_test(${name} ${binary} ${ARGN})
add_test(memcheck_${name} ${memcheck_command} ./${binary} ${ARGN})
endfunction(add_memcheck_test)
function(set_memcheck_test_properties name)
set_tests_properties(${name} ${ARGN})
set_tests_properties(memcheck_${name} ${ARGN})
endfunction(set_memcheck_test_properties)