Unsolved QMake -> MSVC project: is there a way to disable the /FC flag?
-
I'm having the same problem that CMake users had until it was fixed, described and explained here: https://gitlab.kitware.com/cmake/cmake/-/issues/18261
In short, the
/FC
flag (use full paths for__FILE__
and similar macros) is the default behavior in MSBuild, so if/FC
is NOT set, a line<UseFullPaths>false</UseFullPaths
MUST be emitted in the generated project. I assume that because of this inverse logic there is no qmake-native solution (e. g. tricks likeQMAKE_CXXFLAGS = $$replace(QMAKE_CXXFLAGS, "/FC ", "")
won't work). But there is a potential workaround:"Create a ProjectName.vcxproj.user file that turns explicitly sets <UseFullPaths> to false. Because MSBuild merges .user project files with project files of the same name, this lets CMake users disable the setting anyway."
Can this be done in qmake? More specifically, can this be done once in a .pri file that's included into every .pro for a SUBDIRS project with many libraries?
-
Hi,
Wouldn't:
QMAKE_CXXFLAGS -= /FC
Do the job ?
-
@SGaist, no, because qmake is not trying to add this flag - it's not present in
QMAKE_CXXFLAGS
. But it also doesn't include the following line into the resulting vcxproj, and by default it'strue
in MSBuild:<ClCompile> <UseFullPaths>false</UseFullPaths> </ClCompile>
So, /FC is on by default and there seems to be no way to turn it off with qmake.
Since posting the question I have implemented the suggested workaround (creating a
.vcxproj.user
file), it can be easily done in qmake, but I still can't get it to work - it would appear that MSBuild ignores any<ClCompile>
options in a .user file. -
Based on the flag documentation I am wondering whether you have also ZI defined which implies FC.
-
@SGaist, I didn't know about this connection, thanks! No, I'm not specifying /Zi in the .pro file, but it is added to the generated project nonetheless. Not sure where it's coming from;
QMAKE_CXXFLAGS -= /Zi
doesn't affect it. I've also printedQMAKE_CXXFLAGS
to make sure it's not there. It must be hard-coded in the vcxproj generator, or in some template file that's part of qmake? -
I have somehow managed to remove
/Zi
from the generated project, but/FC
is still effectively set by virtue ofUseFullPaths
not being specified in the vcxproj. -
Not related to the initial question, but here are more examples of thing you can't get right with
qmake
in a vcxproj:QMAKE_LFLAGS += /LTCG:INCREMENTAL
results in/LTCG
being set (the non-incremental option).QMAKE_LFLAGS += /DEBUG:FULL
results in/DEBUG
being set (without :FULL). It's probably the same thing, but still annoying.
What's the status of
qmake
, is it end of life? I guess these problems won't be fixed if I report them? -
Did you try to quote these expressions ?
As for qmake, it shall be supported for the lifetime of Qt 6 so I would say it's worth opening tickets since there are still quite a lot of projects using it.
-
@SGaist, like so? This, unfortunately, changed nothing. And note that things like /OPT:REF and /DEBUG:FASTLINK do work correctly, while /DEBUG:FULL does not.
Release:QMAKE_LFLAGS += "/DEBUG:FULL" /OPT:REF /OPT:ICF "/LTCG:INCREMENTAL"
In case with DEBUG it's just a nag, but LTCG is a functionality issue of not being able to get the right behavior with qmake.
P. S. Thanks for your help and advice! -
Then it is likely an issue with the backend.
Don't forget to post a link to your ticket(s) !
-
Posted an issue: https://bugreports.qt.io/browse/QTBUG-104450