On 2013-05-14 13:48, Todd Greer wrote:
My development team and I have struggled with what should be a simple question:
what is the best way to add project-wide compiler flags?
Here are the ways I've seen from the documentation and miscellaneous sources:
1. add_definitions function
2. COMPILE_FLAGS property
3. CMAKE_CXX_FLAGS / CMAKE_<lang>_FLAGS cache variable
Personally I use CMAKE_<lang>_FLAGS for this purpose, as does one of my
coworkers. AFAIK CMAKE_<lang>_FLAGS does apply to all configurations, it
is the CMAKE_<lang>_FLAGS_<config> that are per-config (and are in
addition to the non-config-specific flags).
One possible disadvantage to add_definitions is it is more difficult to
manipulate them later (specifically, there is remove_definitions but I
don't know offhand how, or if, you can get the current set of flags),
e.g. if someone downstream from you needs to remove flags you added.
(That said, my inclination would be to avoid doing this and instead
provide a variable with the flags you expect.)
--
Matthew
--
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake