[CMake] add_test/memcheck

Rolf Eike Beer eike at sf-mail.de
Thu Aug 8 10:10:20 EDT 2013


Am 08.08.2013 14:09, schrieb cabieces julien:
> Hi
> 
> I'm currently using the simple way of testing in Cmake, just adding 
> the two
> following instructions at the end of my CMakeLists.txt;
> 
> enable_testing()
> add_test(TestMyProgram MyProgram)
> 
> I follow this instruction : 
> http://cmake.org/Wiki/CMake/Testing_With_CTest
> 
> and I would like to make memory checking (and eventually coverage)
> 
> In order to do it, I just add "include(CTest)" after enable_testing, 
> and
> type in a terminal
> 
> ctest -D ExperimentalMemCheck
> 
> but now, I would like to customize memchecking (I use valgrind) by 
> setting
> a suppression file and tell valgrind to produce a xml-file (that could 
> used
> in an other tool or maybe Jenkins).
> 
> So according to the documentation I add
> file(TO_CMAKE_PATH "${CMAKE_SOURCE_DIR}/resources/valgrind_supp.xml"
> MEMORYCHECK_SUPPRESSIONS_FILE)
> set(MEMORYCHECK_COMMAND_OPTIONS "--xml=yes 
> --xml-file=test_memcheck.xml")

You must put these into CTestCustom.cmake in your build dir.

Eike


More information about the CMake mailing list