MemCheckType of UndefinedBehaviorSanitizer fails without an (empty) CTestCustom.cmake file
When trying to use CMake/CTest to run tests under UndefinedBehaviourSanitizer, it fails with the following message if no CTestCustom.cmake
file exists:
$ ctest -D ExperimentalMemCheck
Site: mancouch
Build name: Linux-clang++-3.8
Memory check project /home/daver/repos/couchbase/server/build-ubsan/ep-engine
Memory checker (MemoryCheckCommand) not set, or cannot find the specified program.
Errors while running CTest
By creating a CTestCustom.cmake
- even an empty one - the problem goes away.
Discussion on #cmake on IRC identified the issue:
[09:19:16] <Dave_R> Hi All. I'm trying to setup CMake/CTest to drive the UndefinedBehavior memory checker (added here: https://gitlab.kitware.com/cmake/cmake/commit/816c100ae2d1ef9ad42186a260724a279b6b5934). However when I SET(MEMORYCHECK_TYPE UndefinedBehaviorSanitizer), I get "error: Memory checker (MemoryCheckCommand) not set, or cannot find the specified program." Any suggestions?
[09:19:26] <Dave_R> (This is with cmake 3.5.1)
[09:41:34] <Dave_R> ok, getting a bit further - issue is that there's no "CMakeCommand" option in my CMake-generated DartConfiguration.tcl. If I manaully add one it works
[09:41:53] <Dave_R> Anyone know how I can get CMake to add this option to the CTest config file it generates?
[09:52:03] <ngladitz> Dave_R: I think ctest itself is supposed to set it
[09:52:43] <Dave_R> ngladitz I've got a as far a gdb'ing ctest at that point, and indeed the CTest object has it as a blank string :(
[09:54:21] <ngladitz> hm it looks like the code that sets "CMakeCommand" is conditional
[09:54:55] <ngladitz> https://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/CTest/cmCTestMemCheckHandler.cxx#l278
[09:55:33] <ngladitz> I think it only gets run when you have a CTestCustom.cmake
[09:55:56] <Dave_R> ngladitz ah yes. Let me see if I'm hitting that...
[09:56:14] <ngladitz> an empty CTestCustom.cmake would probably suffice
[09:56:17] <Dave_R> ok, so that method is not getting executed on my run
[09:56:20] <Dave_R> ok, let me try that
[09:56:27] <Dave_R> in the build directory?
[09:56:49] <ngladitz> yes
[09:57:05] <Dave_R> aha - victory!
[09:57:20] <Dave_R> thanks for your help