2

I have the shared library project with structure like this:

library.pro:

TEMPLATE = subdirs
CONFIG  += ordered
SUBDIRS += libs plugins test_programs
...
QT += concurrent
...
# Those files contains pure interfaces (C++ abstract classes)
# with no implementation, and some helper classes with inline implementation.
# So there is no reason to create yet another subproject for them
HEADERS += iface/IInterface1.h \   
           iface/IInterface2.h \ # IInterface2 needs QtConcurrent
           ...

IInterface2.h:

...
#include <QtConcurrent> // ERROR HERE: file not found, i.e. qmake ignores
                        // "QT += concurrent" statement in library.pro

class MyHelperExc : public QtConcurrent::Exception
{ ... }

class IInterface2: public virtual IBaseInterface
{ ... }

So, my problem is: qmake just ignores variable operations in SUBDIRS parent project. But it works ok in subprojects. What am i doing wrong?

László Papp
  • 51,870
  • 39
  • 111
  • 135
eraxillan
  • 1,552
  • 1
  • 19
  • 40
  • @dtech, have you ever worked around this issue? I'd love the ability to do what eraxillan is suggesting. I'm incorporating [QuaZip](https://github.com/stachenov/quazip) into my project, but I'm hitting build issues like [this one](https://stackoverflow.com/questions/15648669/how-to-build-quazip-0-5-1-on-windows-7) that means I have to modify the quazip.pro files to link against zlibwapi.dll during build. Thus, I have to maintain a separate quazip git repo, which is a real bummer. – Ross Rogers Oct 18 '18 at 16:39

2 Answers2

1
TEMPLATE = subdirs

This line says that library.pro is just a container for other projects, contained within the subdirectories listed in the SUBDIRS variable. Most other variables in library.pro are ignored, except CONFIG += ordered, which specifies that the subdirectories should be processed in the order in which they are given.

The subprojects which include IInterface2.h all need to have QT += concurrent in their .pro files.

Oktalist
  • 14,336
  • 3
  • 43
  • 63
0

What am i doing wrong?

The fact that you think qmake would parse, however that is not how qmake is currently working. SUBDIRS will mean that it will only look in subfolders.

László Papp
  • 51,870
  • 39
  • 111
  • 135
  • So, in library.pro `qmake` process only `SUBDIRS` variable and don't care about all others? – eraxillan Mar 08 '14 at 14:39
  • @Axilles: that is not fair, but sources and headers will be ignored at that stage. – László Papp Mar 08 '14 at 14:39
  • But if headers/sources in library.pro will be ignored, at what stage compiler process them and produces an error? I'm just trying to understand where to place `QT += concurrent` statement ;( – eraxillan Mar 08 '14 at 14:45
  • @Axilles: the problem is not with that statement, but your HEADERS in library.pro. The best would be if you could upload a tarball with a sample project, reproducing the issue, and I could provide a concrete recommendation. – László Papp Mar 08 '14 at 14:46
  • Ok, i made it: http://yadi.sk/d/BBhA24glKARVT This is a minimalistic subdirs project where my problem reproduces. – eraxillan Mar 08 '14 at 15:22
  • Thanks, so I suggest to create iface.pro and and the iface to the subdirs. SUBDIRS are not meant to be fixed with SOURCES and HEADERS. – László Papp Mar 08 '14 at 15:33
  • So i'm forced to create additional subproject for iface. Ok. Thank you for your time that was wasted... However, in my opinion this solution does not follows Unix "KISS" principle ;( And my programmer soul is sad. – eraxillan Mar 08 '14 at 15:45
  • @Axilles: you do not necessarily need to create a new subproject (or .pri include project file). You can also just include it from elsewhere where that variable will take effect. – László Papp Mar 08 '14 at 15:46
  • So i need empty subproject with QT += concurrent. Now it's clear to me :) – eraxillan Mar 08 '14 at 16:11
  • @Axilles: I meant that you could use use INCLUDEPATH=wherever/the/header/is from the .pro file some file(s) of which will include your interface header. – László Papp Mar 08 '14 at 16:12
  • @Axilles: interesting that you withdrew the answer in favor of another, which basically writes the same as I wrote to you. :) Perhaps, I was not as clear as the other answer in my comments. – László Papp Mar 09 '14 at 07:53
  • The other man write the main thought of your comments in the answer, in the clear way. Nothing personal :D – eraxillan Mar 09 '14 at 11:46
  • @Axilles: ok, I wished to update the answer though, but good that you got what you have wished. I gave a +1 on the question either way. Good luck. – László Papp Mar 09 '14 at 12:32
  • Yep, i'm very need of some luck :D With such complicated things like Qt and C++ this is necessary... Hope you will continue help to Qt ungrateful funs like me ;) – eraxillan Mar 09 '14 at 14:16