All of lore.kernel.org
 help / color / mirror / Atom feed
* CMake based recipes and defining CMAKE_BUILD_TYPE
@ 2019-02-06 18:23 Matt Schuckmann
  2019-02-06 21:31 ` Andreas Müller
  0 siblings, 1 reply; 8+ messages in thread
From: Matt Schuckmann @ 2019-02-06 18:23 UTC (permalink / raw)
  To: yocto

[-- Attachment #1: Type: text/plain, Size: 727 bytes --]

I'm trying to understand why the cmake.bbclass doesn't make any attempt to set CMAKE_BUILD_TYPE and what the design philosophy behind that is?

On the surface I would expect that the default build type would be Release but I can see how that might not always be the right choice. I'm really surprised that there isn't a global variable that can be set for this, am I missing something, or is it really expected that each recipe provide it if they care?


FYI I started looking into this when I realized that NDEBUG is not set for many (if not all) of my CMake based recipes and thus asserts are still enabled in my production code. This appears to be known behavior for CMake if CMAKE_BUILD_TYPE is not set.


Matt S.

[-- Attachment #2: Type: text/html, Size: 1178 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: CMake based recipes and defining CMAKE_BUILD_TYPE
  2019-02-06 18:23 CMake based recipes and defining CMAKE_BUILD_TYPE Matt Schuckmann
@ 2019-02-06 21:31 ` Andreas Müller
  2019-02-06 22:04   ` Matt Schuckmann
  0 siblings, 1 reply; 8+ messages in thread
From: Andreas Müller @ 2019-02-06 21:31 UTC (permalink / raw)
  To: Matt Schuckmann; +Cc: yocto

On Wed, Feb 6, 2019 at 7:39 PM Matt Schuckmann
<Matt.Schuckmann@planar.com> wrote:
>
> I'm trying to understand why the cmake.bbclass doesn't make any attempt to set CMAKE_BUILD_TYPE and what the design philosophy behind that is?
>
> On the surface I would expect that the default build type would be Release but I can see how that might not always be the right choice. I'm really surprised that there isn't a global variable that can be set for this, am I missing something, or is it really expected that each recipe provide it if they care?
>
>
> FYI I started looking into this when I realized that NDEBUG is not set for many (if not all) of my CMake based recipes and thus asserts are still enabled in my production code. This appears to be known behavior for CMake if CMAKE_BUILD_TYPE is not set.
>
>
> Matt S.
>
Hi Matt,

This is not a full answer but Release is not a common target for us:
cmake will produce not containing debug info. With these debugging is
useless (and you'll get package qa warnings). If there is a default
target for us it is RelWithDebInfo.

Andreas


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: CMake based recipes and defining CMAKE_BUILD_TYPE
  2019-02-06 21:31 ` Andreas Müller
@ 2019-02-06 22:04   ` Matt Schuckmann
  2019-02-06 22:24     ` Andreas Müller
  0 siblings, 1 reply; 8+ messages in thread
From: Matt Schuckmann @ 2019-02-06 22:04 UTC (permalink / raw)
  To: Andreas Müller; +Cc: yocto

Hi Andreas, 

Thanks for the response, do you set build type in each recipe individually or is there some central .conf file or other other location that you set it? 

Matt S. 
________________________________________
From: Andreas Müller <schnitzeltony@gmail.com>
Sent: Wednesday, February 6, 2019 1:31 PM
To: Matt Schuckmann
Cc: yocto@yoctoproject.org
Subject: Re: [yocto] CMake based recipes and defining CMAKE_BUILD_TYPE

On Wed, Feb 6, 2019 at 7:39 PM Matt Schuckmann
<Matt.Schuckmann@planar.com> wrote:
>
> I'm trying to understand why the cmake.bbclass doesn't make any attempt to set CMAKE_BUILD_TYPE and what the design philosophy behind that is?
>
> On the surface I would expect that the default build type would be Release but I can see how that might not always be the right choice. I'm really surprised that there isn't a global variable that can be set for this, am I missing something, or is it really expected that each recipe provide it if they care?
>
>
> FYI I started looking into this when I realized that NDEBUG is not set for many (if not all) of my CMake based recipes and thus asserts are still enabled in my production code. This appears to be known behavior for CMake if CMAKE_BUILD_TYPE is not set.
>
>
> Matt S.
>
Hi Matt,

This is not a full answer but Release is not a common target for us:
cmake will produce not containing debug info. With these debugging is
useless (and you'll get package qa warnings). If there is a default
target for us it is RelWithDebInfo.

Andreas





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: CMake based recipes and defining CMAKE_BUILD_TYPE
  2019-02-06 22:04   ` Matt Schuckmann
@ 2019-02-06 22:24     ` Andreas Müller
  2019-02-06 22:53       ` Andreas Müller
  0 siblings, 1 reply; 8+ messages in thread
From: Andreas Müller @ 2019-02-06 22:24 UTC (permalink / raw)
  To: Matt Schuckmann; +Cc: yocto

On Wed, Feb 6, 2019 at 11:05 PM Matt Schuckmann
<Matt.Schuckmann@planar.com> wrote:
>
> Hi Andreas,
>
> Thanks for the response, do you set build type in each recipe individually or is there some central .conf file or other other location that you set it?
>
> Matt S.
Honestly: I do not set them yet because I thought RelWithDebInfo is
default. That assumption was based on some projects but I checked now:
it does not seem to be something to rely on...

Andreas


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: CMake based recipes and defining CMAKE_BUILD_TYPE
  2019-02-06 22:24     ` Andreas Müller
@ 2019-02-06 22:53       ` Andreas Müller
  2019-02-06 23:11         ` Andreas Müller
  0 siblings, 1 reply; 8+ messages in thread
From: Andreas Müller @ 2019-02-06 22:53 UTC (permalink / raw)
  To: Matt Schuckmann; +Cc: yocto

On Wed, Feb 6, 2019 at 11:24 PM Andreas Müller <schnitzeltony@gmail.com> wrote:
>
> On Wed, Feb 6, 2019 at 11:05 PM Matt Schuckmann
> <Matt.Schuckmann@planar.com> wrote:
> >
> > Hi Andreas,
> >
> > Thanks for the response, do you set build type in each recipe individually or is there some central .conf file or other other location that you set it?
> >
> > Matt S.
> Honestly: I do not set them yet because I thought RelWithDebInfo is
> default. That assumption was based on some projects but I checked now:
> it does not seem to be something to rely on...
>
Will build-/run-test this with my 'world':

diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass
index fd40a9863e..a8e08e6d6f 100644
--- a/meta/classes/cmake.bbclass
+++ b/meta/classes/cmake.bbclass
@@ -153,6 +153,7 @@ cmake_do_configure() {
          -DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain.cmake \
          -DCMAKE_VERBOSE_MAKEFILE=1 \
          -DCMAKE_NO_SYSTEM_FROM_IMPORTED=1 \
+         -DCMAKE_BUILD_TYPE=${@d.getVar(oe.utils.vartrue('DEBUG_BUILD',
'Debug', 'RelWithDebInfo', d))} \
          ${EXTRA_OECMAKE} \
          -Wno-dev
 }

Takes a while...

Andreas


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: CMake based recipes and defining CMAKE_BUILD_TYPE
  2019-02-06 22:53       ` Andreas Müller
@ 2019-02-06 23:11         ` Andreas Müller
  2019-02-07  0:08           ` Matt Schuckmann
  0 siblings, 1 reply; 8+ messages in thread
From: Andreas Müller @ 2019-02-06 23:11 UTC (permalink / raw)
  To: Matt Schuckmann; +Cc: yocto

On Wed, Feb 6, 2019 at 11:53 PM Andreas Müller <schnitzeltony@gmail.com> wrote:
>
> On Wed, Feb 6, 2019 at 11:24 PM Andreas Müller <schnitzeltony@gmail.com> wrote:
> >
> > On Wed, Feb 6, 2019 at 11:05 PM Matt Schuckmann
> > <Matt.Schuckmann@planar.com> wrote:
> > >
> > > Hi Andreas,
> > >
> > > Thanks for the response, do you set build type in each recipe individually or is there some central .conf file or other other location that you set it?
> > >
> > > Matt S.
> > Honestly: I do not set them yet because I thought RelWithDebInfo is
> > default. That assumption was based on some projects but I checked now:
> > it does not seem to be something to rely on...
> >
> Will build-/run-test this with my 'world':
>
> diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass
> index fd40a9863e..a8e08e6d6f 100644
> --- a/meta/classes/cmake.bbclass
> +++ b/meta/classes/cmake.bbclass
> @@ -153,6 +153,7 @@ cmake_do_configure() {
>           -DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain.cmake \
>           -DCMAKE_VERBOSE_MAKEFILE=1 \
>           -DCMAKE_NO_SYSTEM_FROM_IMPORTED=1 \
> +         -DCMAKE_BUILD_TYPE=${@d.getVar(oe.utils.vartrue('DEBUG_BUILD',
> 'Debug', 'RelWithDebInfo', d))} \
>           ${EXTRA_OECMAKE} \
>           -Wno-dev
>  }
>
> Takes a while...
>
Not exactly: After short build I saw:

* There are some sed on '*-noconfig.cmake' they are going to break
* libeigen fails because it supports 'Debug' and 'Release' only (and I
bet there are more)

Will skip further tests and get the feeling that a common solution won't do...

Andreas


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: CMake based recipes and defining CMAKE_BUILD_TYPE
  2019-02-06 23:11         ` Andreas Müller
@ 2019-02-07  0:08           ` Matt Schuckmann
  2019-02-07  8:03             ` Mikko.Rapeli
  0 siblings, 1 reply; 8+ messages in thread
From: Matt Schuckmann @ 2019-02-07  0:08 UTC (permalink / raw)
  To: Andreas Müller; +Cc: yocto

Aright thank you for checking into this, you went farther then I expected. 
I will take the approach of setting it for the recipes I really care about and leave the rest alone. 

Matt S. 
________________________________________
From: Andreas Müller <schnitzeltony@gmail.com>
Sent: Wednesday, February 6, 2019 3:11 PM
To: Matt Schuckmann
Cc: yocto@yoctoproject.org
Subject: Re: [yocto] CMake based recipes and defining CMAKE_BUILD_TYPE

On Wed, Feb 6, 2019 at 11:53 PM Andreas Müller <schnitzeltony@gmail.com> wrote:
>
> On Wed, Feb 6, 2019 at 11:24 PM Andreas Müller <schnitzeltony@gmail.com> wrote:
> >
> > On Wed, Feb 6, 2019 at 11:05 PM Matt Schuckmann
> > <Matt.Schuckmann@planar.com> wrote:
> > >
> > > Hi Andreas,
> > >
> > > Thanks for the response, do you set build type in each recipe individually or is there some central .conf file or other other location that you set it?
> > >
> > > Matt S.
> > Honestly: I do not set them yet because I thought RelWithDebInfo is
> > default. That assumption was based on some projects but I checked now:
> > it does not seem to be something to rely on...
> >
> Will build-/run-test this with my 'world':
>
> diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass
> index fd40a9863e..a8e08e6d6f 100644
> --- a/meta/classes/cmake.bbclass
> +++ b/meta/classes/cmake.bbclass
> @@ -153,6 +153,7 @@ cmake_do_configure() {
>           -DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain.cmake \
>           -DCMAKE_VERBOSE_MAKEFILE=1 \
>           -DCMAKE_NO_SYSTEM_FROM_IMPORTED=1 \
> +         -DCMAKE_BUILD_TYPE=${@d.getVar(oe.utils.vartrue('DEBUG_BUILD',
> 'Debug', 'RelWithDebInfo', d))} \
>           ${EXTRA_OECMAKE} \
>           -Wno-dev
>  }
>
> Takes a while...
>
Not exactly: After short build I saw:

* There are some sed on '*-noconfig.cmake' they are going to break
* libeigen fails because it supports 'Debug' and 'Release' only (and I
bet there are more)

Will skip further tests and get the feeling that a common solution won't do...

Andreas





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: CMake based recipes and defining CMAKE_BUILD_TYPE
  2019-02-07  0:08           ` Matt Schuckmann
@ 2019-02-07  8:03             ` Mikko.Rapeli
  0 siblings, 0 replies; 8+ messages in thread
From: Mikko.Rapeli @ 2019-02-07  8:03 UTC (permalink / raw)
  To: Matt.Schuckmann; +Cc: yocto

Hi,

From my experience, what CMAKE_BUILD_TYPE means varies between SW components.
Thus I think the current approach of not setting it is correct. SW components
must set their own defaults in either CMakeLists.txt or in the bitbake recipe.

Also, building with debug info is separate from CMAKE_BUILD_TYPE. The default
compile flags from yocto will include -g for debug symbols and this is provided
to CMake compile flags too.

Cheers,

-Mikko

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-02-07  8:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-06 18:23 CMake based recipes and defining CMAKE_BUILD_TYPE Matt Schuckmann
2019-02-06 21:31 ` Andreas Müller
2019-02-06 22:04   ` Matt Schuckmann
2019-02-06 22:24     ` Andreas Müller
2019-02-06 22:53       ` Andreas Müller
2019-02-06 23:11         ` Andreas Müller
2019-02-07  0:08           ` Matt Schuckmann
2019-02-07  8:03             ` Mikko.Rapeli

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.