Bug 12827

Summary: nativesdk-cmake: can't find OEToolchainConfig.cmake
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Chin Huat Ang <chin.huat.ang>
Component: devtools / tool chainAssignee: Armin Kuster <akuster>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: bluelightning, geissonator, henry.bruce, meta.mr.watcher, meta.watcher, otavio, pokylinux, ross.burton, sjolley.yp.pm
Version: 2.6   
Target Milestone: 2.5.2   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Chin Huat Ang 2018-06-28 07:11:19 UTC
Sourcing SDK environment-setup-* script adds following cmake alias which depends on cmake toolchain file:

alias cmake='cmake -DCMAKE_TOOLCHAIN_FILE=/opt/poky/2.5+snapshot/sysroots/x86_64-pokysdk-linux/usr/share/cmake/OEToolchainConfig.cmake'

However OEToolchainConfig.cmake is packaged in nativesdk-cmake-dev which is not installed as part of SDK by default.
Comment 1 Ross Burton 2018-06-28 14:53:52 UTC
I'd suggest this is a trivial tweak of FILES_* to get the file in the right place.  I'd also say the eSDK test suite needs extending to ensure that cmake builds actually work.
Comment 2 Richard Purdie 2018-06-28 14:54:15 UTC
I'm a little concerned about how we might fix this. We should perhaps only be including this configuration if cmake is installed in the sdk? We could wrap it in the shell script with a test whether the file exists.

Also, does one cmake file really work for all the different target architectures?
Comment 3 Robert Berger 2018-07-02 06:39:06 UTC
I think I am missing something here.

In my case this looks differently for sumo, at least with a quick test for the extensible SDK.

source /opt/ext-sdk/poky/2.5/multi-v7-ml/imx6q-phytec-mira-rdk-nand/environment-setup-armv7a-neon-poky-linux-gnueabi

student@e450-1:~⟫ which cmake
/opt/ext-sdk/poky/2.5/multi-v7-ml/imx6q-phytec-mira-rdk-nand/tmp/sysroots/x86_64/usr/bin/cmake

alias | grep -i cmake

returns nothing!

---------

"classic" SDK

student@e450-1:~⟫ source /opt/poky/2.5/multi-v7-ml/imx6q-phytec-mira-rdk-nand/environment-setup-armv7a-neon-poky-linux-gnueabi 
student@e450-1:~⟫ which cmake
/opt/poky/2.5/multi-v7-ml/imx6q-phytec-mira-rdk-nand/sysroots/x86_64-pokysdk-linux/usr/bin/cmake

please note, that I see this alias only with the "classic" SDK and not with the extensible SDK:

alias | grep -i cmake
alias cmake='cmake -DCMAKE_TOOLCHAIN_FILE=/opt/poky/2.5/multi-v7-ml/imx6q-phytec-mira-rdk-nand/sysroots/x86_64-pokysdk-linux/usr/share/cmake/OEToolchainConfig cmake'
Comment 4 Chin Huat Ang 2018-07-12 03:31:13 UTC
It's worth pointing out that the SDK environment setup script looks for $OECORE_NATIVE_SYSROOT/environment-setup.d/*.sh and thus sourced cmake.sh (installed by nativesdk-cmake), however it sets up a broken alias and rendered cmake unusable with the following error message:


###

parallels@ubuntu:~/git/cmake-hello/build$ cmake . ..
CMake Error at /opt/yocto-releases/2.6_M1.rc1/poky-glibc-x86_64-core-image-sato-i586-toolchain-2.5+snapshot/sysroots/x86_64-pokysdk-linux/usr/share/cmake-3.10/Modules/CMakeDetermineSystem.cmake:100 (message):
  Could not find toolchain file:
  /opt/yocto-releases/2.6_M1.rc1/poky-glibc-x86_64-core-image-sato-i586-toolchain-2.5+snapshot/sysroots/x86_64-pokysdk-linux/usr/share/cmake/OEToolchainConfig.cmake
Call Stack (most recent call first):
  CMakeLists.txt:1 (project)


CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

###


Apparently bitbake.conf includes ${datadir}/cmake/* into nativesdk-cmake-dev package, so instead I'm moving the OEToolchainConfig.cmake file into the same directory as the cmake.sh file which depends on it.

Fix submitted: http://lists.openembedded.org/pipermail/openembedded-core/2018-July/152810.html

I've also sanity tested SDK generated for core-image-sato qemux86 and qemuarm64 targets and the cmake toolchain config file appears to work just fine after correcting the paths, although I should also mention that the toolchain file currently contains optional settings as the default cmake modules are smart enough to reuse common environment variables set by SDK environment script variables, e.g. CMakeDetermineCCompiler.cmake module which detects C compiler settings would prefer to derive CMAKE_C_COMPILER setting (if missing/unset) from $CC environment variable.
Comment 5 Ross Burton 2018-07-12 16:47:57 UTC
It's not fixed until the patch is in master.
Comment 6 Henry Bruce 2018-08-16 19:01:46 UTC
I have an internal customer using meta-intel who has just moved from rocko to sumo (on my advice) and hit this bug. I have fixed with a bbappend implementing the bug-fix patch pending backport to sumo.  

+1 on better test coverage for cmake.
Comment 7 Andrew 2018-08-20 13:06:02 UTC
We hit this as well over in openbmc (https://github.com/openbmc).  Be great to get this one in and done. I patched the change in directly but not sure I'll have much luck getting it in - https://gerrit.openbmc-project.xyz/#/c/openbmc/openbmc/+/11901/
Comment 8 Ross Burton 2018-09-27 15:06:49 UTC
FWIW I believe a6ce79b87d3db57033a3d1710cb3292366a0a8f7 fixed this in master.
Comment 9 Chin Huat Ang 2018-10-02 08:51:04 UTC
I've verified building SDK from master with the following commit fixes the problem:

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=206f8102a45e5e91657dd6e8c098ffe0f257b1cc
Comment 10 Stephen K Jolley 2018-10-02 15:26:17 UTC
Need a backport to 2.5.2
Comment 11 Armin Kuster 2018-10-02 16:03:55 UTC
(In reply to comment #10)
> Need a backport to 2.5.2

in stable/sumo-nmut
Comment 13 Armin Kuster 2018-11-05 23:45:52 UTC
closing