One way to arrange it:
projects
project_1
project_1.pro // see below
file_a.cpp
file_a.h
shared
shared.pri // see below
file_b.cpp
file_b.h
project_2
project_2.pro // see below
file_c.cpp
file_c.h
projects
project_1
project_1.pro // see below
file_a.cpp
file_a.h
shared
shared.pri // see below
file_b.cpp
file_b.h
project_2
project_2.pro // see below
file_c.cpp
file_c.h
To copy to clipboard, switch view to plain text mode
In the project files:
TEMPLATE = app
...
include(../shared/shared.pri)
TEMPLATE = app
...
include(../shared/shared.pri)
To copy to clipboard, switch view to plain text mode
and in shared.pri
INCLUDEPATH += $${PWD}
DEPENDPATH += $${PWD}
HEADERS += $${PWD}/file_b.h
SOURCES += $${PWD}/file_b.cpp
INCLUDEPATH += $${PWD}
DEPENDPATH += $${PWD}
HEADERS += $${PWD}/file_b.h
SOURCES += $${PWD}/file_b.cpp
To copy to clipboard, switch view to plain text mode
Then when you add or remove files from shared the other projects automatically get them. file_a.cpp can directly #include "file_b.h" without worrying about relative paths etc.
Alternatively, you could make "shared" a static library project and use:
LIBS += -L../shared -lshared
LIBS += -L../shared -lshared
To copy to clipboard, switch view to plain text mode
in projects a and b.
Lots of variations on the theme.
Bookmarks