I am using an interface library to specify a set of warnings that should be enabled project wide:
add_library(default_warnings INTERFACE) target_compile_options(default_warnings INTERFACE -Wall -Wextra)
Due to reasons out of my control I inherited some source code that I will not be able to clear of all warnings (from that set) in the foreseeable future. In a Makefile based project I simply would have put
-Wno-whatever on the compile line. With CMake I seem to have run into the problem that the order of compile options is:
<this targets options>, <options propageted from dependencies>. I.e. even if I disable a warning for my target the “ON” switch of the option is introduced by my targets dependencies after the “OFF” switch, which in turn tells the compiler to use the warning.
So my question now is, how can I append a compile option to the end of the accumulated set of all compile options? Or am I abusing Interface targets here?
For now I simply do not depend on my
default_warnings target so I have a workaround but still I would like to be able to control the order or arguments passed to the compile, simply because the order matters.