[CMake] Bug in generation of CTestTestfile commands with test or directory names containing spaces

eddyaod at gmail.com eddyaod at gmail.com
Sun Dec 18 19:34:29 EST 2011


Greetings,

I have noticed that it is possible to run in to problems with CMake
when sub directories or test names contain spaces. CMake initially
parses quote delimited strings correctly, however it writes them
without quotes into the generated CTestTestfile.cmake files which then
causes problems when CTest is run.

Please find attached a small example and also a potential fix, in git
patch format.

To see the example in action, configure and generate a build using
CMake with the "src" folder as source root, then try to run CTest
within the build root. No tests can be found. There are actually 2
issues with the results of CMake. Firstly, in CTestTestfile.cmake in
the build root the command SUBDIRS(Sub Dir) is incorrect. If you
change it to SUBDIRS("Sub Dir") there is still a problem with the
ADD_TEST commands in the "Sub Dir" directory's CTestTestfile.cmake of
the build. Again, the test name needs to be delimited with quotes.
Once this is fixed to: ADD_TEST("Run Test" ... then CTest can
correctly parse and run the specified test.

The patch I have prepared simply wraps all test names and subdirectory
names with quotes as they are written to the CTestTestFile. There may
be more places where similar fixes would be appropriate if anyone
knows of any.

I hope someone might be able to review this issue.

Finally, a big thank you to all involved with CMake for producing such
a great development tool.

Regards,

Edmund Fokschaner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug example.7z
Type: application/octet-stream
Size: 366 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111219/bff2f002/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Fix.patch
Type: application/octet-stream
Size: 1662 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111219/bff2f002/attachment-0001.obj>


More information about the CMake mailing list