12

I am trying to build an yocto image with my own package. I have OpenCV code on github which uses cmake.

I trying to write a recipe for it and facing lot of errors. Can any one give some hints on what functions or parameters to include in my recipe. My recipe looks as following

DESCRIPTION = "cameracapture application" 
SECTION = "examples" 
LICENSE = "CLOSED" 
PR = "r0" 

DEPENDS += "opencv"

SRC_URI = "git://https://github.com/zafrullahsyed/cameracapture.git;protocol=https;tag=v0.1"

EXTRA_OECMAKE=""

do_configure() { 
 cmake ../ 
} 

inherit pkgconfig cmake

I followed these tutorials to write my recipe with cmake but in vain: Bitbake Player recipe

Cmake-Bitbake-QT

Zafrullah Syed
  • 1,170
  • 2
  • 15
  • 38

3 Answers3

19

The correct way of writing own recipes with cmake as follows:

DESCRIPTION = "cameracapture application" 
SECTION = "examples" 
LICENSE = "CLOSED" 
PR = "r0" 

DEPENDS = "opencv"

SRC_URI = "git://github.com/zafrullahsyed/cameracapture.git;protocol=https;tag=v0.1"

S = "${WORKDIR}/git"

inherit pkgconfig cmake

do_install() {
    install -d ${D}${bindir}
    install -m 0755 cameracapture ${D}${bindir}
}

Previously I didn't add do_install that's the reason yocto downloads the recipe but unable to include it Image.

Zafrullah Syed
  • 1,170
  • 2
  • 15
  • 38
19

If the CMakeLists.txt uses the install command then bitbake will do the install for you and you won't need to define you own do_install.

install(TARGETS cameracapture DESTINATION bin)
elmsfu
  • 229
  • 2
  • 3
  • do you means there is no need to add `do_install()` in the recipe? – hukeping Jul 29 '19 at 08:49
  • @hukeping You don't have to add do_install() task. install instruction as pointed in answer has to be added in CMakeLists.txt. do_install() from cmake base class will make use of "make install". – chandola Jan 02 '21 at 12:40
5

add the source directory in your recipe.

example S = "${WORKDIR}/cameracapture

S is the source code path where your CMakeList.txt.

any how your are inheriting the cmake bbclass in your recipe, so it will take care of all configure , compile and install functionalities.

after doing this you can remove you do_configure function in the above recipe also.

you can add your make options if any to the below macro (as you kept empty). example

EXTRA_OECMAKE = "all"

vinay hunachyal
  • 3,781
  • 2
  • 20
  • 31
  • 1
    can you explain me about do_install. I too have the similar kind of problem while installing binaries. please see the below question. http://stackoverflow.com/questions/18508048/do-install-error-while-running-custom-bitbake-in-poky-build – Pala Aug 29 '13 at 12:15