AECSoft

专注于AEC行业软件开发15年

导航

QtCreator的项目组织真心强大

假如说你的代码组织结构是这样的:

project_dir/
-project.pro
-common.pri
-logic/
----logic.pro
----some logic files
-gui/
----gui.pro
----gui files
-main/
----main.pro
----main.cpp

project.pro:

TEMPLATE = subdirs
SUBDIRS = logic \
          gui

# build must be last:
CONFIG += ordered
SUBDIRS += build

common.pri:

#Includes common configuration for all subdirectory .pro files.
INCLUDEPATH += . ..
WARNINGS += -Wall

# The following keeps the generated files at least somewhat separate 
# from the source files.
UI_DIR = uics
MOC_DIR = mocs
OBJECTS_DIR = objs

logic/logic.pro:

! include( ../common.pri ) {
    error( Couldn't find the common.pri file! )
}
TEMPLATE
= lib
TARGET = logic

HEADERS
+= logic.h SOURCES += logic.cpp

gui/gui.pro:

! include( ../common.pri ) {
    error( Couldn't find the common.pri file! )
}

TEMPLATE = lib
TARGET = gui

FORMS += gui.ui
HEADERS += gui.h
SOURCES += gui.cpp

main/main.pro:

! include( ../common.pri ) { error( Couldn't find the common.pri file! ) }

TEMPLATE = app TARGET = main SOURCES += main.cpp #使用add library自动生成 win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../gui/release/ -lgui else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../gui/debug/ -lgui INCLUDEPATH += $$PWD/../gui DEPENDPATH += $$PWD/../gui

 

posted on 2013-03-30 17:58  zuoc  阅读(568)  评论(0编辑  收藏  举报