Changing compiler flags for a single unit
-
Using
qmakefiles and building with GCC 13.3.0 + Qt 6.5 or later and std:c++17, how can I change the optimization flags in a release build for a single .cpp file in my project from-O2to-O3?Is there a "Qt way", or do i have to manually edit the makefile before building?
-
I think you will get better input if you explain your reasoning as to why you want that.
Also, if the cpp file in question is not Q_OBJECT/MOC dependent then you could compile it separately (thru build or manually) and just add it as a link time object. There are project file vars for adding external stuff at linktime. -
I think you will get better input if you explain your reasoning as to why you want that.
Also, if the cpp file in question is not Q_OBJECT/MOC dependent then you could compile it separately (thru build or manually) and just add it as a link time object. There are project file vars for adding external stuff at linktime.@Kent-Dorfman said in Changing compiler flags for a single unit:
I think you will get better input if you explain your reasoning as to why you want that.
Actually, in the meantime I am leaning towards just compiling everything with
-O3as it is much simpler to set up.Also, if the cpp file in question is not Q_OBJECT/MOC dependent then you could compile it separately (thru build or manually) and just add it as a link time object. There are project file vars for adding external stuff at linktime.
Unfortunately, it does inherit from
QObject-- this runs in a background thread, does a lot of heavy lifting (which is why it needs to be as fast as possible) but it does need to communicate with its controller which runds in the main thread.If we assume that I know what I am doing, how could it be done? It's actually fairly common in the real world to mix compilation units having different optimization settings. I just don't know how to do this with
qmake.(EDIT: Most of the caveats involve floating-point calculations, especially when it involves compiling with
-Ofaston GCC -- that's not an issue here). -
@Kent-Dorfman said in Changing compiler flags for a single unit:
I think you will get better input if you explain your reasoning as to why you want that.
Actually, in the meantime I am leaning towards just compiling everything with
-O3as it is much simpler to set up.Also, if the cpp file in question is not Q_OBJECT/MOC dependent then you could compile it separately (thru build or manually) and just add it as a link time object. There are project file vars for adding external stuff at linktime.
Unfortunately, it does inherit from
QObject-- this runs in a background thread, does a lot of heavy lifting (which is why it needs to be as fast as possible) but it does need to communicate with its controller which runds in the main thread.If we assume that I know what I am doing, how could it be done? It's actually fairly common in the real world to mix compilation units having different optimization settings. I just don't know how to do this with
qmake.(EDIT: Most of the caveats involve floating-point calculations, especially when it involves compiling with
-Ofaston GCC -- that's not an issue here).I think you should be able to do what you want using a "custom compiler".
-
I think you should be able to do what you want using a "custom compiler".
@SGaist Thank you ... this is exactly what I was looking for!
-
R Robert Hairgrove has marked this topic as solved