[CMake] Linker flags on all except a couple of programs

Paul Smith paul at mad-scientist.net
Thu Jan 12 00:49:36 EST 2017


I have a CMake-based build that creates about 170 binaries (most of them
are individual unit test programs).

I have set the CMAKE_EXE_LINKER_FLAGS to a set of flags I wanted on all
the binaries.

Now it turns out that I need to remove, or not set, one specific flag on
a small number (like 5) of these binaries, but I still want it set on
all the others.  Unfortunately for this flag there's no "turn it off"
extra flag I can add to the end of the list of flags: I have to actually
remove the flag itself.

What's the cleanest/simplest way to accomplish this?  I don't really
want to modify my cmake files to add an explicit set_target_property()
to all 165 binaries that I _do_ want to have this flag set on, just so I
can avoid calling it on the 5 binaries I don't.  I want to add something
particular to the 5 "oddball" binaries, instead, to override these
values.

But I can't seem to come up with a way to remove a flag from a global
list like this, just for one (or a few) targets.


Any hints?


More information about the CMake mailing list