[CMake] How to "unescape" CXXFLAGS option using CMake 3.12.3

Chris Rankin rankincj at gmail.com
Wed Oct 31 13:23:35 EDT 2018


Hi,

I am trying to add this compiler-specific G++ option to CXXFLAGS:

    -frandom-seed=$(shell sha256sum $< | awk '{print $$1}')

This option obviously needs to be parsed by GNU Make before G++ can use it,
and so I am doing the following:

    add_compile_options(SHELL:"-frandom-seed=$(shell sha256sum $< | awk
'{print $$1}')")

However, CMake is turning this option into nonsense like:

    CXXFLAGS = -g "-frandom-seed=\$$(shell sha256sum \$$< | awk '{print
\$$\$$1}')"

Is there any way that I can turn this accursed "escaping" OFF please? All I
need is for CMake to write the given command verbatim!

Thanks for any help here,
Cheers,
Chris

P.S. This is for a large build with lots and lots of subdirectories, and so
adding this option to CXXFLAGS would be by far the simplest solution -
despite what CMake seems to think.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20181031/b03fe27b/attachment.html>


More information about the CMake mailing list