user42768
user42768

Reputation: 1971

CMake arguments in a command invocation can end in a line comment

In the latest CMake documentation (may 2019), the language section, Source Files paragraph there is the following sentence:

Note that any source file line not inside Command Arguments or a Bracket Comment can end in a Line Comment.

I think that source file lines inside Command Arguments can end in a Line Comment because the grammar specified in the Command Invocations paragraph states that a line_ending (which may contain a line_comment) can separate arguments.

Also, the following code snippet works as expected in cmake 3.11.4:

foreach(arg arg1
            arg2 #line-comment
       )
  message("${arg}")
endforeach()

Am I misunderstanding the above quote or is it inaccurate?

Upvotes: 1

Views: 92

Answers (1)

Tsyvarev
Tsyvarev

Reputation: 65870

Command argument is a specification of the single argument, which could be of one of three type:

argument ::= bracket_argument | quoted_argument | unquoted_argument

And you actually cannot specify a comment inside a command argument specification.

What you show in the question post, is a comment after the command argument.

Upvotes: 1

Related Questions