I have a CMake project that I want to be able to compile using g++, MinGW/g++ (4.x each), Clang (3.x) and MSVC++ (>= V8).
I want to have a precompiler symbol with the compiler arguments or command line.
This is useful to see whether optimization was enabled and which switches were enabled at the command line.
E.g. a program compiled with g++ -O3 -DNDEBUG -g0 should know that the flags are "-O3 -DNDEBUG -g0".
When writing manual Makefiles, I could simply collect the flags in a variable and then additionally pass this to the compiler yielding a command line g++ -O3 -DNDEBUG -g0 -DCOMPILER_ARGS="-O3 -DNDEBUG -g0".
How can I achieve this using CMake?