0
votes

I'm trying to build a helloworld package example with a cmake recipe. My problem is bitbake give me an error because it can't find CMakeLists.txt in the /tmp/work/core2-64-poky-linux/helloworld/0.1-r0 folder.

The error :

helloworld-0.1-r0 do_configure: Execution of '/path-to-tmp/tmp/work/core2-64-poky-linux/helloworld/0.1-r0/temp/run.do_configure.28001' failed with exit code 1:
CMake Error: The source directory "/path-to-tmp/tmp/work/core2-64-poky-linux/helloworld/0.1-r0/files" does not appear to contain CMakeLists.txt.

My package is in my layer meta-mylayer/recipes-core/helloworld :

meta-mylayer/
├── conf
│   └── layer.conf
├── COPYING.MIT
├── README
└── recipes-core
    └── helloworld
        ├── files
        │   ├── CMakeLists.txt
        │   └── main_helloworld.c
        └── helloworld_0.1.bb

My CMakeLists.txt :

cmake_minimum_required(VERSION 2.4)

project(helloworld)
file(GLOB_RECURSE files/*.c)

add_executable(app ${src_files})

install(TARGETS helloworld DESTINATION bin)

My helloworld_0.1.bb :

PN="helloworld"
PV="0.1"
P="${PN}-${PV}"
DESCRIPTION="This is my package helloworld"
LICENSE="CLOSED"
FILESEXTRAPATHS_prepend:="${THISDIR}/${PN}:"
RDEPENDS_${PN}+=""
DEPENDS+=""
DEPENDS+="cmake"

SRC_URI+="file://CMakeLists.txt file://main_helloworld.c"

S="${WORKDIR}/files"

inherit pkgconfig cmake

I can't find my files in /path-to-tmp/tmp/work/core2-64-poky-linux/helloworld/0.1-r0/*

Why files are not copied? I'm using yocto Dunfell.

Thanks for your help.

1

1 Answers

0
votes

When you have files in SRC_URI they are installed in ${WORKDIR}.

The following recipe will do the trick:

DESCRIPTION="This is my package helloworld"
LICENSE="CLOSED"

SRC_URI+="file://CMakeLists.txt file://main_helloworld.c"

S="${WORKDIR}"

inherit pkgconfig cmake

Also, your CMakeLists.txt should not find files in files directory.

S is set to ${WORKDIR} because this is where the files from the file:// fetcher are put by default.

DEPENDS already has cmake-native in it from the cmake bbclass you inherited. You don't need to depends on cmake, because you depends on cmake-native (you need to execute cmake at build time, you don't need cmake headers or sources).

The FILESEXTRAPATHS that was added is already by default used by bitbake (and it's also not matching your directory layout).

PN and PV are gotten from the filename of the bb recipe, no need to set them again.