[yocto] SDK install w/ CMake

Eric Schwarz eas at sw-optimization.com
Fri Feb 1 00:51:28 PST 2019


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


More information about the yocto mailing list