Reputation: 815
My Qt project structure is similar to this:
Directory Structure:
|
|--- dir
| |
| | - a.c
| | - a.h
| | - test.pro
|--- dir1
| | - b.c
| | - b.h
test.pro
SOURCES += a.c \
../dir1/*.c
HEADERS += a.h \
../dir1/*.h
When I try to build the project I get the error:
:-1: error: No rule to make target `../dir1/*.c'
Is there anyway to include source files which are outside the .pro file?
And also have them show in the Projects pane on the left in Qt Creator?
Upvotes: 1
Views: 671
Reputation: 6776
Wildcards in qmake (.pro file) work only for files in current project directory. For subfolders it does not work. So the proper solution is to add each file separately.
The issue was raised on the Qt bug tracker QTCREATORBUG-8925. The ticked is closed as a new feature request or due to multiple problems:
Using wildcards in .pro files creates multiple problems, e.g. adding a additional file won't automatically compile it. Nor would deleting a file automatically remove it from the Makefile
However, there is undocumented function listed on the wiki Undocumented_QMake
files(glob) — Returns a list of files which match the specified glob pattern.
So, if the above problems of using globbing patterns are acceptable it can be used as
SOURCES += $$files(../dir1/*.c)
Upvotes: 2