On 2020-10-05, Julian Smith <ju...@op59.net> wrote:
> It looks like OpenBSD's cmake port patches cmake to remove the use of
> -O2 in Release and RelWithDebInfo builds -
> /usr/ports/devel/cmake/patches/patch-Modules_Compiler_GNU_cmake has:
>
> -  string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os -DNDEBUG")
> -  string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG")
> -  string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG")
> +  string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -DNDEBUG")
> +  string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -DNDEBUG")
> +  string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -g -DNDEBUG")
>
> Does anyone know why things are patched in this way?
>
>
> [I think one can force optimisation with (for example):
>
>     cmake -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -g -DNDEBUG"  ...
> ]
>
>
> Thanks,
>
> - Jules
>

It's setup to work with builds done from ports, which should not
override whatever optimization level is set by either the user or the
build infrastructure.

The downside is that you need to add this yourself for builds from
outside ports.


Reply via email to