[cmake-developers] What about #line like feature in cmake language?

Brad King brad.king at kitware.com
Fri May 23 09:11:25 EDT 2014


On 05/23/2014 03:39 AM, Nicolas Desprès wrote:
>> One remaining challenge is CMAKE_CURRENT_LIST_FILE and
>> CMAKE_CURRENT_LIST_LINE.  Since the "current file" is not
[snip]
> I think we should not touch those variables because they have
> dynamic behavior and if they are used in the generated code I
> expect the current behavior.

CMAKE_CURRENT_LIST_LINE comes from the lexer currently.  I think
CMAKE_CURRENT_LIST_FILE could too, and I'm not sure why it does
not currently.  That would take some investigation in the history
to learn.

> Why not adding __FILE__ and __LINE__ tokens that would be
> expanded by the lexer with the file name and line number
> last set by #cmake-source-line?

That is what the above variables were meant to be.  They just
happen to be implemented by replacing during variable evaluation
instead of by the lexer.  Having the lexer do actual replacements
would be a change to the language beyond the scope of the #line
proposal.

I think this issue as a reason to not add a #line feature.  For
your generated source case you can add comments that refer back
to the original source locations for human reference.

-Brad




More information about the cmake-developers mailing list