作为这个问题的补充,我如何从cmake向valgrind传递标志?
# enable valgrind checks
set(CTEST_MEMORYCHECK_TYPE "valgrind")
set(CTEST_MEMORYCHECK_COMMAND_OPTIONS "--leak-check=no")
根据文档,上面的行应该有效,但在运行cmake .
+make
后,我得到:
$ ctest -T memcheck | grep "Memory Leak|Defects"
1/1 MemCheck: #1: test ............................. Defects: 1
Memory Leak - 1
当我检查DartConfiguration.tcl
文件时,我没有在那里看到我的标志:
$ sed -n "79,80p" ./DartConfiguration.tcl
MemoryCheckCommand: /usr/local/bin/valgrind
MemoryCheckCommandOptions: # <--- nothing here ...
手动编辑DartConfiguration.tcl
后,一切正常:
$ sed -i "s/MemoryCheckCommandOptions:/MemoryCheckCommandOptions: --leak-check=no/g" DartConfiguration.tcl
$ ctest -T memcheck | grep "Memory Leak|Defects"
$ # nothing ( good )
- 公开回购中存在所有详细信息:https://github.com/OrenGitHub/ValgrindCmake
- 特别是cmake测试管道:这里和这里
也许。。。包含顺序和变量名错误
试试这个!
set(MEMORYCHECK_TYPE "valgrind")
set(MEMORYCHECK_COMMAND_OPTIONS "--leak-check=no")
include(CTest)