[cmake-developers] [CMake 0015101]: Imported libraries go out of scope after call to target_link_libraries().

Mantis Bug Tracker mantis at public.kitware.com
Fri Aug 22 08:29:51 EDT 2014


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=15101 
====================================================================== 
Reported By:                Björn Piltz
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15101
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2014-08-22 08:29 EDT
Last Modified:              2014-08-22 08:29 EDT
====================================================================== 
Summary:                    Imported libraries go out of scope after call to
target_link_libraries().
Description: 
I have a project where module lib - a library - depends on Qt, so it calls
find_package(Qt5 ...) and target_link_libraries(lib Qt5::Core). Later I call
target_link_libraries(app lib). 
The cmake configure step runs through without problems, but the generate step
halts with the message:

    Target "app" links to target "Qt5::Core" but the target was not found.
    Perhaps a find_package() call is missing for an IMPORTED target, or an
    ALIAS target is missing?

According to the documentation the target Qt5::Core is out of scope for 'app'
since app is not in a subdirectory of the directory where add_library(...
IMPORTED) was made, but I would argue that this is a bug since the target was in
scope when the call add_library(lib Qt5::Core) was made.

This issue is not specific to Qt and I'm aware that it could be fixed on their
side by calling add_library(... IMPORTED GLOBAL).  I'm hoping it could be fixed
on the cmake side, though.

Steps to Reproduce: 
git clone https://github.com/bjornpiltz/cmake_bug.git cmake_bug
mkdir work
cd work
cmake -DCMAKE_PREFIX_PATH=<Qt5>/lib/cmake/ ../cmake_bug/

Additional Information: 
This issue is platform independent.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2014-08-22 08:29 Björn Piltz    New Issue                                    
======================================================================



More information about the cmake-developers mailing list