如何在适用于Yocto的正确位置为Autotools库部署Find * .cmake文件? [英] How to deploy a Find*.cmake file for an Autotools library in the correct place for Yocto?

查看:297
本文介绍了如何在适用于Yocto的正确位置为Autotools库部署Find * .cmake文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为公司项目在现有Yocto git上创建了一个新层.

在这一层中,我添加了一些基于外部autotools的库. 一些应用程序需要链接到该库,并且应用程序项目均基于cmake.

使用其中一个库(例如 libcoap ),我可以轻松地找到一些

谢谢.

要将FindFoo.cmake与尚未完成的cmake项目一起交付

理想的方法是更新上游项目本身.因此,您将适当地更新配方并打包FindFoo.cmake.

如果您现在想这样做:

  1. FindFoo.cmake添加到您的图层中(到配方旁边的files目录中.)
  2. 将该cmake文件添加到SRC_URI(即SRC_URI += "file://FindFoo.cmake").
  3. 例如,将其安装在do_install中的目录${D}${datadir}/cmake/Modules/中.
  4. 通过FILES_${PN}-dev变量将其打包到dev软件包中(请参见下面的示例配方).

要通过其他食谱使用该cmake

通常的方法是将.cmake文件打包到${PN}-dev软件包中.在您的情况下,您的应用程序(取决于libcoap)将只设置DEPENDS = "libcoap",并且所有需要的文件(例如标头,库和cmake文件)都将被复制(以及硬链接)到应用程序的sysroot.

CMake模块包装在各种配方中,例如:

您的应用程序基于cmake,因此您将在配方中使用inherit cmake.本机模块搜索路径在 cmake中设置.bbclass .

(顺便说一句,我对libcoap) I could easily find some FindCoAP.cmake to add to my library recipe.

Now if I was running on PC, it would simply be a matter of placing this FindCoAP.cmake file in cmake's ${CMAKE_ROOT}/Modules dir, but how should I, from inside a bitbake recipe (do_install hook), proceed to make my Find*.cmake modules available to anyone's dependent projects?

Should I try to get Yocto's cmake CMAKE_ROOT variable from system-information like this or is it a safer and more reliable way?

do_install_append() {
    cmake --system-information | grep CMAKE_ROOT | cut -d \" -f2
    install -d ${D}/$CMAKE_ROOT}/Modules
    install ${S}/FindCoAP.cmake ${D}/$CMAKE_ROOT}/Modules
}

Thanks in advance.

解决方案

To ship FindFoo.cmake with non-yet-cmake project

The ideal way is to update upstream project itself. So you will update your recipe and package FindFoo.cmake appropriately.

If you want to do it right now:

  1. Add FindFoo.cmake to your layer (into the files directory next to your recipe).
  2. Add that cmake file to SRC_URI (i.e. SRC_URI += "file://FindFoo.cmake").
  3. Install it in do_install into the directory ${D}${datadir}/cmake/Modules/ for example.
  4. Package it to the dev package by FILES_${PN}-dev variable (see example recipes below).

To use that cmake by other recipe

The usual way is to package .cmake files into the ${PN}-dev package. In your case, your application (which depends on the libcoap) will just set DEPENDS = "libcoap" and all the needed files (like headers, libraries and cmake file) will be copied (well, hardlinked) to the sysroot of your application.

CMake modules are packaged in various recipes for example:

Your application is cmake based, so you will use inherit cmake in the recipe. Native module search path is set in cmake.bbclass.

(BTW, I do a build test of libcoap recipe from homeassistant layer and it worked, but obviously there is no cmake shipped.)

这篇关于如何在适用于Yocto的正确位置为Autotools库部署Find * .cmake文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆