On 2017-01-12 00:49, Paul Smith wrote:
> 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.

I *thought* (but have not checked) that after the target exists, you can
get its link flags as a target property, which you could then adjust as

Failing that, I think you can remove the flag from the appropriate
global variable, create the target (add_executabe or whatever), then
restore the previous value. If you wrap this in a function, it will
scope the value so you don't even have to worry about restoring it after.

Of course, you could also just wrap all your add_executable calls in a
function that handles the set_target_property dance for you...

Hope this helps!


Powered by www.kitware.com

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: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 

Follow this link to subscribe/unsubscribe:

Reply via email to