Prevent qmake to create executable
-
Hello,
I am currently re-organizing my Qt project and wanted to move basic and common classes into a new subdir.
Since I am using subdirs project, this way, I have common classes, which then can be re-used for my GUI and my Command Line version.
Nevertheless, I can't figure out how to set-up my pro-file for this common-classes-including subdir, so that no dedicated exe file will be created for this subdir.Is there any way to prevent qmake from building a Makefile, which either does not include a "TARGET" property (thus, no executable will be compiled and no qmain is needed), or does not compile a executable but is integrated in my QtCreator project tree.
Thanks in advance for your help!
Best regards
Robiston -
welcome to devnet
If you are using
@
TEMPLATE = app
@in the template qmake will setup for an application.
You need to set
@
TEMPLATE = lib
@which will result in creating a library for the specific subdir.
"If you do not use 'app' it may be used since it is the default value.":http://qt-project.org/doc/qt-4.8/qmake-project-files.html#project-templates -
Hi and welcome to devnet,
Your common code should be in a subdir lib project (meaning using the lib template) and then you would link both your applications against that library.
Hope it helps
-
Thank you for your welcoming words.
Changing to lib Template is indeed a possibility to do this.
This way, I have the source files in a dedicated folder (e.g. "base") and separated them from other derived projects (e.g. "gui").Nevertheless, the solution is a little bit unclean, since a DLL is created by the linker, although not required at all.
And connecting the source files to the specific projects via interfaces (so that they are using the DLL accordingly) would be over-engineering here.More or less, my question related to project code management - so how to organize your code with Qt and QtCreator, if you have common classes, which will be re-used for more specific use cases.
Example:
@|__ base ------------,
|__ gui <---|
|__ command-line <---'@Thanks in advance for your feasible proposals how to manage this.
-
If you don't want a library then use a pri file that contains the same information as the pro would without TEMPLATE, CONFIG and other variables of this type, just HEADERS, SOURCES and INCLUDEPATH.
Include that pri in you other projects and you are good to go. Just beware that the files will be compiled several times