Discussion:
[CMake] How to "unescape" CXXFLAGS option using CMake 3.12.3
Chris Rankin
2018-10-31 17:23:35 UTC
Permalink
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.

Loading...