I would like some clarity regarding cmake build types.
Specifically, it isn't clear to me whether setting a build type will also modify the build flags, or whether this is just a "label" that is used internally for the build configuration. For example, in the case of a release build:
set(CMAKE_BUILD_TYPE Release)
will the O3
flag automatically be specified to the compiler? or do I need to explicitly specify it?
One answer I found sets both the build type and explicitly sets the compiler flags:
But another thread I found online suggests that there are defaults:
https://cmake.org/pipermail/cmake/2016-May/063379.html
If the build type does specify some compiler flags, where can I find documentation for that? I would like to know what flags each build type is setting.
EDIT:
For future reference, if you want to look for the specific flags for your compiler (e.g. gnu in the case of gcc or g++), then you can clone the repo that Kamil references, go into the modules/compilers folder and try a command like:
grep -r _INIT . | grep -i gnu
In fact, as Kamil points out, these flags will also be the same as the ones used by Clang since the Clang cmake file includes the GNU one.