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

Hicham Mouline hicham at mouline.org
Thu Dec 31 15:12:28 EST 2009


> -----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.

Rds,



More information about the CMake mailing list