Gentoo Archives: gentoo-dev

From: Guilherme Amadio <amadio@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH 4/4] cmake.eclass: Default CMAKE_BUILD_TYPE=RelWithDebInfo in EAPI 8
Date: Fri, 20 Aug 2021 07:47:01
Message-Id: YR9d6UDUGgLMVfZ/@gentoo.org
In Reply to: [gentoo-dev] [PATCH 4/4] cmake.eclass: Default CMAKE_BUILD_TYPE=RelWithDebInfo in EAPI 8 by Andreas Sturmlechner
1 Hi,
2
3 On Thu, Aug 19, 2021 at 07:45:16PM +0200, Andreas Sturmlechner wrote:
4 > Signed-off-by: Michał Górny <mgorny@g.o>
5 > Signed-off-by: Andreas Sturmlechner <asturm@g.o>
6 > ---
7 > eclass/cmake.eclass | 11 ++++++++---
8 > 1 file changed, 8 insertions(+), 3 deletions(-)
9 >
10 > diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass
11 > index 8befd9e5a9f..3021a3a2b1e 100644
12 > --- a/eclass/cmake.eclass
13 > +++ b/eclass/cmake.eclass
14 > @@ -42,14 +42,19 @@ _CMAKE_ECLASS=1
15 > # Eclass can use different cmake binary than the one provided in by system.
16 > : ${CMAKE_BINARY:=cmake}
17 >
18 > +[[ ${EAPI} == 7 ]] && : ${CMAKE_BUILD_TYPE:=Gentoo}
19 > # @ECLASS-VARIABLE: CMAKE_BUILD_TYPE
20 > # @DESCRIPTION:
21 > # Set to override default CMAKE_BUILD_TYPE. Only useful for packages
22 > # known to make use of "if (CMAKE_BUILD_TYPE MATCHES xxx)".
23 > # If about to be set - needs to be set before invoking cmake_src_configure.
24 > -# You usually do *NOT* want nor need to set it as it pulls CMake default
25 > -# build-type specific compiler flags overriding make.conf.
26 > -: ${CMAKE_BUILD_TYPE:=Gentoo}
27 > +#
28 > +# The default is RelWithDebInfo as that is least likely to append undesirable
29 > +# flags. However, you may still need to sed CMake files or choose a different
30 > +# build type to achieve desirable results.
31 > +#
32 > +# In EAPI 7, the default was non-standard build type of Gentoo.
33 > +: ${CMAKE_BUILD_TYPE:=RelWithDebInfo}
34
35 Although I think this is better than the "Gentoo" build type we had, I
36 think that even better is to just leave this blank and set a default on
37 a per-ebuild basis, as I commented on bug 802786[1]. Repeating my
38 comment from there, build type flags always come after CMAKE_<LANG>_FLAGS,
39 which then override make.conf settings. Moreover, setting a build type
40 can also have funny behavior with multi-config generators (possible with
41 ninja on Linux too now) because it has no meaning in that context. For
42 instance, this may override make.conf flags with "-O2 -g" in most cases,
43 preventing people from changing the optimization level of any CMake-based
44 package, or disabling compilation of debug info (which is then stripped
45 anyway). This is probably why we had the "Gentoo" build in the first place.
46
47 For ebuilds that must have a CMAKE_BUILD_TYPE set, we should probably
48 use Release and override CMAKE_<LANG>_FLAGS_RELEASE with settings from
49 make.conf, or make CMAKE_<LANG>_FLAGS contain settings from make.conf
50 and enforce CMAKE_<LANG>_FLAGS_<BUILD_TYPE> is empty for all build types.
51
52 Cheers,
53 -Guilherme
54
55 1. https://bugs.gentoo.org/802786
56
57 >
58 > # @ECLASS-VARIABLE: CMAKE_IN_SOURCE_BUILD
59 > # @DEFAULT_UNSET
60 > --
61 > 2.33.0
62 >

Replies