Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
699 views
in Technique[技术] by (71.8m points)

qt creator - Qt - Using asterisk (*) in .pro-File with directories

I have a .pro file which looks like:

SOURCES += myfolder/source1.cpp 
           myfolder/source2.cpp
HEADERS  += myfolder/header1.h
            myfolder/header2.h
FORMS    += myfolder/form1.ui
            myfolder/form2.ui

And everything works great. However, if I try to use an asterisk to include all the files, i.e.:

SOURCES  += myfolder/*.cpp
HEADERS  += myfolder/*.h
FORMS    += myfolder/*.ui

qmake throws a file-not-found-error:

WARNING: Failure to find: myfolder*.cpp
[...]
:-1: error: No rule to make target `myfolder/*.cpp', needed by `release/source1.o'.  Stop.

In both cases, Qt-Creator can find the files.

Is there a way to use the asterisk? It's annoying to type the files manually.

Thank you!

[EDIT: Qt 4.8.4, Windows 7, Qt-Creator 2.6.1. Sry for forgetting this thought it isnt needed.]

[EDIT: Found solution: http://qt-project.org/forums/viewthread/1127 . Thank you anyway!]

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In qmake 3.0, at least, it's possible to use something like:

SOURCES = $$files(*.cpp, true)
HEADERS = $$files(*.h, true)

The true argument will cause the files function to recursively find all files matching the pattern given by the first argument.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...