[yocto] Running cmake in the SDK environment from a script fails

Bartosz Golaszewski brgl at bgdev.pl
Thu Jan 18 06:08:54 PST 2018


2018-01-17 20:30 GMT+01:00 Bartosz Golaszewski <brgl at bgdev.pl>:
> Hi,
>
> I'm working on a project in which a base linux distribution is built
> using yocto while a set of proprietary components is built with the
> generated SDK (-c populate_sdk).
>
> These components use cmake for building. While they build just fine
> when the 'cmake' command is invoked from command-line, as soon as
> there's a fork() and execve() in between (e.g. when cmake is invoked
> from a script or even when I tried tracing it with strace), the build
> fails on finding any external library:
>
> -- Could NOT find ZLIB (missing:  ZLIB_LIBRARY) (found version "1.2.8")
> CMake Error at cmake/external_dependencies.cmake:10 (message):
>   Could not find zlib
> Call Stack (most recent call first):
>   CMakeLists.txt:109 (include)
>
> The 'found' message is there because it eventually 'found' my host's
> header as visible in the strace output[1].
>
> The target arch is core2-64 while the host is x86_64. Both host and
> target dirs are present in sysroots/.
>
> What's clear when browsing the strace output is that the headers are
> not searched for in the right directory which would in this case be
> sysroots/core2-64-poky-linux/usr/include/ but in
> /sysroots/x86_64-pokysdk-linux/ instead.
>
> I initially thought this to be a problem with the project's
> CMakeLists.txt but it seems fine given the fact that it builds when
> used manually.
>
> Any idea what could be the culprit here?
>
> Best regards,
> Bartosz Golaszewski
>
> [1] https://pastebin.com/1pqmbh7R

After some more debugging I found the culprit. The environment setup
script in the SDK aliases cmake to 'cmake
-DCMAKE_TOOLCHAIN_FILE=$OECORE_NATIVE_SYSROOT/usr/share/cmake/OEToolchainConfig.cmake'
but aliases are not expanded in non-interactive shells by default.

It can be fixed with shopt or by passing this parameter explicitly to cmake.

I didn't find any mention of that anywhere in docs. Any idea for a
right place to put it in?

Thanks,
Bartosz



More information about the yocto mailing list