从 cmake 传递 valgrind 标志

问题描述 投票:0回答:1

补充这个问题,我如何从cmake将flags传递到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 )
c++ cmake valgrind ctest
1个回答
0
投票

也许...错误的包括顺序和变量名称。

set(MEMORYCHECK_TYPE "valgrind")
set(MEMORYCHECK_COMMAND_OPTIONS "--leak-check=no")
include(CTest)
© www.soinside.com 2019 - 2024. All rights reserved.