With that change, a build system like conan allows the user to pass individual optimization flags if needed without overriding those.
I'm not sure if it is good practice to do that, but in a project of mine I used the following snippet before I changed fully to conan where the conan profile/settings define the cmake build type. Maybe to ensure to by default build an optimized release version, something like that makes sense:
Additionally to my knowledge -W and -Wextra should be basically the same, while -Wextra is a bit more clear. However despite my knowledge, there where a few small warnings popping up regarding uninitialized variable in one file due to the initialization happening in a helper function which gets passed the pointers. So I initialized the 3 variables.
By default it is better to rely on CMake setting the optimization based on the build type. Release for example even uses
-O3
. There is a more elaborate description in the top answer on https://stackoverflow.com/questions/48754619/what-are-cmake-build-type-debug-release-relwithdebinfo-and-minsizerelWith that change, a build system like conan allows the user to pass individual optimization flags if needed without overriding those.
I'm not sure if it is good practice to do that, but in a project of mine I used the following snippet before I changed fully to conan where the conan profile/settings define the cmake build type. Maybe to ensure to by default build an optimized release version, something like that makes sense:
Additionally to my knowledge
-W
and-Wextra
should be basically the same, while-Wextra
is a bit more clear. However despite my knowledge, there where a few small warnings popping up regarding uninitialized variable in one file due to the initialization happening in a helper function which gets passed the pointers. So I initialized the 3 variables.