3

I have an issue with installing my target to a specific directory by use of cmake managed build and bitbake (yocto).

At CMakeLists.txt, I want to use the install() section to deploy my target to the specific directory e.g. /my/specific/directory.

At CMakeLists.txt this looks like:
install(TARGETS "${PROJECT_NAME}" RUNTIME DESTINATION my/specific/directory).
So, there would be no need at the bitbake recipe to implement an install section.

By default, the cmake uses a prefix which derives from bitbake.conf and points to /usr. Therefore my target is installed to /usr/my/specific/directory.

At cmake documentation I have found to possibilities to modify the prefix:

  • Set the environment variable DESTDIR to overwrite the prefix
  • use cmake --install . --prefix /my/install/prefix

In both cases I have no idea, how I have to implement this at the bitbake recipe that this would have an effect, when the do_install task is executed.

Has anyone of you a hint here?

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
RScAut
  • 33
  • 6
  • meta-note: @tsyvarev I used to link to the "no thanks damnit" meta post too, but I switched to using https://meta.stackexchange.com/a/131011/997587. it covers more ground and gets the same point across. – starball May 11 '23 at 07:53
  • In your bitbake recipe you should be able to set [EXTRA_OECMAKE](https://docs.yoctoproject.org/ref-manual/variables.html?highlight=extra_oecmake#term-EXTRA_OECMAKE) to pass options to cmake e.g. `EXTRA_OECMAKE= "--install-prefix /mydir"`. – 0RR May 11 '23 at 08:30
  • By doing so, it is deployed to the correct directory on the build system, but it is not deployed to the target by yocto: `ERROR: -1.0-r0 do_package: QA Issue: -cmake: Files/directories were installed but not shipped in any package: /my/specific/directory/my-app`. This is not the case, if the default prefix is used. – RScAut May 11 '23 at 09:02
  • Maybe try `FILES:${PN} = /my/specific/directory/my-app` [see here](https://stackoverflow.com/questions/49748528/yocto-files-directories-were-installed-but-not-shipped-in-any-package) Either it will be `FILES_${PN}` or `FILES:${PN}` based on which yocto version you are using – 0RR May 11 '23 at 09:18
  • 1
    Yes, this works. I am wondering, why this is not necessary, when I use the default prefix. But for the moment it works! – RScAut May 11 '23 at 09:34
  • I'm glad it helped, I will add it as an answer. I am still learning with Yocto, but I have found the IRC channel at #yocto to be quite helpful – 0RR May 11 '23 at 09:44

1 Answers1

3

In your bitbake recipe you should be able to set EXTRA_OECMAKE to pass options to cmake e.g. EXTRA_OECMAKE= "--install-prefix /mydir".

But then with errors regarding Files/directories were installed but not shipped in any package: you can set bitbake to install the files by using:

FILES:${PN} = "/mydir"

(Or FILES_${PN} for older versions of Yocto). See here.

There may be other ways to achieve the same thing, the #yocto IRC channel can be quite helpful I find.

0RR
  • 1,538
  • 10
  • 21