Scope of compiler flags

In this particular example project, all source files use the same compile flags. For other projects, we may prefer to not define compile flags globally as we have done above, but to define flags individually for each target using target_compile_options. The advantage would be more flexibility and more local scope. The price to pay in our example here would probably be unnecessary code duplication.

Get CMake Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.