proper setting of the include system property of an imported target.

My goal is simple. When I consume a given library header through:

target_link_libraries(<target> [Inheritance] <package>)

I would like to treat <package> header as system or not system regardless of how it has been actually packaged.

Besides, when using several packages, I may have different settings, according to the package.

Eventually, I’d like my own libraries (to be imported) being not system by default.

Yet I’m confused by CMake documentation that propose several mechanisms, some of them being deprecated:

  • NO_SYSTEM_FROM_IMPORTED, which seems to be a global option for the target/consumer
  • IMPORTED_NO_SYSTEM (marked as deprecated), which was supposed to set the behavior per imported target/package
  • SYSTEM, which is an option that is set by the “to be consumed/imported” target
  • EXPORT_NO_SYSTEM that I don’t really understand.

Would it be possible to have an example (or a link to) of how to answer my need?
Where can I find clarifications on the different mechanisms usage?
How do they interact (for instance, if a library has been packaged as system but the client wants to included its headers as non system, or the other way around)?

Thanks in advance,
how do they interact?

I’m not sure that there’s a coherent design behind the current state. I’m not sure I could reliably articulate what the expected behavior with all of those variables in play would be either. I suspect the best thing to do would be to make test cases for each combination you’re interested in (others can fill in any remaining ones; comments for what is missing would be appreciated if you know) to at least demonstrate (and possibly improve the documentation of) the existing behavior. Once we have that, we can look at adding more knobs and/or policies to make things into something more coherent.