[CMake] FIND_LIBRARY and OS X Frameworks

William A. Hoffman billlist at nycap.rr.com
Fri Mar 31 13:11:43 EST 2006


At 12:41 PM 3/31/2006, Tanner Lovelace wrote:
>Greetings,
>
>I have a weird cmake problem.  In the KDE FindQt4.cmake, currently
>if we determine Qt has been compiled as OS X frameworks, the library
>variables are set by hand to be "-F${QT_LIBRARY_DIR} -framework <frameworkname>"
>instead of using FIND_LIBRARY.  I noticed, however, that FIND_LIBRARY
>has support for finding frameworks so I tried switching it over to that.
>That works and it sets the library variable to the path to the framework
>(i.e. /usr/local/Trolltech/Qt-4.1.1/lib/QtCore.framework).  The find_library
>documentation says "When a full path to a framework is used as a library,
>CMake will use a -framework A and a -F<fullpath> to link the framework
>to the target."
>
>Ok, so far so good.  It does indeed do this correctly.  However, when we
>get into attempting to link the kdecore library, I run into multiple undefined
>symbols.  Looking at the CMakeLists.txt file where libkdecore is defined,
>the only thing I think might make a difference is that the libraries we're not
>linking to are defined in separate target_link_libraries lines.  For instance
>here's the main link line:
>
>target_link_libraries(kdecore  ${QT_QTCORE_LIBRARY}
>${QT_QT3SUPPORT_LIBRARY} ${QT_QTGUI_LIBRARY} ${X11_LIBRARIES}
>${UTIL_LIBRARY} DCOP ${ZLIB_LIBRARY} ${CARBON_LIBRARY})
>
>and further down we have:
>
>if(BZIP2_FOUND)
>   target_link_libraries(kdecore  ${BZIP2_LIBRARIES})
>endif(BZIP2_FOUND)
>
>while the BZIP2_FOUND variable is set to true, for some reason when I
>use find_library to find the qt frameworks, it doesn't get added correctly
>and when the qt frameworks are set manually it does get added to the
>link line correctly.
>
>One other note.  Part of the error message I get includes this:
>
>/usr/bin/libtool: internal link edit command failed
>
>Which seems to me like it was trying to edit a link command to add
>extra defines, but something failed on it.
>
>So, can anyone explain
>
>a) how the substitution of -F dir -framework name happens and if something
>there could be causing a problem

If a path to a framework is found linked to a target, cmake turns
that into -F and -framework  options.   It is not that complicated,
if you do a make VERBOSE=1 you should be able to see the link line
being used.   Can you send me the output of the link for the
one that works and the one that does not?


>b) is there something wrong because not everything is in the same
>target_link_libraries
>line?

I don't think so.  It could be an ordering thing perhaps?

>c) what else have I missed? (could it be something simple?)

Not, sure but send me the output, and maybe I can find something.


-Bill



More information about the CMake mailing list