Include a .pro file in Qt?

后端 未结 1 757
名媛妹妹
名媛妹妹 2021-01-29 04:02

I have a project which has lots of includepaths, source and header files. The project is run as a standalone application (it\'s not a library).

I would like to implement

相关标签:
1条回答
  • 2021-01-29 04:28

    You should perform two modifications:

    1. Separate out all header files and build-specific settings into a *.pri file. This is what you need instead of including a *.pro.
    2. Move all business logic into a library in order to be able to test it in a separate project.

    E.g., you will have build.pri:

    # build.pri
    TOPDIR = $$PWD
    INCLUDEPATH += . \
                   $$TOPDIR/include
    
    DEPENDPATH += $$TOPDIR
    
    INCLUDEPATH += $$TOPDIR/additional/libararies
    
    HEADERS += all.h \
               your.h \
               headers.h \
               of.h \
               interest.h
    
    QT      += xml
    # etc., etc.
    

    and core.pro

    # core.pro
    TEMPLATE = lib
    
    CONFIG  += dll thread create_prl
    QT      += network xml xmlpatterns sql
    
    include(../build.pri)
    
    HEADERS  += \
                headers.h
    
    SOURCES  += sources.cpp \
                many_of_them.cpp
    
    TARGET     = core
    # etc., etc.
    

    (note the include(../build.pri)), and then make your main project app.pro as a subdirs project with core and gui as components of application, and test.pro with obligative core and as many tests as you want.

    0 讨论(0)
提交回复
热议问题