[Qt-interest] How should sources in subdir be compiled?
André Somers
andre at familiesomers.nl
Sun Mar 28 17:48:36 CEST 2010
I have no experience with CMake, but in QMake, I can suggest some options:
Simplest is to just add the files with the subdir included in the path:
HEADERS += GUI/mainwindow.h \
GUI/init/initmainwindow.h
SOURCES += GUI/mainwindow.cpp \
...
Another option, is to create a .pri file in each of the subdirectories. A .pri file is just like a .pro file, only it is mend to be included into another .pro file and is thus not a complete definition of a project by itself. In this case, you probably end up with something like this:
Project.pro:
SOURCES += main.cpp
include(GUI/gui.pri)
gui.pri:
HEADERS += mainwindow.h
SOURCES += mainwindow.cpp
include(init/init.pri)
init.pri:
SOURCES += initmainwindow.cpp
I use the second option often for some mini-components that I use in multiple applications. By just including the associated .pri file, I pull in the sources for these components and all that is needed into the application's project file. No need for an actual library in this case.
André
-----Oorspronkelijk bericht-----
Van: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] Namens Karlis Repsons
Verzonden: zondag 28 maart 2010 16:18
Aan: qt-interest at trolltech.com
Onderwerp: [Qt-interest] How should sources in subdir be compiled?
Coders,
could someone tell me how should a Qt project be compiled, when its structure is like:
project
-main.cpp
-GUI
--mainwindow.cpp
--mainwindow.h
--init
---initmainwindow.cpp
I just tried with CMake, but maybe you can suggest an example or give some advice (I like to make a tree of dirs/files rather than put them all into a single dir)?
More information about the Qt-interest-old
mailing list