Bug 13801 - toolchainfile.cmake CMAKE_BUILD_TYPE
Summary: toolchainfile.cmake CMAKE_BUILD_TYPE
Status: RESOLVED INVALID
Alias: None
Product: buildroot
Classification: Unclassified
Component: Other (show other bugs)
Version: 2021.02.1
Hardware: All Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-12 08:41 UTC by christian.morales.vega
Modified: 2021-05-12 10:14 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description christian.morales.vega 2021-05-12 08:41:59 UTC
The toolchainfile.cmake file created by Buildroot says things like "# This toolchain file can be used both inside and outside Buildroot.". But it's not really friendly to outside Buildroot users since it hardcodes CMAKE_BUILD_TYPE.

cmake -B build -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE=toolchainfile.cmake should use MinSizeRel, not Debug or Release. Maybe I want to debug my software and want to build it with Debug CMAKE_BUILD_TYPE even if the rest of Buildroot has been built with Release.


I'm not even sure how much sense it makes to make it Debug or Release based on BR2_ENABLE_DEBUG (https://git.busybox.net/buildroot/tree/package/pkg-cmake.mk?id=8036c23d5964cf924d8857cf1a8f711404458950#n269).
BR2_ENABLE_DEBUG is described as "Build packages with debugging symbols enabled", i.e. it's only effect is supposed to be to add "-g". But by using the Debug CMAKE_BUILD_TYPE God knows what a specific package will do: it may enable extra logging, use a way slower algorithm to do some task...

In any case I would argue https://git.busybox.net/buildroot/tree/package/pkg-cmake.mk?id=8036c23d5964cf924d8857cf1a8f711404458950#n94 is a better place to set a __default__ CMAKE_BUILD_TYPE. Outside Buildroot user should not be seeing it.
Comment 1 christian.morales.vega 2021-05-12 10:14:22 UTC
I was actually looking at a file doing something differently than what at least the latest Buildroot does. Since it's set as a non-forced cache variable the user's given value has priority.