QMake: How do I change a compiler option which is already given a value by the framework
-
I would like to add the compiler option -mmacosx-version-min=10.6. I have tried setting
@QMAKE_CXXFLAGS += -mmacosx-version-min=10.6@
in my .pro file. The problem is that this option is also given a value by the mkspecs config files - common/g++-macx.conf sets it to -mmacosx-version-min=10.5. The result is that the compiler command line will contain both my setting and the mkspecs setting. The mkspecs settings appears last and will get effect. How can I tell the compiler to use "-mmacosx-version-min=10.6"?
-
Tweak the mkspec, or create a new one by copying the original, changing the min version and name.
-
Tweaking mkspec is what I am currently doing to work around the problem. It is not a good solution for me because mkspecs is obviously outside the source code repository so every developer must do it manually.
-
You can copy the mkspec into your repo, but I do agree it's not a clean or nice solution. There is a Qt configure flag that allows for SDK selection, but I don't think there is one in qmake.
This is what I've found. Does not seem to be exactly it, but maybe will work: "link":http://qt-project.org/doc/qt-4.8/qmake-variable-reference.html#qmake-mac-sdk.
-
There is also the "-after" flag: "link":http://qt-project.org/doc/qt-4.8/qmake-running.html#makefile-mode-options.
-
Thank you for all the suggestions :-) - unfortunately none of them seems to do the trick. Except possibly the option of including mkspec in the repo. Can I tell Qt to look in an alternative place (the repo) for the mkspec?
-
Yes, qmake -spec accepts absolute paths. I have not tried relative ones, but it's worth a try.
-
Ok, this would be a workable solution. Thanks. Still a bit frustrating that there is no way to simply override the option.
-
@
QMAKE_CXXFLAGS -= -mmacosx-version-min=10.5
QMAKE_CXXFLAGS += -mmacosx-version-min=10.6
@ -
doesn't work
-
What Qt version are you using?
@cat test.pro
message($$QMAKE_CXXFLAGS)
QMAKE_CXXFLAGS -= -mmacosx-version-min=10.6
message($$QMAKE_CXXFLAGS)qmake -spec macx-g++
Project MESSAGE: -pipe -mmacosx-version-min=10.6
Project MESSAGE: -pipe
@ -
I'm using qt 4.8.3. If I run your test.pro I get:
Project MESSAGE: -pipe
Project MESSAGE: -pipeThe reason seems to be that the flags are added after the pro file is processed. (Which is also why manipulating QMAKE_CXXFLAGS doesn't work.)
It is interesting that you have a different (and much more desireable) behaviour. What Qt version are you running?
-
I'm using Qt 5. Unfortunately I have no access to a Mac right now to test.
In a next step you could <code>qmake -d</code> to see where the flag actually comes from; it should have been already set when processing the <code>.pro</code> file (and thus beeing removable).
-
Ok, qmake -d shows that tge macx-g++ spec sets it to QMAKE_CXXFLAGS_X86_64. Changing this variable in the pro file actually works. I cannot get rid of the -mmacosx-version-min=10.5 from the spec, but now my setting -mmacosx-version-min=10.6 appears last and gets effect.
Thanks.
-
The proper way should is to overwrite the QMAKE_MACOSX_DEPLOYMENT_TARGET flags, for example:
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7
and then it will change the mmacosx-version-min to 10.7