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

2009-12-31 Thread Hicham Mouline
Hello,

My toplevel CMakeLists.txt looks like:



PROJECT(...)

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

# Openmp
FIND_PACKAGE(OpenMP)
IF(OPENMP_FOUND)
  SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS})
ENDIF()

# Boost
FIND_PACKAGE(Boost)
IF(Boost_FOUND)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
ENDIF()

# Qt
FIND_PACKAGE(Qt4 4.6.0 COMPONENTS QtCore QtGui QtOpenGL REQUIRED)
INCLUDE(${QT_USE_FILE})

INCLUDE_DIRECTORIES(AFTER ${CMAKE_CURRENT_SOURCE_DIR})

ADD_SUBDIRECTORY(common)
ADD_SUBDIRECTORY(lib1)
ADD_SUBDIRECTORY(lib2)
ADD_SUBDIRECTORY(lib3)
ADD_SUBDIRECTORY(main)




Using QT_USE_FILE includes Qt headers for all of common, lib1, lib2, lib3.
How can I include and link Qt only for lib3?

Lib3's CMakeLists.txt looks like:

ADD_LIBRARY(lib3 STATIC #cpps hpps ipps)

ADD_DEPENDENCIES(lib3 common)

TARGET_LINK_LIBRARIES(lib3 ${QT_LIBRARIES})

Rds,

___
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


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

2009-12-31 Thread Pau Garcia i Quiles
Hello,

Do find_package( Qt4 COMPONENTS ... ) from each subdir and use only
the components you need for each library.

Do not INCLUDE( ${QT_USE_FILE} ) in any case, just do an include_directories.

When linking, do not use the contain-all QT_LIBRARIES variable but the
individual library variables.

Assuming lib1 uses QtCore and QtNetwork:

find_package( Qt4 COMPONENTS QtCore QtNetwork REQUIRED )
include_directories( ${QT_QTCORE_INCLUDE_DIR} ${QT_QTNETWORK_INCLUDE_DIR} )
add_library( lib1 SHARED lib1_source1.cpp lib1_source2.cpp ... )
target_link_libraries( lib1 ${QT_QTCORE_LIBRARIES} ${QT_QTNETWORK_LIBRARIES} )

You'd do similar for lib2 and lib3 and the main CMakeLists.txt would
only contain something like:

project( blah )

add_directory( lib1 )
add_directory( lib2 )
add_directory( lib3 )

i. e. no find_package( Qt4 ...) in the main CMakeLists.txt [*]

[*] Actually you can do the find_package( Qt4 COMPONENTES
yourcomponents ) in the main CMakeLists.txt but then you need to
specify all the components required by all the directories below that
one in the hierarchy, which is more difficult to track.


On Thu, Dec 31, 2009 at 2:45 PM, Hicham Mouline hic...@mouline.org wrote:
 Hello,

 My toplevel CMakeLists.txt looks like:

 
 
 PROJECT(...)

 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

 # Openmp
 FIND_PACKAGE(OpenMP)
 IF(OPENMP_FOUND)
  SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS})
 ENDIF()

 # Boost
 FIND_PACKAGE(Boost)
 IF(Boost_FOUND)
    INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
 ENDIF()

 # Qt
 FIND_PACKAGE(Qt4 4.6.0 COMPONENTS QtCore QtGui QtOpenGL REQUIRED)
 INCLUDE(${QT_USE_FILE})

 INCLUDE_DIRECTORIES(AFTER ${CMAKE_CURRENT_SOURCE_DIR})

 ADD_SUBDIRECTORY(common)
 ADD_SUBDIRECTORY(lib1)
 ADD_SUBDIRECTORY(lib2)
 ADD_SUBDIRECTORY(lib3)
 ADD_SUBDIRECTORY(main)
 
 


 Using QT_USE_FILE includes Qt headers for all of common, lib1, lib2, lib3.
 How can I include and link Qt only for lib3?

 Lib3's CMakeLists.txt looks like:

 ADD_LIBRARY(lib3 STATIC #cpps hpps ipps)

 ADD_DEPENDENCIES(lib3 common)

 TARGET_LINK_LIBRARIES(lib3 ${QT_LIBRARIES})

 Rds,

 ___
 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




-- 
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)
___
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


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

2009-12-31 Thread Hicham Mouline


 -Original Message-
 From: Pau Garcia i Quiles [mailto:pgqui...@elpauer.org]
 Sent: 31 December 2009 14:07
 To: Hicham Mouline
 Cc: cmake@cmake.org
 Subject: Re: [CMake] restricting Qt include and library linking to 1
 library/project
 
 Hello,
 
 Do find_package( Qt4 COMPONENTS ... ) from each subdir and use only
 the components you need for each library.
 
 Do not INCLUDE( ${QT_USE_FILE} ) in any case, just do an
include_directories.
 
 When linking, do not use the contain-all QT_LIBRARIES variable but the
 individual library variables.
 
 Assuming lib1 uses QtCore and QtNetwork:
 
 find_package( Qt4 COMPONENTS QtCore QtNetwork REQUIRED )
 include_directories( ${QT_QTCORE_INCLUDE_DIR} ${QT_QTNETWORK_INCLUDE_DIR}
)
 add_library( lib1 SHARED lib1_source1.cpp lib1_source2.cpp ... )
 target_link_libraries( lib1 ${QT_QTCORE_LIBRARIES}
${QT_QTNETWORK_LIBRARIES} )

Does this take care of both release and debug libraries?
Ie, in release build, it will include release libs and in debug debug libs?

Thanks for this,

___
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


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

2009-12-31 Thread Pau Garcia i Quiles
On Thu, Dec 31, 2009 at 4:06 PM, Hicham Mouline hic...@mouline.org wrote:

 Assuming lib1 uses QtCore and QtNetwork:

 find_package( Qt4 COMPONENTS QtCore QtNetwork REQUIRED )
 include_directories( ${QT_QTCORE_INCLUDE_DIR} ${QT_QTNETWORK_INCLUDE_DIR}
 )
 add_library( lib1 SHARED lib1_source1.cpp lib1_source2.cpp ... )
 target_link_libraries( lib1 ${QT_QTCORE_LIBRARIES}
 ${QT_QTNETWORK_LIBRARIES} )

 Does this take care of both release and debug libraries?
 Ie, in release build, it will include release libs and in debug debug libs?

Yes, it does. Take a look at FindQt4.cmake for the details.

-- 
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)
___
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


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

2009-12-31 Thread Clinton Stimpson

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

On Dec 31, 2009, at 6:45 AM, Hicham Mouline wrote:

 Hello,
 
 My toplevel CMakeLists.txt looks like:
 
 
 
 PROJECT(...)
 
 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 
 # Openmp
 FIND_PACKAGE(OpenMP)
 IF(OPENMP_FOUND)
  SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS})
 ENDIF()
 
 # Boost
 FIND_PACKAGE(Boost)
 IF(Boost_FOUND)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
 ENDIF()
 
 # Qt
 FIND_PACKAGE(Qt4 4.6.0 COMPONENTS QtCore QtGui QtOpenGL REQUIRED)
 INCLUDE(${QT_USE_FILE})
 
 INCLUDE_DIRECTORIES(AFTER ${CMAKE_CURRENT_SOURCE_DIR})
 
 ADD_SUBDIRECTORY(common)
 ADD_SUBDIRECTORY(lib1)
 ADD_SUBDIRECTORY(lib2)
 ADD_SUBDIRECTORY(lib3)
 ADD_SUBDIRECTORY(main)
 
 
 
 
 Using QT_USE_FILE includes Qt headers for all of common, lib1, lib2, lib3.
 How can I include and link Qt only for lib3?
 
 Lib3's CMakeLists.txt looks like:
 
 ADD_LIBRARY(lib3 STATIC #cpps hpps ipps)
 
 ADD_DEPENDENCIES(lib3 common)
 
 TARGET_LINK_LIBRARIES(lib3 ${QT_LIBRARIES})
 
 Rds,
 
 ___
 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

___
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


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

2009-12-31 Thread Hicham Mouline
 -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,

___
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


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

2009-12-31 Thread John Drescher
On Thu, Dec 31, 2009 at 3:12 PM, Hicham Mouline hic...@mouline.org 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.


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

John
___
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


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

2009-12-31 Thread John Drescher
 If you open cmake-gui does and look at the Qt tab in Grouped View are
 the debug libraries properly set?

Hmm sorry for the bad wording..

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

John
___
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


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

2009-12-31 Thread Clinton Stimpson

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


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

2009-12-31 Thread John Drescher
On Thu, Dec 31, 2009 at 5:06 PM, Hicham Mouline hic...@mouline.org wrote:
 -Original Message-
 From: John Drescher [mailto:dresche...@gmail.com]
 Sent: 31 December 2009 20:25
 To: Hicham Mouline; CMake mailing list
 Subject: Re: [CMake] restricting Qt include and library linking to 1
 library/project

  If you open cmake-gui does and look at the Qt tab in Grouped View are
  the debug libraries properly set?
 
 Hmm sorry for the bad wording..

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

 John

 The _DEBUG and _RELEASE version of the cmake variables look properly set in
 cmake-gui
 Thanks

I asked this because one time I forgot to build the debug version of
Qt and cmake supplied the release versions of all the Qt libraries for
my projects debug and release builds.

John
___
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


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

2009-12-31 Thread Hicham Mouline
 -Original Message-
 From: Clinton Stimpson [mailto:clin...@elemtech.com]
snip

ADD_LIBRARY(plot STATIC
...
...
...)
TARGET_LINK_LIBRARIES(plot C:/Progra~2/Qt/4.6.0/lib/QtCored4.lib)

1. from cmd dos: dir C:/Progra~2/Qt/4.6.0/lib/QtCored4.lib  = nothing
   But dir C:\Progra~2\Qt\4.6.0\lib\QtCored4.lib  = works

2. I tried all the following:
TARGET_LINK_LIBRARIES(plot C:/Progra~2/Qt/4.6.0/lib/QtCored4.lib)
TARGET_LINK_LIBRARIES(plot C:/Progra~2/Qt/4.6.0/lib/QtCored4.lib)

Neither generates a plot.vcjproj containing this .lib at all

TARGET_LINK_LIBRARIES(plot C:\Progra~2\Qt\4.6.0\lib\QtCored4.lib)
TARGET_LINK_LIBRARIES(plot C:\Progra~2\Qt\4.6.0\lib\QtCored4.lib)
Fail with a syntax error by cmake.

I then tried 

FILE (TO_CMAKE_PATH C:\\Program Files (x86)\\Qt\\4.6.0\\lib\\QtCored4.lib
MY_QTCORELIB)
TARGET_LINK_LIBRARIES(plot MY_QTCORELIB)

But still not QtCored4.lib in the vcproj

Rds,

___
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