On 2007-08-16 15:18+0100 Tim Schooley wrote:
-----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.
Hi Tim:
To address the CMake issue of where it expects to find files,
use full pathnames for all files, and drop the
WORKING_DIRECTORY. That is, do something like the following:
Add_Custom_Command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${DRIVER_FILE}
COMMAND ${KBUILD_CMD}
DEPENDS ${src} Kbuild VERBATIM )
Add_Custom_Target ( driver ALL DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/${DRIVER_FILE} )
Without the WORKING_DIRECTORY the external make command you access with
${CMAKE_MAKE_PROGRAM} should be issued from the ${CMAKE_CURRENT_BINARY_DIR}
directory (which I assume is identical to ${PROJECT_BINARY_DIR}/bin in your
above example. However, if the above does not work, you can be absolutely
specific by doing, e.g.,
Add_Custom_Command( OUTPUT ${CMAKE_BINARY_DIR}/bin/${DRIVER_FILE}
COMMAND ${KBUILD_CMD}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
DEPENDS ${src} Kbuild VERBATIM )
Add_Custom_Target ( driver ALL DEPENDS ${CMAKE_BINARY_DIR}/bin/${DRIVER_FILE} )
Anyhow, one of the two variations above should take care of the CMake
issues. That leaves the issue of where the external make command outputs
its files. I am guessing here that it will output the ${DRIVER_FILE} result
to ${CMAKE_BINARY_DIR}/bin/ or what I think is the equivalent
${CMAKE_CURRENT_BINARY_DIR}. If the external make programme does not
cooperate that way by default then you may have to try additional make
options to get it to do that or add a specific stanza to copy the output
file from make to the directory that you want.
Alan
__________________________
Alan W. Irwin
Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).
Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________
Linux-powered Science
__________________________
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake