Skip to content

abuild-cmake: an improvement for cmake packaging

Ghost User requested to merge (removed):cmakeimprovements into master

@ncopa @kdaudt
this finally sets the default CMAKE_BUILD_TYPE back to MinSizeRel (after much discussion on irc, every time we had a broken build with None, i believe ncopa agreed to finally move this back), and places it into a wrapper script so we don't need to do this outside it again. the wrapper script is also useful so every single apkbuild doesn't need to copy-paste the same incantation every time. yes, this is a lot of work to change, but i can do the majority of this myself- all of main/ is already done here.

much of !6271 (merged) also applies here, but there is a difference for cmake- cmake projects generally do far more stupid shit in their cmake files with debug-by-default hacks than meson projects, which is why None does not work as well and so many things have been broken with it. see for some examples #13287 (closed) #13276 (closed) #13322 (closed) #13039 (closed). also, a lot of those meson options are redundant (https://mesonbuild.com/Builtin-options.html)- many of them have their equivalents here, but there isn't really much point, given how they always inherit from the prefix. it might also be useful to define -DCMAKE_SKIP_INSTALL_RPATH=ON to strip rpaths at install, but i'm not sure what this would really affect.

basically every package rebuilt with this is either the same size or smaller (or much smaller.. !28663 (merged)), so there are no real downsides compared to our previous None usage, and this might also have caught the rare package with debugging enabled that nobody realised (it takes a lot of work to manually check so many cmakefiles if they do something weird in them, or source files for NDEBUG usage)

of course, the same has to be done for community/ and testing/, and i propose removing the lint rule for None as well- nobody needs to set this anymore, and some packages want Release instead (clang, llvm, any massive performance-needing package), and there are a number of packages in testing that i have seen basically do if build_type != Release; build_type=Debug in their cmake files, so sometimes this needs to be overriden, and a lint rule that permanently warns is annoying (also see alpine/infra/docker/apkbuild-lint-tools!4 (merged)). we also set CTEST_PARALLEL_LEVEL and --output-on-failure a lot, so abuild!122 (merged) would be good too, and there are no real downsides to merging these

old irc log snippet:

[2021-12-07T12:16:01+0100] <ikke> ncopa: Do you think !28190 can be merged?
[2021-12-07T12:16:02+0100] <algitbot> main/mariadb: define DBUG_OFF for build: https://gitlab.alpinelinux.org/alpine/aports/merge_requests/28190
[2021-12-07T12:19:09+0100] <ikke> (someone is asking about it)
[2021-12-07T12:20:17+0100] <ncopa> https://gitlab.alpinelinux.org/alpine/aports/-/issues/13276#note_196932
[2021-12-07T12:20:29+0100] <ikke> right
[2021-12-07T12:22:38+0100] <ncopa> I've never been a big fan of the -DCMAKE_BUILD_TYPE=none in the first place
[2021-12-07T12:23:48+0100] <ikke> afaik, the reason was that otherwise our flags would just be ignored in many cases?
[2021-12-07T12:27:37+0100] <ncopa> yes I understand why. But there are otherways to set cflags: https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_FLAGS.html#variable:CMAKE_%3CLANG%3E_FLAGS

(embedded link) #13276 (comment 196932)
of course, -DCMAKE_C_FLAGS doesn't work as expected here, but our flags aren't really ignored in 'many' cases.. rather, they are always prepended, and mainly this means if a project sets -O3 for MinSizeRel it will be overriding the default -Os. this is rather rare though, compared to setting debugging things for None, and this would most likely not need more patches than we already have to fix build_type in aports, and fixing something that sets '-O3' is generally less of an error than it shipping as debug.

also fixes the style of some apkbuilds, a stale patch or two, some licences

Edited by Ghost User

Merge request reports