Managing a project using only headers in Qt

Now I have a project that uses a template, therefore, only for the title, library and creates two applications.

The organization of my folder is as follows:

base/lib
base/app1
base/app2

What I'm doing now is what I have base/lib/lib.pri, which looks like this:

HEADERS += ../lib/someHeader.h

And I turn it on base/app1/app1.proand base/app2/app2.pro.

However, in QtCreator it looks a little ugly for two reasons:

  • The path in the file .pridepends on where it is included. For example, if I had another application that for some reason I wanted to be in a folder anotherBase/app3/, this would not work.
  • In the project tree, it looks like this:

(it looks like I should put text after the list in order to have nice code)

app1
  -> app1.pro
  -> headers
  -> source files
  -> lib/
       -> lib.pri
       -> headers
           -> someHeader.h
app2
  -> app2.pro
  -> headers
  -> source files
  -> lib/
       -> lib.pri
       -> headers
           -> someHeader.h

, .

? :

app1
  -> app1.pro
  -> headers
  -> source files
app2
  -> app2.pro
  -> headers
  -> source files
lib
  -> lib.pri
  -> headers

, , .pro - lib , , , , lib ...

!

+4
2

.pri $$PWD. , include.

, PWD , _PRO_FILE_PWD_, .

+3

, . , . .pro TEMPLATE = subdirs , SUBDIRS . .pro . :

TEMPLATE = subdirs
HEADERS += h1.h \
           h2.h

qmake , .pro "", qt , , . .

+1

Source: https://habr.com/ru/post/1527299/


All Articles