SDK install w/ CMake
Hello,
we have got the problem that w/ the Yocto recipe and CMake install targets as below always everything (headers and library or binary respectively) is installed in the SDK. The binary also goes into the SDK even though we just add it to IMAGE_INSTALL based on a XILINX yocto build (rel-v2018.3).
For sure we only want headers to be installed when "<library_name>-dev" is added to TOOLCHAIN_TARGET_TASK_append and the binary should not be installed at all when it is just added to IMAGE_INSTALL.
For sure we studied Yocto and CMake recipes from other libraries where it works like pugixml but weren't able to figure out what's going wrong.
Yocto recipe
============
DESCRIPTION = "C++ reflection library"
SECTION = "libs"
LICENSE = "CLOSED"
SRCREV = "${AUTOREV}"
SRCBRANCH = "next"SRC_URI = "git://gitlab.company.de/psg/${PN}.git;branch=${SRCBRANCH};protocol=ssh"
DEPENDS = "catch2"
inherit cmake
S = "${WORKDIR}/git"
FILES_${PN}-dev += "${libdir}/cmake"
# The following are needed because the library is unversioned.
# See https://wiki.yoctoproject.org/wiki/TipsAndTricks/Packaging_Prebuilt_Libraries#Non-versioned_Libraries
SOLIBS = ".so"FILES_SOLIBSDEV = ""
CMake library install part
==========================
# Shared client library target. add_library(shared SHARED $<TARGET_OBJECTS:objects>) target_include_directories(shared PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
set_target_properties(shared
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY lib/shared
LIBRARY_OUTPUT_DIRECTORY lib/shared
RUNTIME_OUTPUT_DIRECTORY lib/shared
OUTPUT_NAME ${LIBRARY_NAME})
# Install target.
install(TARGETS shared static
EXPORT ${LIBRARY_NAME}-config
DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(DIRECTORY include/reflect DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(EXPORT ${LIBRARY_NAME}-config
NAMESPACE ${LIBRARY_NAME}-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${LIBRARY_NAME})CMake binary install part
=========================
install(TARGETS ${EXECUTABLE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
Many thanks for any hints
Eric
Hi Eric
I don't think your issue has something do to with CMake.
Quoted 7 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Eric Schwarz
Sent: Freitag, 1. Februar 2019 09:51
To: [email protected]
Subject: [yocto] SDK install w/ CMake
Quoted 7 lines
Hello,
we have got the problem that w/ the Yocto recipe and CMake install targets as below always everything (headers and library or binary respectively) is installed in the SDK.
The binary also goes into the SDK even though we just add it toIMAGE_INSTALLbased on a XILINX yocto build (rel-v2018.3).
I'm not sure I understand what you are trying to do. If you add something to IMAGE_INSTALL it gets installed to the target. That usually includes binaries and libraries.
If you only want libraries but not binaries it's probably best to split them into multiple packages as described in https://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html#package-splitting-dev-environment
This way you can have the binaries in a different package like ${PN}-tools.
Pascal
Quoted 78 lines
For sure we only want headers to be installed when "<library_name>-dev" is added to
TOOLCHAIN_TARGET_TASK_appendand the binary should not be installed at all when it is just added toIMAGE_INSTALL.For sure we studied Yocto and CMake recipes from other libraries where it works like pugixml but weren't able to figure out what's going wrong.
Yocto recipe
============DESCRIPTION = "C++ reflection library"
SECTION = "libs"
LICENSE = "CLOSED"SRCREV = "${AUTOREV}"
SRCBRANCH = "next"SRC_URI= "git://gitlab.company.de/psg/${PN}.git;branch=${SRCBRANCH};protocol=ssh"DEPENDS = "catch2"
inherit cmake
S = "${WORKDIR}/git"
FILES_${PN}-dev += "${libdir}/cmake"# The following are needed because the library is unversioned. # See
https://wiki.yoctoproject.org/wiki/TipsAndTricks/Packaging_Prebuilt_Librari
es#Non-versioned_Libraries
SOLIBS = ".so"FILES_SOLIBSDEV= ""CMake library install part
==========================# Shared client library target.
add_library(shared SHARED $<TARGET_OBJECTS:objects>)target_include_directories(shared PUBLIC$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
set_target_properties(shared
PROPERTIES ARCHIVE_OUTPUT_DIRECTORY lib/shared LIBRARY_OUTPUT_DIRECTORY lib/shared RUNTIME_OUTPUT_DIRECTORY lib/shared OUTPUT_NAME ${LIBRARY_NAME})
# Install target.
install(TARGETS shared staticEXPORT ${LIBRARY_NAME}-config DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(DIRECTORY include/reflect DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(EXPORT ${LIBRARY_NAME}-config NAMESPACE ${LIBRARY_NAME}- DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${LIBRARY_NAME})CMake binary install part
=========================install(TARGETS ${EXECUTABLE_NAME} DESTINATION
${CMAKE_INSTALL_BINDIR})Many thanks for any hints
Eric
--
_______________________________________________
yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/yocto
Hi Pascal
Quoted 1 line
I don't think your issue has something do to with CMake.
You are right IMHO. We checked again the pugixml installation behaviour and it turned out we are experiencing the same issue.
Quoted 6 lines
Quoted 5 lines
we have got the problem that w/ the Yocto recipe and CMake install targets as below always everything (headers and library or binary respectively) is installed in the SDK.
The binary also goes into the SDK even though we just add it toIMAGE_INSTALLbased on a XILINX yocto build (rel-v2018.3).
Quoted 7 lines
I'm not sure I understand what you are trying to do. If you add something to
IMAGE_INSTALLit gets installed to the target. That usually includes binaries and libraries.If you only want libraries but not binaries it's probably best to split them into multiple packages as described in https://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html#package-splitting-dev-environment
This way you can have the binaries in a different package like ${PN}-tools.
We have not figured out on how to add the build artifacts of the library to the the correct FILES_${PN} variables. It seems that the FILES_${PN} variables are also kind of overlayed [1].
a) We would like to see the *.so of the library only on the RootFS but the headers, the *.so and the *.a in the SDK.
b) We are trying to install a binary via FILES_${PN} but it also ends up in the SDK no matter what.
A colleague also posted the question on stackoverflow [2] which describes it more verbosely.
The Yocto release is rocko based.
Thanks
Eric
[1] https://stackoverflow.com/questions/35090669/bitbake-packaging-strangeness
[2] https://stackoverflow.com/q/54569314/10921299