How it works

In this example, the warning flags -Wall, -Wextra, and -Wpedantic will be added to the compile options for the geometry target; both the compute-areas and geometry targets will use the -fPIC flag. Compile options can be added with three levels of visibility: INTERFACE, PUBLIC, and PRIVATE.

The visibility levels have the following meaning:

  • With the PRIVATE attribute, compile options will only be applied to the given target and not to other targets consuming it. In our examples, compiler options set on the geometry target will not be inherited by the compute-areas, even though compute-areas will link against the geometry library.
  • With the INTERFACE attribute, compile options on a given target will only be applied to targets consuming ...

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.