QT Creator "subdirs" project
-
You can alternatively setup a pri file with all the Stanford code. And include that pri file in each of your separate projects. This way you would not need a subdirs project.
-
Hi,
Do you mean move all your files to the subproject folder used to build your library ?
-
@SGaist said in QT Creator "subdirs" project:
Hi,
Do you mean move all your files to the subproject folder used to build your library ?Let me explain:
This is the file structure I get when I unzip the starter project (i've left out some things I feel are non-essential):
simple_project - simple_project.pro - lib - StanfordCPPLib - *.h - *.cpp - private - *.h - stacktrace - *.h - *.cpp - src - *.h - *.c
As per how the .pro file is configured, the student is expected to complete an assignment by writing all his code in the
src
folder, and he can just#include
headers fromStanfordCPPLib
and hit "Build". However, this way allows only having one file containingmain()
in thesrc
folder. What I would rather be able to do is make multiple projects relying on the same code (StanfordCPPLib
), but which are otherwise independent of one another, each having its ownmain()
function, and do it in a way that would allow me to keep all these "sister projects" together in the same hierarchy in a non-interfering way whilst making the least amount of additions to the .pro files or build system boilerplate.Even though this is just for learning purposes and I can conceive of several (inelegant) ways of getting around the issue, I was wondering what the best way would be in this situation.
(I still have to look into @t3685's suggestion, at first glance it seems closest to what I want.)
-
A more flexible sub-project setup:
complex_project - sub_project.pro - lib - lib.pro <- TEMPLATE = subdirs - StanfordCPPLib - StanfordCPPLib.pro - StanfordCPPLib.pri <- will be included by your applications - *.h - *.cpp - private - *.h - stacktrace - *.h - *.cpp - apps - apps.pro <- TEMPLATE = subdirs - my_app - my_app.pro -> include(../../lib/StanfordCPPLib/StanfordCPPLib.pri) - *.h - *.cpp
StanfordCPPLib.pri
will contain statements likeÌNCLUDEPATH
andLIBS
to set things up for the projects using that library. Doing so will avoid duplication in your apps .pro file. -
Hi,
Not my knowledge.
-
In your main pro file :
TEMPLATE = subdirs SUBDIRS += \ ADD YOUR SUBDIR NAME HERE
#To use ordered build: CONFIG += ordered
In your subdir pro file:
TARGET= ... QT += ... SOURCES += \ ... HEADERS += \ ... FORMS += \ ... RESOURCES += \ ...
@Raad Please avoid
ordered
and specify the dependencies directly.See this very good blog post.
-
@Raad Please avoid
ordered
and specify the dependencies directly.See this very good blog post.