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. QT Creator "subdirs" project
Forum Updated to NodeBB v4.3 + New Features

QT Creator "subdirs" project

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
14 Posts 6 Posters 11.2k Views 2 Watching
  • 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.
  • T t3685

    @mindgames

    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.

    https://wiki.qt.io/Including_.pro_Files

    M Offline
    M Offline
    mindgames
    wrote on last edited by
    #5

    @t3685 This seems like a more attractive option, I'll look into it.. thanks!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #6

      Hi,

      Do you mean move all your files to the subproject folder used to build your library ?

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

      M 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Do you mean move all your files to the subproject folder used to build your library ?

        M Offline
        M Offline
        mindgames
        wrote on last edited by
        #7

        @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 from StanfordCPPLib and hit "Build". However, this way allows only having one file containing main() in the src 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 own main() 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.)

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #8

          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 and LIBS to set things up for the projects using that library. Doing so will avoid duplication in your apps .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

          1 Reply Last reply
          2
          • S Offline
            S Offline
            sujith D
            wrote on last edited by
            #9

            @SGaist Is there an automatic way to generate a .pri file
            from .pro of an existing project?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #10

              Hi,

              Not my knowledge.

              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
              • RaadR Offline
                RaadR Offline
                Raad
                wrote on last edited by
                #11

                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 += \
                    ...
                
                SGaistS 1 Reply Last reply
                0
                • RaadR Raad

                  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 += \
                      ...
                  
                  SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #12

                  @Raad Please avoid ordered and specify the dependencies directly.

                  See this very good blog post.

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

                  RaadR 1 Reply Last reply
                  4
                  • SGaistS SGaist

                    @Raad Please avoid ordered and specify the dependencies directly.

                    See this very good blog post.

                    RaadR Offline
                    RaadR Offline
                    Raad
                    wrote on last edited by
                    #13

                    @SGaist Thank you so much for pointing that out! I was not aware of this issue.

                    SGaistS 1 Reply Last reply
                    1
                    • RaadR Raad

                      @SGaist Thank you so much for pointing that out! I was not aware of this issue.

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

                      @Raad A documentation update is in the works that will explain that.

                      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
                      2

                      • Login

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