[cmake-developers] Support for imported targets in CMAKE_REQUIRED_LIBRARIES

Rolf Eike Beer eike at sf-mail.de
Wed Jan 18 16:44:26 EST 2012


Alexander Neundorf wrote:
> On Wednesday 18 January 2012, Alexander Neundorf wrote:
> > Hi,
> > 
> > the variable CMAKE_REQUIRED_LIBRARIES is used by several of the
> > check-modules for listing additional libraries which should be linked.
> > It is common to use variables set by Find-modules for this, e.g.
> > set(CMAKE_REQUIRED_LIBRARIES ${JPEG_LIBRARIES} )
> > 
> > Now, if the module did not simply set JPEG_LIBRARIES to the full path,
> > but instead created an imported target, e.g. FindJPEG::libjpeg, this
> > leads to a problem.
> > The check-modules will simply append this to the linker command, so
> > there
> > will be -lFindJPEG::libjpeg, which will not work.
> > This actually happened in KDE the first time more than 2 years ago.
> > 
> > On cmake stage there is now a branch
> > HandleTargetsInCMakeRequiredLibraries, where I ported the solution from
> > KDE to CMake and applied it to all places where
> > CMAKE_REQUIRED_LIBRARIES is used.
> > I did not test it yet (but it should work, since it is exactly the same
> > as in KDE).
> > 
> > Please have a look at it.
> 
> It's here:
> http://cmake.org/gitweb?p=stage/cmake.git;a=log;h=refs/heads/HandleTargetsIn
> CMakeRequiredLibraries

Some minor nitpicks just when I read through it:

-you introduced double newlines after the include() in many modules
-the doc header of the module says CMAKE_REQUIRED_LIBRARY instead of ...IES
-is it really KDE4__kdeui or KDE4_kdeui (1 vs. 2 underscores)?
-I'm no native speaker, but shouldn't it be "100 is arbitrarily chosen"? (and 
an extra space after the ( removed
-is it useful to call list(REMOVE_DUPLICATES) at the end? If I link in 3 KDE 
libs I otherwise would get the whole dependencies of e.g. kdecore at least 3 
times, no?

Eike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20120118/877c6dde/attachment.sig>


More information about the cmake-developers mailing list