Complementary to this question, how can I pass flags to valgrind from cmake?
作为对这个问题的补充,我如何将标志从cmake传递给valgrind?
# enable valgrind checks
set(CTEST_MEMORYCHECK_TYPE "valgrind")
set(CTEST_MEMORYCHECK_COMMAND_OPTIONS "--leak-check=no")
According to the docs, The lines above should work, but after running cmake .
+ make
I get:
根据文档,上面的代码行应该可以工作,但在运行cmake之后。+使我得到:
$ ctest -T memcheck | grep "Memory Leak\|Defects"
1/1 MemCheck: #1: test ............................. Defects: 1
Memory Leak - 1
When I inspect the DartConfiguration.tcl
file I don't see my flag there:
当我检查DartConfiguration.tcl文件时,我没有在那里看到我的标志:
$ sed -n "79,80p" ./DartConfiguration.tcl
MemoryCheckCommand: /usr/local/bin/valgrind
MemoryCheckCommandOptions: # <--- nothing here ...
After manually editing DartConfiguration.tcl
everything works fine:
手动编辑DartConfiguration.tcl后,一切正常:
$ sed -i "s/MemoryCheckCommandOptions:/MemoryCheckCommandOptions: --leak-check=no/g" DartConfiguration.tcl
$ ctest -T memcheck | grep "Memory Leak\|Defects"
$ # nothing ( good )
更多回答
@dewaffled no, it doesn't work
@dewaffed no,它不起作用
优秀答案推荐
Maybe...wrong include order and variable name.
Try this!
也许……错误的包含顺序和变量名。尝尝这个!
set(MEMORYCHECK_TYPE "valgrind")
set(MEMORYCHECK_COMMAND_OPTIONS "--leak-check=no")
include(CTest)
更多回答
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
您的答案可以通过其他支持信息来改进。请编辑以添加更多详细信息,如引用或文档,以便其他人可以确认您的答案是正确的。你可以在帮助中心找到更多关于如何写出好答案的信息。
我是一名优秀的程序员,十分优秀!