This came up in bug 856778 where it appears that LTO is coming from pybind11 (!) which defaults to LTO per https://github.com/pybind/pybind11/blob/8b48ff878c168b51fe5ef7b8c728815b9e1a9857/docs/compiling.rst#pybind11_add_module. We should set -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF in the eclass. THe user can enable LTO if they want. Alternatively, we could do the meson.eclass appraoch and check for tc-is-lto first...?
https://cmake.org/cmake/help/latest/prop_tgt/INTERPROCEDURAL_OPTIMIZATION.html#prop_tgt:INTERPROCEDURAL_OPTIMIZATION https://cmake.org/cmake/help/latest/variable/CMAKE_INTERPROCEDURAL_OPTIMIZATION.html#variable:CMAKE_INTERPROCEDURAL_OPTIMIZATION
Note the meson.eclass approach is beneficial since there are meson projects that specifically set some targets known to not work with LTO to off. e.g. scipy has some really old fortran code with no intention of fixing it, since they just want to migrate *away* from it. So they force LTO off, but other scipy extension modules are expected to work fine. Similar logic may or may not apply to cmake / projects using cmake. (Or might not apply.)
Note that cmake seems to add -flo=auto when this option is enabled. Not sure if there is any way to control the exact flags it adds.