[cmake-developers] Generating imported library targets without the cmake executable
Alexander Neundorf
neundorf at kde.org
Wed Nov 30 12:57:13 EST 2011
On Wednesday 30 November 2011, Stephen Kelly wrote:
> Alexander Neundorf wrote:
> > On Tuesday 29 November 2011, Stephen Kelly wrote:
> >> Alexander Neundorf wrote:
> >> >> I can't generate the files. I'm asking people with windows and mac
> >> >> setups to generate them and post them for review. I don't have those
> >> >> setups.
> >> >
> >> > Just the ones for Linux would already help :-)
> >>
> >> I managed to get generated files for windows and mac through some IRC
> >> puppeteering, so I've attached them here now.
> >>
> >> Thanks,
> >
> > I looked through the QtCore files.
> >
> > Some things:
> >
> > if (NOT _Qt5Core_target)
> >
> > set(_Qt5Core_target 1)
> > add_library(Qt5Core SHARED IMPORTED)
> > if (NOT "" STREQUAL "")
> >
> > set_property(TARGET Qt5Core PROPERTY FRAMEWORK 1)
> >
> > endif()
> >
> > endif()
> >
> > I think you can simply do:
> >
> > if(NOT TARGET Qt5Core)
> >
> > add_library(Qt5Core SHARED IMPORTED)
> > if (NOT "" STREQUAL "")
> >
> > set_property(TARGET Qt5Core PROPERTY FRAMEWORK 1)
> >
> > endif()
> >
> > endif()
>
> I didn't do it like this because that could potentially hide errors as
> described here:
>
> http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/2147/focus
> =2152
>
> Someone else could define a target called QtCore (in theory at least), and
> it makes sense to show a failure as early as possible.
Hmm, ok.
Somebody could also have set that variable already... ;-)
For Qt4 I have put the imported targets into a "namespace" "Qt4::", so they
are e.g. "Qt4::QtCore".
It looks nice and it makes somewhat clear that "Qt5Core" is not the name of an
in-project target, or the name of a library to link against, but something
special (an imported target). I'd do that here too, so it would be
"Qt5::Qt5Core" etc.
This also reduces the risk of name clashes even more.
> > Can this also handle already static builds of Qt ?
>
> Nope, not yet.
>
> Static builds of Qt are no longer tested by Nokia at least as far as I
> know. I don't know if it is even possible to build Qt statically on all
> (or any) platforms anymore.
Ah, ok.
So if we (at work) would like to have static builds, we maybe should take
action ?
Alex
More information about the cmake-developers
mailing list