Qmake: editing global configuration for a SUBDIRS project
-
@SGaist, then I don't understand how to use it, it's not documented for this use case. After renaming
.qmake.cacheto.qmake.confit doesn't look like it's picked up at all.cachewas picked up.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!!!) -
@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.confadds a value to CONFIG that propagates to all subfolder projects.I have a root SUBDIRS project. In that project folder, I have a
.qmake.conffile containing:CONFIG += my_velociraptorI 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.proEach .pro file confirms the presence of the CONFIG value I added in the
.qmake.conffile 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.
-
@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.confadds a value to CONFIG that propagates to all subfolder projects.I have a root SUBDIRS project. In that project folder, I have a
.qmake.conffile containing:CONFIG += my_velociraptorI 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.proEach .pro file confirms the presence of the CONFIG value I added in the
.qmake.conffile 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.conffile 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.proAs you can see, if I want to supply separate configs for
prj1.proandprj2.pro, there doesn't seem to be a way. Both projects uselib1andlib2asSUBDIRS(in reality there's 10+ libs, but otherwise it's like this). -
@Pixelgrease, thanks a lot for the detailed answer!
Does it so happen that for your project this
qmake.conffile 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.proAs you can see, if I want to supply separate configs for
prj1.proandprj2.pro, there doesn't seem to be a way. Both projects uselib1andlib2asSUBDIRS(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 projectsthen 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 prj2then the CONFIG change will only be available to them. -
@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 projectsthen 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 prj2then the CONFIG change will only be available to them.@stan-m
And that is the problem.prj1.prois one top-most project.prj2.prois another one. Both uselib1.proandlib2.pro, but they require different configuration. -
@stan-m
And that is the problem.prj1.prois one top-most project.prj2.prois another one. Both uselib1.proandlib2.pro, but they require different configuration.@Violet-Giraffe Your first sentences in the OP says there is a "SUBDIRS project". Where is it?
Are there two? Then put custom
.qmake.conffiles in those folders: every project below them will get the customizations. -
@Violet-Giraffe Your first sentences in the OP says there is a "SUBDIRS project". Where is it?
Are there two? Then put custom
.qmake.conffiles in those folders: every project below them will get the customizations.@Pixelgrease
prj1.proandprj2.proare two separateSUBDIRSprojects. That need different customization. And this per-project customization needs to be applied tolib1andlib2as well.lib1andlib2should compile differently based on the needs of the parent top-most project. -
@Pixelgrease
prj1.proandprj2.proare two separateSUBDIRSprojects. That need different customization. And this per-project customization needs to be applied tolib1andlib2as well.lib1andlib2should 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.conffiles in each of the prj*.pro folders. You could use anincludedirective to reference a shared .pri in the projects folder and have only customizations in the.qmake.conffile.My uncertainty is lack of experience with
.qmake.conf-- I only learned about it on Monday..qmake.conflooks 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.confworks. Getting it to work the first time can be frustrating. -
@Pixelgrease
prj1.proandprj2.proare two separateSUBDIRSprojects. That need different customization. And this per-project customization needs to be applied tolib1andlib2as well.lib1andlib2should compile differently based on the needs of the parent top-most project.@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.