It seems you are trying to change the value of the optimization level with qmake here is wrong:
QMAKE_CXXFLAGS += -O3
The problem with this line is that g ++ will use -O2 for the compilation phase and -O1 for the default binding phase. It seems you only want to change the compiler phase, since you will not specify linker flags. However, += means adding with qmake, not overriding. The right way to achieve your original goal would be:
QMAKE_CXXFLAGS_RELEASE -= -O2 QMAKE_CXXFLAGS_RELEASE += -O3
and the following line to override the linker stage:
QMAKE_LFLAGS_RELEASE -= -O1
You will naturally need to repeat qmake after this change. Now -O3 means that it will be optimized for performance, not space. Therefore, because of this, your previous concern about space may arise. The second part is still in doubt, however, without specific details.
The default optimization level for cmake is different from qmake; it's -O3 . You can easily verify this by running the following short cmake snippet:
message("CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}")
You need to sync them to queue them. For example, if you want to use -O2 everywhere, overriding cmake, you also need to apply the following:
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
If you want to use -O3 , see the above logic to change this in the qmake project file. If you want to use something like -Os , you will need to apply both types of changes. I think this is pretty much about it.
As for debugging, you can fully optimize the work in both cases to have a more pleasant debugging work, however!
In general, you need to decide on a performance and gap characterization. You seem to be complaining about both, but you will not inherently receive perfectionism in both. If you want to fully optimize the space, use -Os , if for performance, use -O3 , if you want to compromise the solution, use something in between, etc.