On Tue, 6 Oct 2020 13:29:56 -0000 (UTC) Stuart Henderson <s...@spacehopper.org> wrote:
> 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. Thanks for the explanation. Would it be worth documenting this in the cmake(1) manpage? If so, i'll submit a patch. It's quite confusing to have cmake not optimise by default for Release or RelWithDeb builds - i built OpenSceneGraph-3.6 while working on Flightgear and it took a rather long time to figure out why i was getting such a reduced frame rate. Thanks, - Jules -- http://op59.net