[CMake] Where is QT_USE_IMPORTED_TARGETS not safe to use?

Stephen Kelly steveire at gmail.com
Wed Jun 22 15:51:20 EDT 2011


Alexander Neundorf wrote:
>> Is there some way I can modify that example to re-create the linker error
>> described in the comment?
> 
> Well, if simply the path is used, FindQt4.cmake does not have to be
> executed before.
> If imported targets are used, FindQt4.cmake has to be executed before (or
> at least at some point), otherwise nobody creates the imported targets
> (independent from the USE_IMPORTED_TARGETS switch).
> 
> I think that's all.

Interesting.

I think it would be very odd to not use FindQt4.cmake though. Not something 
to consider I think.

> 
>> > You can still test in e.g. GrantleeConfig.cmake whether the target
>> > Qt4::QtCore exists and fail with FATAL_ERROR if it doesn't.
>> > 
>> > I strongly recommend using these imported targets, one reason is
>> > because otherwise when installing a binary package of Grantlee under
>> > Windows, it will not be possible to freely choose the install location,
>> > or better the location where Qt must be is then already hardcoded in
>> > GrantLeeConfig.cmake (because then there won't be "Qt4::QtCore" in
>> > GrantleeConfig.cmake, but something like
>> > "c:/where/was/Qt/at/buildtime/QtCore.dll"). When then linking against
>> > Grantleee, and Qt is installed somewhere else, it will fail.
>> 
>> Yes, this makes sense. I think that's something we almost covered in the
>> review in Randa :). I am adding the setter to use the imported target
>> feature so it will be in the next release, but I also want to understand
>> it
> 
> What setter ?

Sorry, I meant the set(QT_USE_IMPORTED_TARGETS TRUE)

> I think you can simply use the exported targets.
> 

Agreed. Done now, thanks for the help. 

Steve.




More information about the CMake mailing list