2

我有一个结构如下的共享库项目:

图书馆专业版:

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
           ...

接口2.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
{ ... }

所以,我的问题是:qmake 只是忽略了SUBDIRS父项目中的变量操作。但它在子项目中工作正常。我究竟做错了什么?

4

2 回答 2

1
TEMPLATE = subdirs

这一行表示 library.pro 只是其他项目的容器,包含在SUBDIRS变量中列出的子目录中。library.pro 中的大多数其他变量都被忽略,除了CONFIG += ordered,它指定子目录应该按照给定的顺序处理。

包含 IInterface2.h 的子项目都需要QT += concurrent在它们的 .pro 文件中。

于 2014-03-08T21:09:30.290 回答
0

我究竟做错了什么?

您认为 qmake 会解析的事实,但这不是 qmake 当前的工作方式。SUBDIRS 意味着它只会在子文件夹中查找。

于 2014-03-08T14:30:28.663 回答