I'm trying to separate my application from a small open lib I created, so I put the files in .pri
and include in .pro
, the folder structure looks like this:
c:/projetos/
├── minhalib
│ ├── minhalib.pri
│ ├── foo
│ | ├── foo.cpp
│ | └── foo.h
│ └── bar
│ ├── bar.cpp
│ └── bar.h
|
└── aplicativo
├── aplicativo.pro
├── main.cpp
├── mainwindow.cpp
└── mainwindow.h
In the .pro application I have this:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = aplicacao
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
include($PWD/../../minhalib/minhalib.pri)
And in minhalib/foo.pri
I have this:
SOURCES += $$PWD/foo/foo.cpp \
$$PWD/bar/bar.cpp
HEADERS += $$PWD/foo/foo.h \
$$PWD/bar/bar.h
No main.cpp
I called it like this:
#include "mainwindow.h"
#include "../minhalib/bar/bar.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Bar bar;
bar.test();
MainWindow w;
w.show();
return a.exec();
}
Note that I include #include "../minhalib/bar/bar.h"
, but I would like to include more simply something like:
#include <bar/bar>
#include <foo/foo>
Or:
#include "bar/bar.h"
#include "foo/foo.h"
How can I do this by setting in .pri