[CMake] Erasing a compiler flags

Philip Lowman philip at yhbt.com
Tue Mar 3 23:33:50 EST 2009


On Tue, Mar 3, 2009 at 3:54 PM, Leopold Palomo Avellaneda
<leo at alaxarxa.net>wrote:

> > Hope that helps
>
> Yes, sure. Thanks. It's not exactly what I wanted, but it will help me.
>
> Thanks a lot.
>
> Best regards,


Another idea might be to use a function to add the flags with COMPILE_FLAGS
to all of your targets except one of them that passes a special argument to
the function...  Of course then you have to modify every one of your
CMakeLists.txt to call this special function.

(this is pseudo code but you probably get the idea):

# Assume BLAH is the thing you want added everywhere except one target
# have everyone call fixor_target(target) after creating a target, except
for the one where you want the flags stripped, then call
# fixor_target(target NOBLAH)
#
function(fixor_target _target)
 if (${ARGN} list contains "NOBLAH") # use LIST(FIND... or STRING(MATCH ...
   get_target_property(existing_compile_flags ${_target} COMPILE_FLAGS)
   set_target_properties(_target PROPERTIES COMPILE_FLAGS
"${existing_compile_flags} -BLAH")
 endif()
endfunction()


-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090303/026c194c/attachment.htm>


More information about the CMake mailing list