qmake -project: add new file extensions
I'm using QTCreator as a code editor for my C++ project, not using the real features of the qmake compilation process.
My project has several subdirectories, in all of which I ran qmake -project
to create a duummy .pro file that simply lists the source and header files in the directory.
In my root folder, I simply created a "main.pro" file that includes all these "subdir/subdir.pro" files.
So it looks like this:
./开发者_StackOverflow中文版
main.pro
subdir1/
/include
/src
subdir1.pro
subdir2/
/include
/src
subdir2.pro
Now my problem is, I use some files that have a special file extension (say, .ccp
), which are actually some C code but are used in a different step of my compilation process.
They are naturally ignored by the qmake -project
command and do not appear in my project.
I read here that I could use the qmake setting QMAKE_EXT_CPP
to tell it to gather my files as a C-code file, but it doesn't seem to be working.
If I run qmake -query QMAKE_EXT_CPP
, I get .cpp::.c::.ccp
(which I set right before), but when running a new qmake, it doesn't take my .ccp
files in account.
So, three questions:
- Is it possible to make qmake take some special extensions as a C++ file, when building the
.pro
file? - If yes, is it correct to use the QMAKE_EXT_CPP setting?
- If yes, what should be the syntax of the QMAKE_EXT_CPP setting? (mine inspired by this forum post, but it might be bogus).
You cannot change QMAKE_EXT_CPP with -project option. The list of cpp extensions used at this stage is hardcoded into qmake. However after initial creation of .pro file you can edit it to extend with support for other extensions:
in test.pro
QMAKE_EXT_CPP += .ccp
SOURCES += test.ccp
You have to add new files manually.
精彩评论