[CMake] Removing default COMPILE_FLAGS

Daniel Nelson torham at connect2.com
Tue Dec 1 19:09:19 EST 2009


> > I believe CMAKE_CXX_FLAGS is consulted each time an add_library() or
> > add_executable() call is processed. So you should be able to remove the
> > flag, add the singleton library/executable, and put the flag back.
> > 
> > tyler
> 
> This is the first thing I tried, however it doesn't seem to work.  
> I seems they are written to the flags.make files at the end, 
> with whatever the final value of CMAKE_CXX_FLAGS is.
> --
> Daniel  

Actually, I think it uses whatever the final value of CMAKE_CXX_FLAGS is within
the CMakeLists.txt file.  Since I was setting the variable back to its original
value in the same file with the target, the change was being undone, even
though I was setting it back after adding the target.  If I just leave the
value changed and let the normal scoping rules undo the change, it works
perfectly.

Now that I think about it, this seems like the same way that
include_directories() works.
--
Daniel



More information about the CMake mailing list