Hi Jakob,

On Mon, May 29, 2017 at 6:29 PM, Jakob Hasse
<jakob.ha...@smart-home-technology.ch> wrote:
> Hello,
>
> I have two issues:
>
> 1.
> I innocently tried to include an open source version of the ST Link tools
> (https://github.com/texane/stlink) into my yocto image.
> I created a recipe fetching from git and got the error:
>
> | CMake Error at CMakeLists.txt:105 (install):
> |   install TARGETS given unknown argument "/lib".
> |
> |
> | CMake Error at CMakeLists.txt:135 (install):
> |   install TARGETS given unknown argument "/lib".
> |
> |
> | CMake Error at usr/lib/pkgconfig/CMakeLists.txt:12 (install):
> |   install FILES given unknown argument "/lib/pkgconfig/".
> |
> |
> | CMake Error at include/CMakeLists.txt:9 (install):
> |   install FILES given unknown argument "/lib".
> |
> |
> | CMake Error at include/CMakeLists.txt:12 (install):
> |   install FILES given unknown argument "/lib/stlink".
>
> I'm not sure whether it's a CMake problem since the project compiles
> absolutely fine on my host machine with native target (the binary also works
> fine in my case).
> Also, the CMake error log shows me errors about unrecognized CFlags
> (-Wmissing-variable-declarations, -Wshorten-64-to-32) which confuse me
> somewhat given the errors above.
> Then I checked out the source and changed the CMake file to exclude
> corresponding flags - with no difference, errors still remain.
> My recipe now looks like this:
>
> # comment
> SUMMARY = "ST-Link firmware flasher"
> DESCRIPTION = ""
> SECTION = "examples"
> LICENSE = "MIT"
> LIC_FILES_CHKSUM =
> "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
>
> DEPENDS = "libusb pkgconfig"
>
> SRC_URI = "file://stlink.tar.gz"
Why don't use git protocol instead of link to fetched sources?
>
> FILES_${PN} += "${bindir}/st-flash"
>
> S = "${WORKDIR}/git"
Here is my updated recipe:

# comment
SUMMARY = "ST-Link firmware flasher"
DESCRIPTION = ""
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM =
"file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

DEPENDS = "libusb pkgconfig"

SRCREV = "55c057296ad15fa6de9909206098bd4eed8f6311"

PV = "1.3.1+git${SRCPV}"

SRC_URI = "git://github.com/texane/stlink.git"

SRC_URI[md5sum] = "99fa2b1de041f62b7285a8f1870c891b"
SRC_URI[sha256sum] =
"8545752efe2be13c6dbadec48c93cd72be448147f38f0fe44050c0416827ca37"

S = "${WORKDIR}/git"

inherit cmake

Also it is necessary to patch a stlink before to pass configuration phase like:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index afa7fde..4d2db6c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,9 +1,10 @@
 cmake_minimum_required(VERSION 2.8.7)
 project(stlink C)
+SET(CMAKE_INSTALL_PREFIX /usr/)
 set(PROJECT_DESCRIPTION "Open source version of the
STMicroelectronics Stlink Tools")
 set(STLINK_UDEV_RULES_DIR "/etc/udev/rules.d" CACHE PATH "Udev rules
directory")
 set(STLINK_MODPROBED_DIR "/etc/modprobe.d" CACHE PATH "modprobe.d directory")
-set(STLINK_LIBRARY_PATH "lib/${CMAKE_LIBRARY_PATH}" CACHE PATH
"Target lib directory")
+set(STLINK_LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH
"Target lib directory")

 option(STLINK_GENERATE_MANPAGES "Generate manpages with pandoc" OFF)

diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 0b5a443..e0851e4 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -2,13 +2,16 @@ configure_file(
        "${PROJECT_SOURCE_DIR}/include/stlink/version.h.in"
        "${CMAKE_BINARY_DIR}/include/stlink/version.h"
 )
+
+SET(CMAKE_INSTALL_PREFIX /usr/)
+
 file(GLOB STLINK_HEADERS
        "stlink/*.h"
        "${CMAKE_BINARY_DIR}/include/stlink/*.h"
 )
 install(FILES ${CMAKE_SOURCE_DIR}/include/stlink.h
-       DESTINATION include/${CMAKE_LIBRARY_PATH}
+       DESTINATION
"${CMAKE_INSTALL_PREFIX}/include/${CMAKE_LIBRARY_PATH}/stlink"
 )
 install(FILES ${STLINK_HEADERS}
-       DESTINATION include/${CMAKE_LIBRARY_PATH}/stlink
+       DESTINATION
"${CMAKE_INSTALL_PREFIX}/include/${CMAKE_LIBRARY_PATH}/stlink"
 )

Then it still fails to compile but I tried to compile it for arm so
maybe this is the reason. Hope it helps a bit ;).

>
> inherit cmake
>
> 2.
> For the last step I had to repack a tar.gz out of the checked out source
> folder, otherwise bitbake complained.
> Is it possible to base a yocto package on a local source folder using
> autotools or cmake class?. All the examples I found either use remote git
> repos + autotools/cmake or a local source folder without autotools/cmake.
>
> Cheers and many thanks in advance,
> Jakob
>
> --
> Jakob Hasse
> Software Developement
>
> E: jakob.ha...@smart-home-technology.ch
> T: +41 44 552 02 66
>
> Smart Home Technology GmbH
> www.smart-home-technology.ch
>
> --
> _______________________________________________
> yocto mailing list
> yocto@yoctoproject.org
> https://lists.yoctoproject.org/listinfo/yocto

BR,

marek

-- 
as simple and primitive as possible
-------------------------------------------------
Marek Belisko - OPEN-NANDRA
Freelance Developer

Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
twitter: #opennandra
web: http://open-nandra.com
-- 
_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto

Reply via email to