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

Jack Kelly endgame.dos at gmail.com
Thu Aug 16 10:49:34 EDT 2007


Tim Schooley wrote:
>> Unfortunately, that's right, but at least "make pristine" or "make
>> mrproper" is somewhat conventional as a "cleaner-than-clean" target.
> 
> True. I should probably do this, as I'm sure there will be other outputs
> that need manual cleaning (doxygen stuff and test result files).

If your macros for processing this stuff are smart enough, the source 
directory should be clean if you build outside of the source tree.

>> The cleanliness of the source tree is irrelevant if you do an out of
>> tree build, though, isn't it?
> Well, for building the kernel module, you need to pass the module source
> directory as a parameter to the Makefile found in the
> /lib/modules/XXX/build directory. The build then leaves the source tree
> unclean. Is there a way of forcing CMake to copy the whole module
> sources to the out-of-source build directory and invoke from there ?

I think you could do this with EXEC_PROGRAM (or its newer, more powerful 
sibling EXECUTE_PROCESS. Both get called as CMakeLists.txt is getting 
processed rather than at make time) and cmake -E copy_directory, and 
then do all your building in the build directory. Test if you need to 
copy with something like IF(${CMAKE_SOURCE_DIR} STREQUAL 
${CMAKE_BINARY_DIR}), perhaps?

-- Jack


More information about the CMake mailing list