[CMake] Proper way to redefine build type compiler options

Neil Carlson neil.n.carlson at gmail.com
Sat Mar 19 10:13:10 EDT 2016


What is considered best practice for (re)defining build-type compiler
options for a project, especially one that may find itself as a subproject
of something larger?

To be concrete, say for Debug I want the project to use a set of warn/check
options.  Should I set (or add to) CMAKE_C_FLAGS_DEBUG, and if so
should I use the CACHE FORCE options to get it into the cache? (I don't
have a good feel for the implications.)  Or is it better to append to
CMAKE_C_FLAGS?  I observe that the value of the latter precedes the
value of the build-type variables on the compile line, and so it can't
override
those defaults.  Or is some other way best?

Also, say there was a compiler flag that was absolutely required.  Where
to add it so that it didn't get overridden by anything coming in through
either CMAKE_C_FLAGS or the build-type specific variables?

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160319/a893f3f6/attachment.html>


More information about the CMake mailing list