On Dec 31, 2009, at 1:12 PM, Hicham Mouline wrote:

>> -----Original Message-----
>> From: Clinton Stimpson [mailto:clin...@elemtech.com]
>> Sent: 31 December 2009 16:08
>> To: Hicham Mouline
>> Cc: cmake@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,
> 

You probably meant ${QT_QTCORE_LIBRARY} instead of $QT_CORE_LIBRARY

What about this:

find_package(Qt4 4.6.0 COMPONENTS QtCore QtGui QtOpenGL REQUIRED)
include(${QT_USE_FILE})
...
target_link_libraries(plot ${QT_LIBRARIES})

The file pointed to by QT_USE_FILE sets up the current directory with include 
directories and compile flags and sets up QT_LIBRARIES for the chosen 
components.
You can do it on your own, but its more work.

Clint

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to