Closed4

[yocto kirkstone] cmake's FetchContent_Populate does not download the module.

nb.onb.o

Minimum sample of FetchContent_Populate

Reference

CMakeLists.txt

cmake_minimum_required(VERSION 3.16)
project(example)

set(helloworld_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/helloworld")
set(helloworld_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/helloworld")
set(helloworld_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${helloworld_INSTALL_DIR})

include(FetchContent)
FetchContent_Declare(
  helloworld
  GIT_REPOSITORY https://github.com/mickey-happygolucky/helloworld.git
  GIT_TAG main
)
FetchContent_GetProperties(helloworld)
if(NOT depname_helloworld)
  # Fetch the content using previously declared details
  FetchContent_Populate(helloworld)

  # Set custom variables, policies, etc.
  # ...

  # Bring the populated content into the build
  add_subdirectory(${helloworld_SOURCE_DIR} ${helloworld_BINARY_DIR})
endif()

configure

$ ls 
CMakeLists.txt
$ mkdir build && cd build
$ cmake ..
-- The C compiler identification is GNU 11.3.1
-- The CXX compiler identification is GNU 11.3.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: xxxxxxxxx/build/test/build

Download under the _deps directory.

$ ls _deps/
helloworld-build  helloworld-src  helloworld-subbuild
$ ls _deps/helloworld-src/
CMakeLists.txt  LICENSE  README.md  main.cpp
nb.onb.o

Create yocto recipe and bitbake

$ git clone -b kirkstone git://git.yoctoproject.org/poky.git
$ source poky/oe-init-build-env
$ bitbake-layers create-layer meta-test
$ bitbake-layers add-layer ./meta-test
$ mkdir ./meta-test/recipes-example/example/files

Copy the created CMakeLists.txt

$ cp ../CMakeLists.txt ./meta-test/recipes-example/example/files/CMakeLists.txt

Create recipe

$ vim ./meta-test/recipes-example/example/example_0.1.bb
 

SUMMARY = "bitbake-layers recipe"
DESCRIPTION = "Recipe created by bitbake-layers"
LICENSE = "MIT"

python do_display_banner() {
    bb.plain("***********************************************");
    bb.plain("*                                             *");
    bb.plain("*  Example recipe created by bitbake-layers   *");
    bb.plain("*                                             *");
    bb.plain("***********************************************");
}

addtask display_banner before do_build
SUMMARY = "bitbake-layers recipe"
DESCRIPTION = "Recipe created by bitbake-layers"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

inherit cmake

SRC_URI = "file://CMakeLists.txt"

S = "${WORKDIR}"

do_configure[network] =  "1"
do_compile[network] = "1"

do_install() {
    install -d ${D}/${bindir}
    install ${B}/helloworld/bin/helloworld ${D}/${bindir}
}

bitbake and failed

$ bitbake example
Loading cache: 100% |########################################################################################################################################################################################################| Time: 0:00:00
Loaded 1641 entries from dependency cache.
Parsing recipes: 100% |######################################################################################################################################################################################################| Time: 0:00:00
Parsing of 883 .bb files complete (882 cached, 1 parsed). 1641 targets, 44 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION           = "2.0.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "universal"
TARGET_SYS           = "x86_64-poky-linux"
MACHINE              = "qemux86-64"
DISTRO               = "poky"
DISTRO_VERSION       = "4.0"
TUNE_FEATURES        = "m64 core2"
TARGET_FPU           = ""
meta                 
meta-poky            
meta-yocto-bsp       = "kirkstone:27de52e402ae000dfa502d52908cd6e6aef923ec"
meta-test            = "<unknown>:<unknown>"

Initialising tasks: 100% |###################################################################################################################################################################################################| Time: 0:00:00
Sstate summary: Wanted 5 Local 0 Mirrors 0 Missed 5 Current 154 (0% match, 96% complete)
NOTE: Executing Tasks
ERROR: example-0.1-r0 do_configure: ExecutionError('/home/abcde/Data/yocto/kirkstone/build/tmp/work/core2-64-poky-linux/example/0.1-r0/temp/run.do_configure.926353', 1, None, None)
ERROR: Logfile of failure stored in: /home/abcde/Data/yocto/kirkstone/build/tmp/work/core2-64-poky-linux/example/0.1-r0/temp/log.do_configure.926353
Log data follows:
| DEBUG: Executing python function extend_recipe_sysroot
| NOTE: Direct dependencies are ['virtual:native:/home/abcde/Data/yocto/kirkstone/poky/meta/recipes-devtools/pseudo/pseudo_git.bb:do_populate_sysroot', '/home/abcde/Data/yocto/kirkstone/poky/meta/recipes-devtools/cmake/cmake-native_3.22.3.bb:do_populate_sysroot', '/home/abcde/Data/yocto/kirkstone/poky/meta/recipes-devtools/quilt/quilt-native_0.67.bb:do_populate_sysroot', 'virtual:native:/home/abcde/Data/yocto/kirkstone/poky/meta/recipes-devtools/ninja/ninja_1.10.2.bb:do_populate_sysroot', 'virtual:native:/home/abcde/Data/yocto/kirkstone/poky/meta/recipes-devtools/patch/patch_2.7.6.bb:do_populate_sysroot', '/home/abcde/Data/yocto/kirkstone/poky/meta/recipes-devtools/gcc/gcc-cross_11.2.bb:do_populate_sysroot', '/home/abcde/Data/yocto/kirkstone/poky/meta/recipes-core/glibc/glibc_2.35.bb:do_populate_sysroot', '/home/abcde/Data/yocto/kirkstone/poky/meta/recipes-devtools/gcc/gcc-runtime_11.2.bb:do_populate_sysroot']
| NOTE: Installed into sysroot: []
| NOTE: Skipping as already exists in sysroot: ['pseudo-native', 'cmake-native', 'quilt-native', 'ninja-native', 'patch-native', 'gcc-cross-x86_64', 'glibc', 'gcc-runtime', 'zstd-native', 'curl-native', 'zlib-native', 'bzip2-native', 'ncurses-native', 'xz-native', 're2c-native', 'libtool-native', 'attr-native', 'binutils-cross-x86_64', 'texinfo-dummy-native', 'gmp-native', 'libmpc-native', 'linux-libc-headers', 'flex-native', 'gnu-config-native', 'mpfr-native', 'libgcc', 'openssl-native', 'gettext-minimal-native', 'm4-native', 'perl-native', 'gdbm-native']
| DEBUG: Python function extend_recipe_sysroot finished
| DEBUG: Executing shell function do_configure
| -- The C compiler identification is GNU 11.2.0
| -- The CXX compiler identification is GNU 11.2.0
| -- Detecting C compiler ABI info
| -- Detecting C compiler ABI info - done
| -- Check for working C compiler: /home/abcde/Data/yocto/kirkstone/build/tmp/work/core2-64-poky-linux/example/0.1-r0/recipe-sysroot-native/usr/bin/x86_64-poky-linux/x86_64-poky-linux-gcc - skipped
| -- Detecting C compile features
| -- Detecting C compile features - done
| -- Detecting CXX compiler ABI info
| -- Detecting CXX compiler ABI info - done
| -- Check for working CXX compiler: /home/abcde/Data/yocto/kirkstone/build/tmp/work/core2-64-poky-linux/example/0.1-r0/recipe-sysroot-native/usr/bin/x86_64-poky-linux/x86_64-poky-linux-g++ - skipped
| -- Detecting CXX compile features
| -- Detecting CXX compile features - done
| CMake Error at CMakeLists.txt:23 (add_subdirectory):
|   add_subdirectory given source
|   "/home/abcde/Data/yocto/kirkstone/build/tmp/work/core2-64-poky-linux/example/0.1-r0/build/_deps/helloworld-src"
|   which is not an existing directory.
| 
| 
| -- Configuring incomplete, errors occurred!
| See also "/home/abcde/Data/yocto/kirkstone/build/tmp/work/core2-64-poky-linux/example/0.1-r0/build/CMakeFiles/CMakeOutput.log".
| WARNING: /home/abcde/Data/yocto/kirkstone/build/tmp/work/core2-64-poky-linux/example/0.1-r0/temp/run.do_configure.926353:163 exit 1 from 'cmake -G 'Ninja' -DCMAKE_MAKE_PROGRAM=ninja $oecmake_sitefile /home/abcde/Data/yocto/kirkstone/build/tmp/work/core2-64-poky-linux/example/0.1-r0 -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_INSTALL_BINDIR:PATH=bin -DCMAKE_INSTALL_SBINDIR:PATH=sbin -DCMAKE_INSTALL_LIBEXECDIR:PATH=libexec -DCMAKE_INSTALL_SYSCONFDIR:PATH=/etc -DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=../com -DCMAKE_INSTALL_LOCALSTATEDIR:PATH=/var -DCMAKE_INSTALL_LIBDIR:PATH=lib -DCMAKE_INSTALL_INCLUDEDIR:PATH=include -DCMAKE_INSTALL_DATAROOTDIR:PATH=share -DPYTHON_EXECUTABLE:PATH=/usr/bin/python3 -DPython_EXECUTABLE:PATH=/usr/bin/python3 -DPython3_EXECUTABLE:PATH=/usr/bin/python3 -DLIB_SUFFIX= -DCMAKE_INSTALL_SO_NO_EXE=0 -DCMAKE_TOOLCHAIN_FILE=/home/abcde/Data/yocto/kirkstone/build/tmp/work/core2-64-poky-linux/example/0.1-r0/toolchain.cmake -DCMAKE_NO_SYSTEM_FROM_IMPORTED=1 -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON -DFETCHCONTENT_FULLY_DISCONNECTED=ON -Wno-dev'
| WARNING: Backtrace (BB generated script):
| 	#1: cmake_do_configure, /home/abcde/Data/yocto/kirkstone/build/tmp/work/core2-64-poky-linux/example/0.1-r0/temp/run.do_configure.926353, line 163
| 	#2: do_configure, /home/abcde/Data/yocto/kirkstone/build/tmp/work/core2-64-poky-linux/example/0.1-r0/temp/run.do_configure.926353, line 142
| 	#3: main, /home/abcde/Data/yocto/kirkstone/build/tmp/work/core2-64-poky-linux/example/0.1-r0/temp/run.do_configure.926353, line 199
ERROR: Task (/home/abcde/Data/yocto/kirkstone/build/meta-test/recipes-example/example/example_0.1.bb:do_configure) failed with exit code '1'
NOTE: Tasks Summary: Attempted 658 tasks of which 657 didn't need to be rerun and 1 failed.

Summary: 1 task failed:
  /home/abcde/Data/yocto/kirkstone/build/meta-test/recipes-example/example/example_0.1.bb:do_configure
Summary: There was 1 ERROR message, returning a non-zero exit code.
nb.onb.o

It can be downloaded by adding FETCHCONTENT_FULLY_DISCONNECTED to example_0.1.bb.

EXTRA_OECMAKE:append = "-DFETCHCONTENT_FULLY_DISCONNECTED=OFF"
このスクラップは2022/05/06にクローズされました