[Qt-interest] cmake: how to set up a deep project tree

Rui Maciel rui.maciel at gmail.com
Tue Feb 14 15:46:24 CET 2012


Andreas Pakulat wrote:

> Its recommended to instead store the result of pkg_check_modules in an
> internal variable and then use find_path and find_library with HINTS to
> let cmake setup the actual library/include variables. The benefit of
> this is proper dependency tracking by cmake's makefiles for those
> external libraries. See the FindLibXml2.cmake shipped with CMake module
> for an example.

Thanks for the tip.  I'll look into it. 


>> INCLUDE(${QT_USE_FILE})
> 
> This is unecessary here since its already done in the top-level file.

Quite true.


>> ADD_DEFINITIONS(${QT_DEFINITIONS})
> 
> This is unecessary when using the QT_USE_FILE, see the cmake manual for
> FindQt4.

Again, you are right.


> Personally I wouldn't use static libs for data or ui (at least not in
> such small projects), but simply handle everything in the
> src/CMakeLists.txt via relative paths (i.e. data/data.c
> ui/MainWindow.cpp).

The project used as an example was only an example project, tailoured to 
demonstrate how to set up such a project without having long lists of source 
files getting in the way.  

If a project consists of half dozen source files then it wouldn't make much 
sense to set up a pair of static libraries and disperse the source code 
files through a directory tree with 3 or 4 levels.  Yet, projects do tend to 
grow, and even the project which served as a basis for this guide, which was 
started recently, already has about 30 or 40 source files dispersed through 
out the project tree. 


Thanks for the tips,
Rui Maciel



More information about the Qt-interest-old mailing list