Definite's Extractor

My findings on Life, Linux, Open Source, and so on.

Monthly Archives: April 2009

About CMake Verbatim (replied from brad.king)

After I submitted the bug report about CMake Verbatim, brad.king replied that he had committed a new documentation about Verbatim, which reads:

If VERBATIM is given then all arguments to the commands will be
escaped properly for the build tool so that the invoked command
receives each argument unchanged. Note that one level of escapes is
still used by the CMake language processor before add_custom_command
even sees the arguments. Use of VERBATIM is recommended as it enables
correct behavior. When VERBATIM is not given the behavior is platform
specific because there is no protection of tool-specific special
characters.

Thanks, brad.king! Keep up the good work.

CMake String regex match annoyance (aftermath)

Bill Hoffman kindly informed me that I can use “” to protect the semicolon.

For example, to get value of variable “_line” should be written as “${_line}”.

Thanks, Bill.

CMake String regex match annoyance

CMake has a regex string matching function STRING(REGEX MATCH … ), but it does not work as normal regex should. Firstly, as quite a bit people already aware of, it does not recognize the beginning-of-string ‘^’ and end-of-string ‘$’.

I also recently found that ‘;’ in the input string will be stripped, so be aware of that.

CMake Verbatim

From Merriam Webster Online:
ver·ba·tim (adv): in the exact words : word for word.

That’s my first impression of what CMake VERBATIM option should behave, and so do some folks in http://marc.info/?l=cmake&m=122818556004629&w=2. That is, the WHOLE argument list should be passed exactly as it is in CMakeLists.txt, unchanged.

But apparently CMake developers interpret that word in other way. For them, INDIVIUAL arguments should be passed safely though the tough neighberhood. The idea itself sounds good, unfortunately, CMake is not smart enough to do that.

Following example demostrates this problem:

ADD_CUSTOM_TARGET(hello
    COMMAND echo "How are you doing?" 'Fine, thank you.'
)

generates

CMakeFiles/hello:
	echo How\ are\ you\ doing? 'Fine, thank you.'

While with VERBATIM,

ADD_CUSTOM_TARGET(hello
    COMMAND echo "How are you doing?" 'Fine, thank you.'
    VERBATIM
)

generates

CMakeFiles/hello:
	echo "How are you doing?" "'Fine," thank "you.'"

Seems that VERBATIM only reckons and handles double-quoted strings.
If you need single-quoted strings or any others, sorry,
turn off VERBATIM and do it yourself.