Results 1 to 12 of 12

Thread: Qt project management - bigger project

  1. #1
    Join Date
    Oct 2009
    Posts
    70
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Qt project management - bigger project

    I am very confused how to manage bigger project in Qt with .pro files. I have got this directory tree:
    Qt Code:
    1. /
    2. /bin - all binary files (.EXE/.DLL)
    3. /lib - all linking libraries (.a/ .lib)
    4. /tmp - temporary
    5. /src - sources
    6. Projects:
    7. /src/Executable/Executable.pro
    8. /src/Library.GUI/Library.GUI.pro
    9. /src/Library.Services/Library.Services.pro
    10. /src/...
    To copy to clipboard, switch view to plain text mode 
    How to link this projects together with Qt .pro/.pri (projects files) ? Is there some tutorial for it?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt project management - bigger project

    It is all in the QMake manual. Look at "TEMPLATE = subdirs" for your PRO files to traverse a tree. Use a single, central PRI file that determines the full path to the bin and lib directories and defines QMAKE variable containing the results, and use those in the LIBS and DESTDIR variables of the component PRO files.

  3. #3
    Join Date
    Oct 2009
    Posts
    70
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Qt project management - bigger project

    Yes, of course, but I am very confused by using this project-type files (better solution is something like Visual Studio Solution and adding project via dialogues, and not via manually typing project ... it's not so practical)

  4. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Qt project management - bigger project

    Before trying to run, you should at least be able to crawl.
    This means that before you use tools like Visual Studio, you should already have basic knowledge of the toolchain and how to build programs with certain toolkits.

    The subdirs template is extremely easy to use.
    But, if you want shiny dialogs and buttons, go for Qt Creator.

  5. #5
    Join Date
    Oct 2009
    Posts
    70
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Qt project management - bigger project

    I don't want shiny dialogs, but Visual Studio has more better project management than Qt Creator, here I must manually set up directories and configuration, but it wasn't my question. But:

    1. If I define something in Project.pro (it is main project file - works as entry for other subprojects) and use this variable in SubProject.pro (not included together, linked via SUBDIRS), it will works?

    I have got 2 projects: Main - just for environment setup and working like entry point, Subproject - some subproject...
    Qt Code:
    1. # Main.pro
    2.  
    3. DESTDIR = bin
    4. DLLDESTDIR = bin
    5. # and so on...
    6.  
    7. TEMPLATE = subdirs
    8. SUBDIR = subproject
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. #subproject.pro
    2. DESTDIR = ../$${DESTDIR}
    To copy to clipboard, switch view to plain text mode 

    2. Will this "project" work ?
    3. Can I put makefile files into other directory ?

  6. #6
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qt project management - bigger project

    If you need setting shared across a project, the easiest approach is to put them all into a project include file (*.pri) and include that file in the project files that need it. What you define in a *.pri file is arbitrary; any legal project file construct is acceptable. This is how shared settings are handled in any make-based environment.

    You can, of course, also use environment variables for similar purposes. If these variables are unset or set incorrectly, however, builds can fail in unpleasant ways.

  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt project management - bigger project

    More like this:
    Qt Code:
    1. # top.pro
    2. include(common.pri)
    3. TEMPLATE = subdirs
    4. CONFIG += ordered
    5. SUBDIRS = sub1
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. # common.pri
    2. # You can use another method to locate the directories, e.g. full paths
    3. MYBINDESTDIR = $$PWD/bin
    4. MYDLLDESTDIR = $$PWD/bin
    5. MYLIBDESTDIR = $$PWD/lib
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. # sub1/sub1.pro
    2. include(../common.pri)
    3. message( Sub1 MYBINDESTDIR is $$MYBINDESTDIR )
    4. message( Sub1 MYDLLDESTDIR is $$MYDLLDESTDIR )
    5. message( Sub1 MYLIBDESTDIR is $$MYLIBDESTDIR )
    6.  
    7. TEMPLATE = app
    8. DESTDIR = $$MYBINDESTDIR
    9.  
    10. # Input
    11. SOURCES += main.cpp
    To copy to clipboard, switch view to plain text mode 
    Last edited by ChrisW67; 21st December 2010 at 23:23.

  8. #8
    Join Date
    Oct 2009
    Posts
    70
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Qt project management - bigger project

    I am not sure, in your second code block: Yes, Okay, I have $$PWD/Bin (in main project - it is okay), but what if it will be subproject? It will not changes it automatically (this PATH) or it will make files into a current subproject directory? For example:
    Qt Code:
    1. #in main project:
    2. PWD = c:/test/project
    3. BINDIR = $${PWD}/bin # also: c:/test/project/bin - that's good
    4.  
    5. #in subproject, it will change or not? (If not, it will be okay, if yes, I can't use them)
    6. PWD = c:/test/project/subproject
    7. BINDIR = c:/test/project/subproject/bin ??
    To copy to clipboard, switch view to plain text mode 
    I think I need use full direct paths (I don't want to play with these commands)....

    Okay previous question was unanswered: How can I change a Makefiles files directory (I don't want have Makefiles at sources)
    Last edited by Peppy; 22nd December 2010 at 16:00. Reason: updated contents

  9. #9
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt project management - bigger project

    I am not sure, in your second code block: Yes, Okay, I have $$PWD/Bin (in main project - it is okay), but what if it will be subproject? It will not changes it automatically (this PATH) or it will make files into a current subproject directory?
    Take 30 seconds and try it for yourself. $$PWD will be the directory containing common.pri, which is the top level directory in my example.
    How can I change a Makefiles files directory (I don't want have Makefiles at sources)
    You want to do a shadow build if you wish to keep the sources and the derived files (Makefiles, *.o, *.a, executables etc.) separate. If you are using Qt Creator there's a simple option to do this for you. Otherwise, create a build directory in parallel with your top level project directory and run the qmake there:
    Qt Code:
    1. $ ls -d
    2. myproject
    3. $ mkdir build
    4. $ cd build
    5. $ qmake ../myproject/myproject.pro
    6. $ make
    To copy to clipboard, switch view to plain text mode 
    This will affect the $$PWD expansion so you may wish to hard code the paths in common.pri.

    If someone else has an elegant solution to identify the top of the shadow build location so that outputs can be placed there then I'm all ears.

  10. #10
    Join Date
    Oct 2009
    Posts
    70
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Qt project management - bigger project

    Yes, I think a shadow build will be the best sollution, but if I have more subprojects, which has shadow builds too, it won't be much chaotic? Should I forbid a shadow builds in subprojects? How to organize it (to decrease a mess of directories, and count of directories [make shared binary, temporary, library, makefile and source directories and forbid for everyone subproject new shadow builds directories]) ?
    Last edited by Peppy; 23rd December 2010 at 21:43.

  11. #11
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt project management - bigger project

    If you have a structure:
    Qt Code:
    1. myproject/
    2. myproject.pro # includes the sub projects using subdirs template
    3. ...
    4. subproj1/
    5. subproj1.pro # maybe a library template
    6. ... # source files
    7. subproj2/
    8. subproj2.pro # maybe another lib
    9. ...
    10. subproj3/
    11. subproj3.pro # this one is an app template
    12. ...
    13. subproj4/
    14. subproj4.pro # this one is another set of sub-projects
    15. ...
    16. subproj4a/
    17. subproj4a.pro # another lib
    18. ...
    19. subpro4b/
    20. subproj4b.pro # another app
    21. ...
    To copy to clipboard, switch view to plain text mode 
    and so on then when you shadow build you get:
    Qt Code:
    1. myproject_shadow_build_dir/
    2. Makefile
    3. ... # output files
    4. subproj1/
    5. Makefile
    6. ... # output files
    7. subproj2/
    8. Makefile
    9. ... # output files
    10. subproj3/
    11. Makefile
    12. ... # output files
    13. subproj4/
    14. Makefile
    15. ... # output files
    16. subproj4a/
    17. Makefile
    18. ... # output files
    19. subproj4b/
    20. Makefile
    21. ... # output files
    To copy to clipboard, switch view to plain text mode 
    in your build directory (If you don't fiddle with DESTDIR etc). One project structure, one shadow build structure.

  12. #12
    Join Date
    Oct 2009
    Posts
    70
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Qt project management - bigger project

    Okay, I'll try something

Similar Threads

  1. help for my project
    By valgaba in forum Qt-based Software
    Replies: 3
    Last Post: 16th July 2010, 22:18
  2. cannot run the project
    By kazal in forum Qwt
    Replies: 0
    Last Post: 24th May 2010, 09:18
  3. Replies: 1
    Last Post: 4th December 2009, 00:34
  4. Project generation on linux from QT Project
    By darpan in forum Qt Programming
    Replies: 6
    Last Post: 11th December 2006, 10:43
  5. [DevQt] Team & project management
    By Cesar in forum Qt-based Software
    Replies: 15
    Last Post: 21st February 2006, 13:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.