[CMake] linux kernel module, output directory and clean issues

Tim Schooley tim at sbdev.net
Thu Aug 16 10:18:53 EDT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all!

[My first post, please bear with me...]

I've been porting a Makefile project to use CMake. Thankfully, it's gone
very smoothly, and now I'm just trying to iron out some ripples. CMake
truly rocks.

I found some advice on this mailing list for building linux kernel
modules, and I'm using the following for it:

- ---

Set( DRIVER_FILE mydriver.ko )
Set( KERNEL_DIR "/lib/modules/${CMAKE_SYSTEM_VERSION}/build" )
Set( KBUILD_CMD ${CMAKE_MAKE_PROGRAM}
                -C ${KERNEL_DIR}
                M=${CMAKE_CURRENT_SOURCE_DIR} modules)

Add_Custom_Command( OUTPUT ${DRIVER_FILE}
                    COMMAND ${KBUILD_CMD}
                    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
                    DEPENDS ${src} Kbuild VERBATIM )

Add_Custom_Target ( driver ALL DEPENDS ${DRIVER_FILE} )

- ---

My issue is this: no matter how I specify the output, I cannot for the
life of me get the mydriver.ko file to be outputted to the
${PROJECT_BINARY_DIR}/bin directory. I've searched around for similar
issues/code, but come to a dead end.

My second problem: I'm aware that you currently cant add custom commands
to the "clean" target, but is there _any_ way of cleaning up the kernel
module source directory when "clean" is called, even if it's a slightly
nasty hack ?

Thanks for any help/advice/pointers.

Kind regards,

Tim
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGxFzNChPkLPgrpHQRAsovAJ9eA0N0Wr3b6UEs94CDH1PpYR3tXQCgpHGa
0OWqH24nwiohpA2YXenDX00=
=Ue7F
-----END PGP SIGNATURE-----



More information about the CMake mailing list