bbc / bmx

Library and utilities to read and write broadcasting media files. Primarily supports the MXF file format
BSD 3-Clause "New" or "Revised" License
57 stars 16 forks source link

Remove the fixed -O2 compile flag #73

Closed irieger closed 2 months ago

irieger commented 2 months ago

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-minsizerel

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:

if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Release)
endif()

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.