Qmake: editing global configuration for a SUBDIRS project
-
No no, it's really
.qmake.conf
that I was suggesting. -
Where do you have that file located ?
What is in it ? -
@SGaist
It's located one directory above theSUBREPOS
.pro file. The contents is as follows. There is no message, and no config or variable in the sub-projects.CONFIG += my_config MY_VAR=12345678 message(CACHE!!!)
-
@Violet-Giraffe I hope I can provide useful input. @SGaist gave me advice on a different problem and while I haven't resolved my problem, I think I see the behavior you want to achieve; my
.qmake.conf
adds a value to CONFIG that propagates to all subfolder projects.I have a root SUBDIRS project. In that project folder, I have a
.qmake.conf
file containing:CONFIG += my_velociraptor
I added message() statements to each of my .pro files such as:
contains(CONFIG, my_velociraptor): message(root SUBDIRS .pro file: \ my_velociraptor found in $$_PRO_FILE_)
My output:
Project MESSAGE: root SUBDIRS .pro file: my_velociraptor found in E:/Dev/QtTestPlay/QtTestPlay.pro Project MESSAGE: my_velociraptor found in E:/Dev/QtTestPlay/TestName-1/TestName-1.pro Project MESSAGE: my_velociraptor found in E:/Dev/QtTestPlay/AutoTestProject-2/AutoTestProject-2.pro
Each .pro file confirms the presence of the CONFIG value I added in the
.qmake.conf
file in the same folder as the .pro file containingTEMPLATE = subdirs
.BTW, I had to touch my .pro files before running qmake, otherwise I didn't get the message() output. Might be obvious, but I thought I'd mention it incase you run into that.
-
@Pixelgrease, thanks a lot for the detailed answer!
Does it so happen that for your project this
qmake.conf
file is in one of the parent directories relative to the sub-projects? My desired folder hierarchy is like so:.. |--lib1 |--lib2 |--projects |--prj1 |--prj1.pro |--prj2 |--prj2.pro
As you can see, if I want to supply separate configs for
prj1.pro
andprj2.pro
, there doesn't seem to be a way. Both projects uselib1
andlib2
asSUBDIRS
(in reality there's 10+ libs, but otherwise it's like this). -
@Violet-Giraffe My .qmake.conf is in the same folder as the topmost .pro file with a SUBDIRS directive.
I just followed repeated my steps in another project and I got logging output in the QC "General Messages" tab each time I saved a modified .pro file after adding the message() directive from my previous post.
Based on your tree diagram, you have 3 subfolders (
lib1
,lib2
, andprojects
) within the same folder.If that folder has a topmost_project.pro containing
SUBDIRS += lib1 lib2 projects
then that is where the .qmake.conf belongs. The variables declared or modified in that file will be available to every .pro file below them.If instead you put it in the same folder as your projects.pro having
SUBDIRS += prj1 prj2
then the CONFIG change will only be available to them. -
@Violet-Giraffe Your first sentences in the OP says there is a "SUBDIRS project". Where is it?
Are there two? Then put custom
.qmake.conf
files in those folders: every project below them will get the customizations. -
@Pixelgrease
prj1.pro
andprj2.pro
are two separateSUBDIRS
projects. That need different customization. And this per-project customization needs to be applied tolib1
andlib2
as well.lib1
andlib2
should compile differently based on the needs of the parent top-most project. -
@Violet-Giraffe Are the lib projects built by the separate prj* SUBDIRS .pro files? If so, I suspect that even though they are higher in the folder structure than the main .pro project they would get the customizations.
I'm too busy at work to test this... Monday I was working on a similar problem but today I'm on something completely different and don't have time to build test projects.
If it works, you would put your
.qmake.conf
files in each of the prj*.pro folders. You could use aninclude
directive to reference a shared .pri in the projects folder and have only customizations in the.qmake.conf
file.My uncertainty is lack of experience with
.qmake.conf
-- I only learned about it on Monday..qmake.conf
looks like magic. I wish I knew about it 4 years ago when I started my unit tests project. Now I have over 100 unit test project folders across multiple levels of SUBDIRS .pro files that all use the same libraries; I would have used this.Have you tried using
.qmake.conf
? It took me 2 minutes to verify behavior in a completely separate project, but I knew how.qmake.conf
works. Getting it to work the first time can be frustrating. -
@Violet-Giraffe how did you setup your subdirs project ?
It seems you have a "reverse setup" (for lack of a better name) issue meaning that a lower-level project should influence the build of a higher level one.
If I understood correctly it seem that prj1 and prj2 should in fact each define the whole subdirs structure by being "pseudo top level" projects including the higher level folders in their definition. Your top level pro file would then just contain prj1 and prj2. Note that I currently don't know if would be working that way.