[CMake] Imported libraries lookup

Brad King brad.king at kitware.com
Wed Apr 15 13:23:10 EDT 2009


Sergey Rudchenko wrote:
> Hi all,
> 
> My global generator adds some imported libraries in EnableLanguage 
> method, but the TARGET_LINK_LIBRARIES command doesn't obey that fact the 
> libraries are imported.
> Here is the code which adds an imported library:
> 
> void cmGlobalSymbianMmpGenerator
> ::EnableLanguage(std::vector<std::string>const& languages,
>                 cmMakefile* mf, bool optional)
> {
>    ...
>    cmTarget* tgt = mf->AddImportedTarget(targetName.c_str(), 
> cmTarget::SHARED_LIBRARY);
>    tgt->SetProperty("IMPORTED_IMPLIB", importedImplib.c_str());
> }
> 
> CMakeLists.txt:
> add_executable(test test.cpp)
> target_link_libraries(test euser)
> 
> I expected to know in my local generator whether the library is shared 
> or not, but currently cmTarget::GetLinkLibraries() gives me 
> cmTarget::GENERAL there.
> 
> My observations:
> cmTargetLinkLibraries doesn't lookup linked library name in the imported 
> targets, so it assumes it's link type is cmTarget::GENERAL.
> 
> cmMakefile::AddImportedTarget() creates a new target object in the 
> cmMakefile::ImportedTargets container, but 
> cmMakefile::AddLinkLibraryForTarget (TARGET_LINK_LIBRARIES essential) 
> does not lookup lib name in that container too.
> 
> I am working in the 2.6.2 source tree.

In 2.6.2 an imported target is not recognized unless it sets IMPORTED_LOCATION
(in this case to the location of the .dll, even if the location is bogus).
Just IMPORTED_IMPLIB is not enough.  Just recently in CMake HEAD from CVS I
committed changes to support setting only IMPORTED_IMPLIB on imported shared
libraries on DLL platforms.

I just updated the corresponding bug:

   http://www.cmake.org/Bug/view.php?id=8486

-Brad



More information about the CMake mailing list