[CMake] Adding a compiler flag globally

Alexander Neundorf a.neundorf-work at gmx.net
Sun Jan 20 07:18:39 EST 2008


On Sunday 20 January 2008, Robert Bielik wrote:
> I'd like to add a compiler flag globally for all targets within a project
> (multiple targets and CMakeLists.txt files), i.e. I don't want to use
> SET_TARGET_PROPERTIES.
>
> I tried updating the CMAKE_CXX_FLAGS_RELEASE but nothing happens, the added
> flag doesn't show up in the cache.

If you just put 
set(CMAKE_CXX_FLAGS_RELEASE -your -flags)
in some top level CMakeLists.txt, this will be executed on each cmake run and 
the flags will be used. But the value won't be stored in the cache (which 
shouldn't be a problem).
Or you can edit the value directly in the cache e.g. using "make edit_cache"

Alex


More information about the CMake mailing list