PDA

View Full Version : QMake Who to force qmake to use absolute paths in generated Makefiles



fightling
10th November 2015, 13:06
I have a QT project with some sub projects like this:


main/
main.pro
sub1/
include/
src/
s1.cpp
sub1.pro
sub2/
sub2.pro

I generate the makefiles with qmake -r from the top. qmake is then generating Makefiles for main.pro, sub1.pro and sub2.pro. Because qmake uses relative paths the paths within the Makefiles of sub1 and sub2 are relatively to the pro files. This causes clang to print relative paths when referring to source code files within error messages:


src/s1.cpp:22:13: error: expected '('

And seen from the project directory src/s1.cpp doesn't exist. At least the path should be sub1/src/s1.cpp.
Another solution would be to force qmake to generate absolute paths in the Makefile but I can't find a way to do that.
Any idea?

fightling
17th November 2015, 21:22
no one with an idea?

jefftee
19th November 2015, 05:04
Not sure I fully understand your problem, or which project / makefile is being processed when you get this error. If you're building the sub1.pro subproject, src/s1.cpp is a correct reference, no?

How about providing the contents of the profiles and the actual build output to start?

fightling
25th November 2015, 10:01
qmake generates a Makefile that includes some directory changes. When it's about to compile a sub project it switches to that directory and then runs all the clang/cc commands to compile. But because this is not happening in the top project's directory, the output relates to the sub projects directory. My IDE/Editor who wants to interpret the error messages cannot find the source file because it overlooks the directory changes. So my solution would be to force qmake to use absolute path within the makefiles it generates. I thought this would be a very common problem :/

zmurf
8th July 2016, 09:24
Im not sure if this is what you are asking for. But if you want qmake to only create absolute path you should put following line into your .pro file

QMAKE_PROJECT_DEPTH = 0 # undocumented qmake flag to force absolute paths in make files
It basically tells qmake that the accepted depth for a relative path is zero. So there will never be any relative paths.

You can find information about this and other undocumented features on QTs wiki page.
https://wiki.qt.io/Undocumented_QMake