using check_cxx_source_runs

Leo Franchi lfranchi at kde.org
Thu Mar 12 23:02:44 CET 2009


On 12 Mar 2009, at 21:46, Alexander Neundorf wrote:

> On Thursday 12 March 2009, Leo Franchi wrote:
>> n 12 Mar 2009, at 20:12, Alexander Neundorf wrote:
>>> On Thursday 12 March 2009, Leo Franchi wrote:
>>>> On 12 Mar 2009, at 19:49, Alexander Neundorf wrote:
>>>
>>> ...
>>>
>>>>> Can you please post a minimal example ?
>>>>> So I can just try and see what goes wrong ?
>>>>
>>>> and the cmake stuff is this:
>>>>
>>>> include(CheckCXXSourceRuns)
>>>>
>>>> file( READ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/
>>>> QtScriptBindingsTest.cpp" source )
>>>> message(STATUS "Checking if the QtScript Qt Bindings are  
>>>> installed.")
>>>>
>>>> #set( BINDINGS_RUN_RESULT -10 )
>>>> set(CMAKE_REQUIRED_DEFINTIONS ${QT_DEFINITIONS} $ 
>>>> {KDE4_DEFINITIONS} )
>>>> set(CMAKE_REQUIRED_INCLUDES ${QT_QTCORE_INCLUDE_DIR} $
>>>> {QT_QTSCRIPT_INCLUDE_DIR} ${KDE4_INCLUDES})
>>>> set(CMAKE_REQUIRED_LIBRARIES QtScript kdeui)
>>>
>>> I guess you tried ${QT_QTSCRIPT_LIBRARY} and ${KDE4_KDEUI_LIBS} ?
>>
>> First of all, apologies for the confusing emails. I've been hitting  
>> my
>> head against this for a while, so what came out was probably pretty
>> garbled and only made half sense.
>
> No, no, it made sense.
>
>> I didn't have a completely clean build dir (I guess on that test I  
>> had
>> just removed CMakeCache.txt)
>
> Yes, this was part of the problem.
>
>> and also I couldn't figure out why $
>> {KDE4_KDECORE_LIBS} didn't work. For some reason here the
>> KDE4_KDE*_LIBS variables resolve to something like KDE4__kdeui  
>> instead
>> of the actual path to the library.
>
> This is a new feature of cmake 2.6.
> It is a so-called imported target. The nice thing about an imported  
> library
> target (compared to a plain path) is that cmake can know more about  
> it. E.g.
> it knows the "LINK_INTERFACE_LIBRARIES" of such imported library  
> targets. So
> when you link against ${KDE4_KDEUI_LIBS}, which resolves to the  
> imported
> target KDE4__kdeui, cmake checks the properties of this imported  
> target (set
> in KDELibs4LibraryTargets.cmake, included by FindKDE4Internal.cmake  
> installed
> with kdelibs, included by FindKDE4.cmake coming with cmake). It then  
> finds
> the location of the file on disk (here: /opt/kdelibs/libkdeui.so. 
> 5.2.0), and
> also its link interface libraries (here:
> KDE4__kdecore;/usr/lib/qt4/lib/libQtSvg.so;/usr/lib/qt4/lib/ 
> libQtGui.so )
>
> So now when you link a target against this imported library target,  
> you will
> link against the library itself and the libraries from the link  
> interface
> (which is a good thing).
>
> Now you use ${KDE4_KDEUI_LIBS} with check_cxx_source_runs(). The  
> problem here
> now is that this creates a tiny cmake project itself, and then tries  
> to build
> and run it. But here this tiny independent cmake project is told to  
> link
> against KDE4__kdeui, but inside that project there are no imported  
> targets,
> so it just takes that string and tries to link against it
> using -lKDE4__kdeui, which of course fails.
>
> Please replace the CheckCXXSourceRuns.cmake which is installed by  
> the cmake on
> your system with the one attached to this email. It adds some basic  
> handling
> for using imported targets with check_cxx_source_runs().
> It's not perfect yet, but it works here for me.
> Please let me know if it works for you, then we can add it to
> kdelibs/cmake/modules/.
> A real fix for this should go into cmake itself.


Yeah, this works great. Actually, since the whole link interface stuff  
makes it resolve the dependencies (qtcore is linked twice), can we  
just specify KDE4_KDEUI_LIBS and KDE4_KDECORE_LIBS and let it do the  
rest?

Thanks for all the help,
leo

---
Leo Franchi				(650) 704 3680
Tufts University 2010

lfranchi at kde.org
leonardo.franchi at tufts.edu



More information about the Kde-buildsystem mailing list