[CMake] restricting Qt include and library linking to 1 library/project

John Drescher drescherjm at gmail.com
Thu Dec 31 15:24:12 EST 2009


On Thu, Dec 31, 2009 at 3:12 PM, Hicham Mouline <hicham at mouline.org> wrote:
>> -----Original Message-----
>> From: Clinton Stimpson [mailto:clinton at elemtech.com]
>> Sent: 31 December 2009 16:08
>> To: Hicham Mouline
>> Cc: cmake at cmake.org
>> Subject: Re: [CMake] restricting Qt include and library linking to 1
>> library/project
>>
>>
>> If you have multiple directories with different Qt dependencies, you can
>> do:
>> find_package(Qt4 REQUIRED)
>> in the top directory,
>> then each sub directory can do something like
>> set(QT_USE_QTOPENGL 1)
>> include(${QT_USE_FILE})
>>
>> But in your case, its only lib3, so just do it in that CMakeLists.txt
>> file.
>>
>> Clint
>>
> That's what I did at the end.
> I did this:
>
> FIND_PACKAGE(Qt4 4.6.0 COMPONENTS QtCore QtGui QtOpenGL REQUIRED)
> INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR}
> ${QT_QTGUI_INCLUDE_DIR})
> MESSAGE(STATUS "QT_QTCORE_LIBRARY=${QT_QTCORE_LIBRARY}")
> TARGET_LINK_LIBRARIES(plot $QT_QTCORE_LIBRARY)
>
> The include dirs are set correctly, but I'm having trouble with
> QT_QTCORE_LIBRARY.
> This appears as :
> QT_QTCORE_LIBRARY=optimized;C:/Progra~2/Qt/4.6.0/lib/QtCore4.lib;debug;C:/Pr
> ogra~2/Qt/4.6.0/lib/QtCored4.lib
>
> When I open the solution with vs2008, the Librarian doesn't show this
> libraries as input.
>
> Note the help for TARGET_LINK_LIBRARIES displays the syntax as:
> target_link_libraries(<target> [item1 [item2 [...]]]
>                       [[debug|optimized|general] <item>] ...)
>
> There are no semicolons after the optimized|debug keywords, I wonder if by
> not using QT_USE_FILE, QT_QTCORE_LIBRARY are others are set incorrecty.
>

If you open cmake-gui does and look at the Qt tab in Grouped View are
the debug libraries properly set?

John


More information about the CMake mailing list