[CMake] Where is QT_USE_IMPORTED_TARGETS not safe to use?
Stephen Kelly
steveire at gmail.com
Wed Jun 22 09:01:08 EDT 2011
Wups, sent a moment to early...
Stephen Kelly wrote:
> Clinton Stimpson wrote:
>> It means the target must be created again with something like
>> add_library(Qt4::QtCore UNKNOWN IMPORTED)
>>
>> If GrantleeConfig.cmake were to do this:
>> SET(QT_USE_IMPORTED_TARGETS 1)
>> find_package(Qt4 REQUIRED)
>>
>> then the imported targets would satisfy the Qt4::QtCore reference and
>> others from your GrantleeTargets-debug.
>>
>>>
>>> > The GrantleeConfig.cmake could set QT_USE_IMPORTED_TARGETS and a
>>> > find_package(Qt4) to recreated those imported targets.
>>>
>>> Ok, so maybe setting cis the thing that needs to
>>> be done 'again' by project B?
>>
>> Yes, or preferably in your GrantleeConfig.cmake so project B doesn't have
>> to do it.
>>
>
> I tried creating the error scenario, but it does work even if the
> downstream does not set QT_USE_IMPORTED_TARGETS and even if I don't put it
> in GrantleeConfig either. Qt4::QtCore is never interpreted as a file path
> because FindQt4.cmake sets it unconditionally, and only conditionally sets
> QT_QTCORE_LIBRARY to Qt4::QtCore based on QT_USE_IMPORTED_TARGETS.
That means that if GrantleeTarget-debug uses
IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG "Qt4::QtCore"
then the Qt4::QtCore will never be interpreted as a file on disk and the
comment in the file:
> This
> means when a project B then uses project A, these imported targets must be
> created again, otherwise e.g. "Qt4__QtCore" will be interpreted as name of
> a library file on disk, and not as a target, and linking will fail.
is not correct. Right?
Also, it means that I don't have to use
SET(QT_USE_IMPORTED_TARGETS 1)
find_package(Qt4 REQUIRED)
in my GrantleeConfig?
Thanks,
Steve.
More information about the CMake
mailing list