Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cmake setup for yocto #290

Merged
merged 9 commits into from
Mar 23, 2020

Conversation

GertRozing
Copy link
Contributor

@GertRozing GertRozing commented Aug 26, 2019

The current cmake setup of the pigpio project was incompatible with a yocto build for the raspberry pi. For some reason it had problems finding standard header files like <stdio.h>. However the builds succeeded on non Yocto builds which reinforced my suspicion that the CMake setup was the cause.

Nevertheless I modernized the CMake setup, which now also builds in a yocto environment :D. The new CMake conforms with the current CMake 3.0 standard. As such the following features are available.

  • Usage of CMAKE_INSTALL_PREFIX instead of the custom DEST_DIR
  • Usage of CMAKE_BUILD_TYPE to determine Release/Debug or RelWithDebInfo builds.
  • Usage of CMake versioning system
  • Create a CMake importable package configuration for all configurations.
  • Create a CMake installer via CPack (build the package target)
  • Usage of dependency handling via CMake target architecture (no more add_dependencies)
  • Finding of external dependencies via CMake (CMake will raise an error if -lpthread or -lrt are not present on the system)
  • Moved the option like option (BUILD_SHARED_LIBS) to an actual option (default is ON).
  • Removed the uninstall target (CMake tracks all install commands and provides an uninstall target, however this is not compatible with the custom python module setup.py)

I wrote these enhancements for our own raspberry pi yocto builds, which require pigpio. We used to use WiringPi, however that project got disbanded by the maintainer himself, which is sad. Nevertheless the pigpio project works equally amazing.

@joan2937
Copy link
Owner

joan2937 commented Aug 26, 2019

I have no knowledge or experience of using cmake so can not judge the merits of this request.

That said, I am happy to accept this as long as no one objects within a few days.

@deets
Copy link

deets commented Mar 8, 2020

I would like to second this issue, I was hunting down this for a couple of hours today for my own yocto build until I solved it myself with a patch. It would be great if this was merged.

@guymcswain
Copy link
Collaborator

I'll try to include this in the next release sometime in March.

@guymcswain guymcswain mentioned this pull request Mar 23, 2020
@guymcswain guymcswain merged commit 9f22d94 into joan2937:master Mar 23, 2020
@novalisek
Copy link

@GertRozing Do you have pigpio recipe which works with this PR? coud you share it? I would like to add pigpio to my yocto build. Thank you.

@dir-ableton
Copy link

I have this recipe. It comes with it's own patch to prevent the issue here, but you can now of course just ditch that. It is also not very sophisticated, but it gets you going.

DESCRIPTION = "pigpio "
SECTION = "devtools"
LICENSE = "CLOSED"
LIC_FILES_CHKSUM = "file://UNLICENCE"

FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"

SRC_URI = "git://github.com/joan2937/pigpio.git;protocol=https;tag=${PV}\
    file://0001-Fix-CFLAGS-so-cross-compilation-in-YOCTO-works.patch\
    file://pigpiod.sh\
    "

S = "${WORKDIR}/git"

inherit pkgconfig cmake update-rc.d

RDEPENDS_${PN} = "python3"

FILES_${PN} += "${bindir}/pigpiod\
    ${libdir}/libpigpio.so\
    ${libdir}/libpigpiod_if.so\
    ${libdir}/libpigpiod_if2.so\
    ${libdir}/python3.7/site-packages/pigpio.py\
"

FILES_${PN}-dev = "${includedir}"

INITSCRIPT_NAME = "pigpiod"
INITSCRIPT_PARAMS = "start 01 5 3 2 . stop 99 0 1 6 ."

do_install() {
    install -d ${D}${bindir}
    install -d ${D}${libdir}
    install -d ${D}${libdir}/python3.7/site-packages

    install -m 0755 pigpiod ${D}${bindir}
    install -m 0755 libpigpio.so ${D}${libdir}
    install -m 0755 libpigpiod_if.so ${D}${libdir}
    install -m 0755 libpigpiod_if2.so ${D}${libdir}
    install -m 0644 ${S}/pigpio.py ${D}${libdir}/python3.7/site-packages

    install -d ${D}${sysconfdir}/init.d
    install -m 0755 ${WORKDIR}/pigpiod.sh ${D}${sysconfdir}/init.d/pigpiod
}

@novalisek
Copy link

@dir-ableton thanks, I will give it a try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants