So I have the following setup (simplified version):
application/app1.hpp
application/app1.cpp
application/utils/utils1.hpp
application/utils/utils1.cpp
So when I compile app1.cpp I do so like this (this is a cut-down version of the compile):
g++ -Wall -Wextra -Werror -I application -isystem application/utils -MMD -MP -MF dep.d -c application/app1.cpp -o obj.o
Where I use -MDD to auto generate dependency information. I use -isystem to inhibit warnings from files in utils folder.
Note: that utils
is a sub-module (ie a seperate project that compiles on its own). Therefore I don't want compile warnings/errors from that project. Therefore I am using -isystem application/utils
to include folders. When you use isystem you don't get gcc warnings - which is great :)
However I just discovered that this is also the reason I am not getting complete depenecy outputs. Files included in the isystem
directories are not added as dependecies in the gcc generated dep.d file.
So it seems I can either ignore the warnings from utils but not get depenency generation for it OR I can get the dependency output but not ignore the warnings.
I really want both:
Is that possible to get both behaviours somehow?
Some ideas of mine:
-include
but not folders and I don't have a list of files :( I just found something that could work, but I am not sure how efficient it is. I found the -E gcc option which replaces -c (compile) with preprocess only). So I could do:
Generate the dependency info:
g++ -I application -I application/utils -E application/app1.cpp -o /dev/null -MMD -MP -MF dep.d
Compile the file with minimal warnings:
g++ -Wall -Wextra -Werror -I application -isystem application/utils -c application/app1.cpp -o obj.o
This will mean that the preprocessor runs twice - not sure how much work that is... but it seems to run pretty quickly compared to the compile phase.
If there is further ideas I am still very much open to them... I won't mark this answer for a while incase someone has a better idea...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.