[cmake-developers] target_link_libraries, IMPORTED targets and SYSTEM includes
Stephen Kelly
steveire at gmail.com
Thu Jul 25 11:25:54 EDT 2013
Brad King wrote:
> On 07/25/2013 09:16 AM, Stephen Kelly wrote:
>> target_link_libraries(foo SYSTEM Qt5::Core)
>
> That looks okay to me so long as SYSTEM must always be the first keyword.
Yes, that's how I've implemented it currently.
> We could also consider adding it only to the modern (newest) keyword
> signature to encourage conversion to it.
I considered that, but I think the plain signature without
INTERFACE_LINK_LIBRARIES is going to remain most common in executable lhs
cases. I didn't see any need to exclude it from only the signature with
INTERFACE_LINK_LIBRARIES.
>
>> Should we treat the INTERFACE_INCLUDE_DIRECTORIES of all IMPORTED targets
>> as SYSTEM includes automatically?
>
> I don't think so because one could be importing targets from a dependency
> that was just built as part of a "superbuild" and may want to see the
> warnings.
I considered that, but if you're building it as part of a superbuild, you'll
still get the warning when building the dependency itself.
You control the flags used to build the dependency, so you can add the flag
to trigger the warning when building the dependency. If the dependency is
something you bundle, like zlib as in the case of Qt and cmake, then you
don't want to maintain patches to clean the headers, but you want them
upstream. At the same time, you don't want to trigger the warnings which may
be new with your compiler (usused typedefs is a common one nowadays) when
using the bundled dependency. When building it, you disable that warning,
and when using it, you want its headers treated as system headers, but you
still want the unused typedef warning for your own code.
So, I think it still makes sense to treat all interface include directories
of IMPORTED targets as SYSTEM includes.
Thanks,
Steve.
More information about the cmake-developers
mailing list