Bug 15873 - meson having hard time finding cmake dependencies
Summary: meson having hard time finding cmake dependencies
Status: NEW
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: devtools / tool chain (show other bugs)
Version: 5.0.8
Hardware: x86 Multiple
: Medium enhancement
Target Milestone: 6.1
Assignee: Toni Lammi
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2025-05-22 06:20 UTC by Toni Lammi
Modified: 2026-04-15 19:18 UTC (History)
4 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Don't know


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Toni Lammi 2025-05-22 06:20:55 UTC
Recipes inheriting meson.bbclass don't, by default, find dependencies using cmake.

I created a simple repo to reproduce this issue: https://gitlab.com/toni.lammi.kone/meta-foo/-/tree/master/recipes-foo/app?ref_type=heads

I've fixed this with a custom meson-cmake.bbclass with pretty trivial contents:
```
inherit cmake meson

# This might be a meson bug, cmake executable is not found otherwise
export CMAKE="cmake"

do_write_config:append(){
    # Point meson to correct cmake toolchain file to find dependencies correctly
    sed -i '/^\[properties\]/acmake_toolchain_file='"'${WORKDIR}/toolchain.cmake'" \
        ${WORKDIR}/meson.cross
}
```

I'm wondering if this should be handled in meson.bbclass directly? For instance MESON_USE_CMAKE variable which would enable this cmake functionality.
Comment 1 Ross Burton 2025-05-22 14:47:37 UTC
Inheriting both cmake and meson in the same recipe seems a little heavy-handed. I wonder how minimal a cmake toolchain file needs to be, considering it's only used for finding the module scripts?
Comment 2 Toni Lammi 2025-05-23 05:39:47 UTC
Looked into this a bit more.

All the cmake dependencies I've been having bad time with have a dependency to openssl which depends on threads. The build config fails when cmake's threads module tries to check if the compiler compiler supports -pthread flag.

The build can be fixed by simply adding
```
set( CMAKE_CXX_COMPILER some-prefix-g++)
```
to the toolchain file. A similar setting is probably needed for C if the project uses that.

Meson sets the same variable in its internal cmake toolchain but the value is an absolute path to the compiler.

No idea who is at fault here: meson, cmake or FindOpenSSL.cmake.
Comment 3 Ross Burton 2025-05-23 12:36:35 UTC
You'd think an absolute path would be fine...
Comment 4 Randy MacLeod 2026-04-15 19:18:19 UTC
This enhancement is apparently not implemented so bump to 6.1.