[CMake] Imported libraries lookup

Sergey Rudchenko sergey.rudchenko at gmail.com
Wed Apr 22 10:13:07 EDT 2009


On Wed, 2009-04-15 at 13:23 -0400, Brad King wrote: 
> 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

What piece of code should handle those imported targets? I thought it is
cmMakefile::AddLinkLibraryForTarget, but it doesn't do that. Should a
local generator check itself whether a library is an imported target?
I thought this work is done transparently for generators.

I use cmLocalVisualStudio6Generator as a reference and looked at the
cmLocalUnixMakefileGenerator3 but still do not understand how to distinguish
imported link libraries from other ones in a LocalGenerator.
Please, give me a point.

Now I'm working in the CVS source.

Thanks,
Sergey




More information about the CMake mailing list