Search code examples
cmakeyoctobitbake

cmake with bitbake and specific install directory


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?


Solution

  • 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.