[cmake-developers] Setting target properties before the target is defined ?

Alexander Neundorf neundorf at kde.org
Mon Feb 18 12:33:42 EST 2013


On Monday 18 February 2013, Brad King wrote:
> On 02/17/2013 10:00 AM, Alexander Neundorf wrote:
> > On Sunday 17 February 2013, Brad King wrote:
> >> Just to make sure I understand correctly, you're bringing up a use case
> >> where an imported target's dependencies are not satisfied but it does
> >> not matter when the imported target is not used by the project?
> > 
> > Yes.
> > But I wouldn't call it use case, but a case which accidentially works
> > right
> 
> Why not?  Say I'm using a package that provides 50 different libraries
> that wrap around various third-party image file format readers.  Each
> library depends on a different third-party library for its corresponding
> format.  Say my app wants to use this to read JPEG but does not care
> about PNG.  Now I need to find PNG just to prevent the warning that
> the package's target would need it if I linked to the png reader even
> though I do not?

Interesting.
You'll have broken imported targets in your build, I think that's bad.
Telling the developer about it (it's a -Wno-dev warning) seems good to me.

IIRC we always said that
find_package(ImageReaders)
should in general find_package() everything it needs.
In the case above this would means also all required 3rd party libs, so that 
it is ready to use afterwards.

Would the ideal solution be to use components ?

find_package(ImageReaders COMPONENTS JPEG)

and the the ImageReadersConfig.cmake would include only those export-files 
which contain the JPEG-related targets ?


Or do we allow "broken" targets to exist (but not to be used) and do not 
demand anymore that
find_package(Foo)
does everything necessary ?


Alex



More information about the cmake-developers mailing list