How to limit C_FLAGS to certain libraries

We are trying to reduce warnings in our code base by promoting some warnings to errors.
We build the list of warnings during configure time and add them to CMAKE_C_FLAGS.
This was fine until we started implementing the list of -Werror=xxx.
First was CMake FortranCInterface failed to compile with:
After fixing that, then the errors in examples and tests started failing - libraries and programs outside the intended code base for the stricter warnings.

I am looking for advice and how to selectively choose which library/sub-folder/target get which list of flags. Is there an easy way to set the CMAKE_C_FLAGS only on a specific library/sub-folder/target?


Use target properties (Mainly target COMPILE_OPTIONS).

Properties can also be set at directory level (see directory COMPILE_OPTIONS).