[yocto] out-of-tree module issues with cmake: CMAKE_SYSTEM_VERSION undefined within yocto build system

Brett R. Nicholas Brett.R.Nicholas.TH at dartmouth.edu
Fri Jun 30 12:45:19 PDT 2017


Hi there,


I'm trying to incorporate an out-of-tree kernel module alongside of a shared library and test program into my Yocto build. The project housing the module, library, and test needs to use Cmake.


My question: How can I make CMake aware of the target kernel source path (i.e. ${KERNEL_SRC} or ${KERNEL_STAGING_DIR} if I were using a makefile and inheriting the modules.bbclass)?


I ask because I get build failures when I incorporate the project into Yocto build system. Everything builds fine on the host machine outside of Yocto. However when I try and incorporate the project into Yocto, the build fails because the CMAKE_SYSTEM_VERSION variable (which I use to provide the path to the kernel source) is somehow unset by the Yocto build system.


I know the CMAKE_SYSTEM_VERSION variable is erased and causing the failure from comparing the error message (below) with my CMakeLists.txt


Yocto error message:

......

| make[3]: Entering directory '/home/brett/Thesis/Zynq_Linux/Yocto/wslinux/build/tmp/work/zedboard_zynq7-poky-linux-gnueabi/wssha256-kmod/0.1-r0/build/modules/wssha256kern'
| make[3]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
| make[3]: *** /lib/modules//build: No such file or directory.  Stop.

......



My CMakeLists.txt for the module is as follows:

SET( MODULE_NAME wssha256kern)
SET( MODULE_SOURCE_FILES ${MODULE_NAME}.c)
SET( MODULE_FILE ${MODULE_NAME}.ko)
SET( MODULE_OUTPUT_DIR ${CMAKE_BINARY_DIR}/modules/${MODULE_NAME})

SET( KERNEL_SRC "/lib/modules/${CMAKE_SYSTEM_VERSION}/build" ) # <----- THIS IS WHERE THE VARIABLE IS NEEDED!!!!!

SET( KBUILD_COMMAND ${CMAKE_MAKE_PROGRAM} -C ${KERNEL_SRC} M=${MODULE_OUTPUT_DIR} modules)

CONFIGURE_FILE( Kbuild.in ${MODULE_OUTPUT_DIR}/Kbuild)

FOREACH( MODULE_SOURCE_FILE ${MODULE_SOURCE_FILES} )
    CONFIGURE_FILE(
        ${MODULE_SOURCE_FILE}
        ${MODULE_OUTPUT_DIR}/${MODULE_SOURCE_FILE}
        COPYONLY
    )
ENDFOREACH( MODULE_SOURCE_FILE )

ADD_CUSTOM_COMMAND(
    OUTPUT ${MODULE_OUTPUT_DIR}/${MODULE_FILE}
    COMMAND ${KBUILD_COMMAND}
    WORKING_DIRECTORY ${MODULE_OUTPUT_DIR}
    DEPENDS ${MODULE_SOURCE_FILES} Kbuild.in
    VERBATIM
)

ADD_CUSTOM_TARGET(
    ${MODULE_NAME}
    ALL
    DEPENDS ${MODULE_OUTPUT_DIR}/${MODULE_FILE}
)


How can I pass the Yocto Kernel source location (for the target, not the host) to my project's CMake?


Thanks,

Brett

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20170630/f538cfe0/attachment.html>


More information about the yocto mailing list