Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qmake: editing global configuration for a SUBDIRS project

Qmake: editing global configuration for a SUBDIRS project

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
15 Posts 4 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    If memory serves well, you can put a .qmake.conf in your project's root folder and it's content should be available in all sub-folders .pro file.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    V 1 Reply Last reply
    1
    • SGaistS SGaist

      Hi,

      If memory serves well, you can put a .qmake.conf in your project's root folder and it's content should be available in all sub-folders .pro file.

      V Offline
      V Offline
      Violet Giraffe
      wrote on last edited by Violet Giraffe
      #3

      @SGaist, hi! do you mean .qmake.cache? I just edited my question to say it doesn't seem to work in a useful way (it does work in principle, it just doesn't do the right thing).

      SGaistS 1 Reply Last reply
      0
      • V Violet Giraffe

        @SGaist, hi! do you mean .qmake.cache? I just edited my question to say it doesn't seem to work in a useful way (it does work in principle, it just doesn't do the right thing).

        SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #4

        No no, it's really .qmake.conf that I was suggesting.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        V 1 Reply Last reply
        0
        • SGaistS SGaist

          No no, it's really .qmake.conf that I was suggesting.

          V Offline
          V Offline
          Violet Giraffe
          wrote on last edited by
          #5

          @SGaist, then I don't understand how to use it, it's not documented for this use case. After renaming .qmake.cache to .qmake.conf it doesn't look like it's picked up at all. cache was picked up.

          SGaistS 1 Reply Last reply
          0
          • V Violet Giraffe

            @SGaist, then I don't understand how to use it, it's not documented for this use case. After renaming .qmake.cache to .qmake.conf it doesn't look like it's picked up at all. cache was picked up.

            SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #6

            Where do you have that file located ?
            What is in it ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            V 1 Reply Last reply
            0
            • SGaistS SGaist

              Where do you have that file located ?
              What is in it ?

              V Offline
              V Offline
              Violet Giraffe
              wrote on last edited by Violet Giraffe
              #7

              @SGaist
              It's located one directory above the SUBREPOS .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!!!)
              
              P 1 Reply Last reply
              0
              • V Violet Giraffe

                @SGaist
                It's located one directory above the SUBREPOS .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!!!)
                
                P Offline
                P Offline
                Pixelgrease
                wrote on last edited by Pixelgrease
                #8

                @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 containing TEMPLATE = 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.

                V 1 Reply Last reply
                1
                • P Pixelgrease

                  @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 containing TEMPLATE = 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.

                  V Offline
                  V Offline
                  Violet Giraffe
                  wrote on last edited by Violet Giraffe
                  #9

                  @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 and prj2.pro, there doesn't seem to be a way. Both projects use lib1 and lib2 as SUBDIRS (in reality there's 10+ libs, but otherwise it's like this).

                  S 1 Reply Last reply
                  0
                  • V Violet Giraffe

                    @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 and prj2.pro, there doesn't seem to be a way. Both projects use lib1 and lib2 as SUBDIRS (in reality there's 10+ libs, but otherwise it's like this).

                    S Offline
                    S Offline
                    stan.m
                    wrote on last edited by
                    #10

                    @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, and projects) 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.

                    V 1 Reply Last reply
                    0
                    • S stan.m

                      @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, and projects) 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.

                      V Offline
                      V Offline
                      Violet Giraffe
                      wrote on last edited by
                      #11

                      @stan-m
                      And that is the problem. prj1.pro is one top-most project. prj2.pro is another one. Both use lib1.pro and lib2.pro, but they require different configuration.

                      P 1 Reply Last reply
                      0
                      • V Violet Giraffe

                        @stan-m
                        And that is the problem. prj1.pro is one top-most project. prj2.pro is another one. Both use lib1.pro and lib2.pro, but they require different configuration.

                        P Offline
                        P Offline
                        Pixelgrease
                        wrote on last edited by
                        #12

                        @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.

                        V 1 Reply Last reply
                        0
                        • P Pixelgrease

                          @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.

                          V Offline
                          V Offline
                          Violet Giraffe
                          wrote on last edited by
                          #13

                          @Pixelgrease
                          prj1.pro and prj2.pro are two separate SUBDIRS projects. That need different customization. And this per-project customization needs to be applied to lib1 and lib2 as well. lib1 and lib2 should compile differently based on the needs of the parent top-most project.

                          P SGaistS 2 Replies Last reply
                          0
                          • V Violet Giraffe

                            @Pixelgrease
                            prj1.pro and prj2.pro are two separate SUBDIRS projects. That need different customization. And this per-project customization needs to be applied to lib1 and lib2 as well. lib1 and lib2 should compile differently based on the needs of the parent top-most project.

                            P Offline
                            P Offline
                            Pixelgrease
                            wrote on last edited by Pixelgrease
                            #14

                            @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 an include 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.

                            1 Reply Last reply
                            0
                            • V Violet Giraffe

                              @Pixelgrease
                              prj1.pro and prj2.pro are two separate SUBDIRS projects. That need different customization. And this per-project customization needs to be applied to lib1 and lib2 as well. lib1 and lib2 should compile differently based on the needs of the parent top-most project.

                              SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #15

                              @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.

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              1 Reply Last reply
                              0

                              • Login

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved