[CMake] Generating warnings for undefined variables?

Philip Lowman philip at yhbt.com
Fri May 9 15:14:05 EDT 2008


So a few months back I was bored one night and dug through the CMake bug
tracker looking for something interesting.  I came across a request from a
user to have CMake generate warnings when undefined variables are
encountered.  I thought, gee, what a great idea.  I've often been bitten by
variable name typo bugs before and why doesn't CMake simply give me a
warning like most scripting languages out there when an undefined variable
is used?

So I dove through the source to try to learn a bit more about CMake works
(and see how hard the patch would be to implement).  It didn't look that
hard to do in the source so I messed around a little and implemented a small
patch to enable it.  The major catch I discovered was that there are a lot
of places where people expect variables to be often undefined and some of
these places (i.e. FIND_LIBRARY) it would be unfeasible for a user to
introduce IF(DEFINED... ) logic so I introduced a variable keyword that
could be used to suppress the warnings.  I don't like some of the things I
did in the patch looking back at it, but before I forget about it entirely
or consider working on it again I wanted to get some feedback from users
regarding this idea.

Are undefined variable warnings something that people might want in CMake
2.8.0 (as a default policy) or is the language too far deployed to expect to
be able to introduce this feature?

http://public.kitware.com/Bug/view.php?id=4249

-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080509/b90f097c/attachment.htm>


More information about the CMake mailing list