[CMake] Generating warnings for undefined variables?

Alexander Neundorf a.neundorf-work at gmx.net
Sat Jun 14 09:44:12 EDT 2008


On Saturday 14 June 2008, Matthew Woehlke wrote:
> Philip Lowman wrote:
> > 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.
>
> No comments?

I think not having to declare variables is as it is in most scripting 
languages (which doesn't automatically mean it's the best way, but at least 
cmake is not different here).

Alex


More information about the CMake mailing list