Results 1 to 2 of 2

Thread: SUBDIR qmake structure

  1. #1
    Join Date
    Sep 2010
    Location
    Norway
    Posts
    12
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default SUBDIR qmake structure

    I want to organize my project in the following order:

    projectname\
    projectname.pro
    common.pri

    projectname\gui\
    gui.pro
    mainwindow.cpp
    mainwindow.h
    mainwindow.ui

    projectname\aname\
    aname.pro
    h and cpp files only

    projectname\test\
    test.pro
    main.cpp

    projectname.pro:
    Qt Code:
    1. TEMPLATE = subdirs
    2. SUBDIRS = gui \
    3. aname
    4. QT += core gui
    5. # main app
    6. CONFIG += ordered
    7. SUBDIRS += test
    To copy to clipboard, switch view to plain text mode 

    common.pri:
    Qt Code:
    1. INCLUDEPATH += gui \
    2. aname
    3. WARNINGS += -Wall
    4. # The following keeps the generated files at least somewhat separate
    5. # from the source files.
    6. UI_DIR = uics
    7. MOC_DIR = mocs
    8. OBJECTS_DIR = objs
    To copy to clipboard, switch view to plain text mode 

    gui.pro:
    Qt Code:
    1. ! include( ../common.pri ) {
    2. error( Couldn't find the common.pri file! )
    3. }
    4. QT += core gui
    5. FORMS += \
    6. mainwindow.ui
    7. SOURCES += \
    8. mainwindow.cpp
    9. HEADERS += \
    10. mainwindow.h \
    11. OBJECTS_DIR += projectname\gui\mainwindow.h
    12. QMAKE_EXT_OBJ += projectname\gui\mainwindow.h
    13. LIBS += -L../aname -laname
    To copy to clipboard, switch view to plain text mode 


    aname.pro:
    Qt Code:
    1. ! include( ../common.pri ) {
    2. error( Couldn't find the common.pri file! )
    3. }
    4. QT += core gui
    5. SOURCES += \
    6. ...cpp
    7.  
    8. HEADERS += \
    9. ....h
    10.  
    11. OBJECTS_DIR += projectname/aname/....h \
    12.  
    13. QMAKE_EXT_OBJ = projectname/aname/....h \
    14. test.pro
    15. ! include( ../common.pri ) {
    16. error( Couldn't find the common.pri file! )
    17. }
    18. QT += core gui
    19. TARGET = test
    20. TEMPLATE = app
    21. SOURCES += \
    22. main.cpp \
    23. LIBS += -L../gui -lgui
    To copy to clipboard, switch view to plain text mode 

    I want my header and source located in the same folder, but I want the #include to be <projectname/amame/...h>. I have tried the OBJECTS_DIR and QMAKE_EXT_OBJ but it don't seem to find the header files. It can't find the header in #include <...h> current folder ether. The qtcreator auto completion seems to be a bit smarter since it finds the headers... hehe.
    Can anyone see what I'm doing wrong and how I can get the #include <projectname/aname/..>

  2. #2
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: SUBDIR qmake structure

    Objects have nothing to do with includes. If you want to be able to include headers as <p1/p2/p3/file> then add a corresponnding path to INCLUDEPATH variable. Set it to "." in common.pri file.

    By the way, I think that prefixing your include with project's name is not a good idea.
    I'm a rebel in the S.D.G.

Similar Threads

  1. MSVC Project generated using qmake - turn off flat structure
    By Piskvorkar in forum Qt Programming
    Replies: 3
    Last Post: 4th February 2013, 23:25
  2. c structure & Qfile
    By eva2002 in forum Qt Programming
    Replies: 15
    Last Post: 25th January 2010, 08:37
  3. Treeview Structure
    By bismitapadhy in forum Qt Programming
    Replies: 2
    Last Post: 3rd June 2009, 13:44
  4. .pro settings for obj subdir
    By bajarangi in forum Newbie
    Replies: 2
    Last Post: 17th April 2009, 14:31
  5. Data Structure help!
    By darshan in forum Newbie
    Replies: 8
    Last Post: 18th February 2009, 12:47

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.