问题
I created a new layer over an existing Yocto git for my company project.
In this layer I added a few external autotools
based libraries.
A few applications need to link against this libraries and the application projects are all cmake
based.
Taking one of this libraries (e.g. 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.
回答1:
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:
- Add
FindFoo.cmake
to your layer (into thefiles
directory next to your recipe). - Add that cmake file to
SRC_URI
(i.e.SRC_URI += "file://FindFoo.cmake"
). - Install it in
do_install
into the directory${D}${datadir}/cmake/Modules/
for example. - 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:
- libeigen
- opencv
- json-spirit
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.)
来源:https://stackoverflow.com/questions/52063591/how-to-deploy-a-find-cmake-file-for-an-autotools-library-in-the-correct-place-f