Bug 14927

Summary: Meson >= 59.0 fails to find Threads dependency using CMake
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Toni Lammi <toni.lammi>
Component: devtools / tool chainAssignee: Unassigned <unassigned>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: Undecided CC: meta.mr.watcher, meta.watcher, randy.macleod
Version: 4.0.2   
Target Milestone: ---   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Toni Lammi 2022-10-12 08:52:02 UTC
Meson fails when searching for Threads dependency using cmake:
dependency('Threads', method: 'cmake', modules: ['Threads::Threads'])

This issue was likely caused by an update to how Meson manages
CMake dependencies: https://github.com/mesonbuild/meson/pull/8812
See also issue in meson: https://github.com/mesonbuild/meson/issues/10384
The issue only occurs with meson >= 59.0


I studied this issue a bit and found a couple workarounds for this in Yocto:
First one is to modify cmake_toolchain_file in SDK's meson.cross from
cmake_toolchain_file='<sdkpath>/usr/share/cmake/OEToolchainConfig.cmake'
to
cmake_toolchain_file='<sdkpath>/usr/share/cmake/cortexa53-crypto-<distro>-toolchain.cmake'
Another one is to modify OEToolchainConfig.cmake from
file( GLOB toolchain_config_files "${CMAKE_CURRENT_LIST_FILE}.d/*.cmake" )
to
file( GLOB toolchain_config_files "${CMAKE_CURRENT_LIST_DIR}/*toolchain.cmake" )

To me it looks like the SDK's configuration is a bit off and meson therefore
fails to get the correct information from the environment.

I'm wondering if this behavior is a bug or if I'm doing something wrong here.
Comment 1 Toni Lammi 2022-10-12 11:53:55 UTC
Looking at this a bit more and I can see that the cmake_toolchain_file option
comes from our own layer so I think this is not actually an oe-core issue.

It seems that OE-core does not have support for this cmake-meson interoperability
out-of-the-box.
Comment 2 Randy MacLeod 2022-10-13 14:42:38 UTC
Seems to be specific to Toni's local layer.