How to "unescape" CXXFLAGS option using CMake 3.12.3

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

How to "unescape" CXXFLAGS option using CMake 3.12.3

Chris Rankin

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,

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.


Powered by

Please keep messages on-topic and check the CMake FAQ at:

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support:
CMake Consulting:
CMake Training Courses:

Visit other Kitware open-source projects at

Follow this link to subscribe/unsubscribe: