[CMake] Building linux kernel module with Cmake

Suhas Jain suhasj at aftek.com
Fri Nov 2 07:40:23 EDT 2007


As you said I am using these ADD_CUSTOM_COMMAND / ADD_CUSTOM_TARGET
But its not working at my end... please help me out
This is what I have in my CMakeLists.txt file
===========================================================================
Set( MODULE_OUTPUT_FILES    hello.o
                            hello.mod.c
                            hello.mod.o
                            hello.ko
                            .hello.o.cmd
                            .hello.ko.cmd
                            .hello.mod.o.cmd
				    main.o
				    .main.o.cmd
				    output.o
				    output.o.cmd
                            .tmp_versions/hello.mod
                            .tmp_versions/ )

Set( MODULE_SOURCE_FILES    output.c 
				    main.c )

Set( DRIVER_FILE        hello.ko )
Set( DRIVER_TARGET_NAME hello-module )
Set( DRIVER_BIN_FILE    ${CMAKE_BINARY_DIR}/bin/${DRIVER_FILE} )
Set( MODULE_SOURCE_DIR  ${CMAKE_CURRENT_BINARY_DIR} )

Set( KERNEL_DIR "/lib/modules/2.6.20-16-generic/build" )
Set( KBUILD_CMD ${CMAKE_MAKE_PROGRAM}
                -C ${KERNEL_DIR}
                M=${MODULE_SOURCE_DIR}
                modules )
=========================================================================

Please point me out if I am doing something wrong. I think I am missing
something to add.




-----Original Message-----
From: cmake-bounces+suhasj=aftek.com at cmake.org
[mailto:cmake-bounces+suhasj=aftek.com at cmake.org] On Behalf Of Brandon Van
Every
Sent: Friday, November 02, 2007 12:08 AM
To: cmake at cmake.org
Subject: Re: [CMake] Building linux kernel module with Cmake

On Nov 1, 2007 5:48 AM, Suhas Jain <suhasj at aftek.com> wrote:
> Thanks for you reply Hendrik
> Even I know that Kbuild is a very simple procedure to do so.
> But I have a source tree which has applications, drivers and other modules
> for different OS as well as hardware architectures and I want to compile
all
> these folders from a single top level directory. All this can be achieved
> with Cmake utlity. I have already compiled other modules.
> I want to know if it possible to use cmake for compiling kernel module

It would be simpler to use ADD_CUSTOM_COMMAND / ADD_CUSTOM_TARGET to
invoke the Linux kernel's native Kbuild, then utilize the results.


Cheers,
Brandon Van Every
_______________________________________________
CMake mailing list
CMake at cmake.org
http://www.cmake.org/mailman/listinfo/cmake





More information about the CMake mailing list