[CMake] Dependency scanning for non-supported languages?

Alan W. Irwin irwin at beluga.phys.uvic.ca
Wed Dec 30 14:21:42 EST 2009


On 2009-12-30 10:42-0800 Talin wrote:

> I guess what I am asking is - if I modified my build script to generate a
> text file (Makefile, CMakeLists.txt or whatever) containing the
> dependencies, would CMake be able to use it? I know that with GNU makefiles
> there is a way to generate additional makefiles as part of the build process
> (although it is rather complex and clumsy), I wonder if CMake can support
> something similar?

Sorry for entering this conversation late, but I want to make the point that
you can essentially do anything related to builds that you like with CMake.
I presume (since your language is not officially supported by CMake) that
you are building libraries and executables with add_custom_command, and you
want some way to get the right file dependencies in the DEPENDS of that
add_custom_command.

Here is one way to do that.

At cmake time, you run execute_process to generate the file with
lists of dependent files, then use file(READ...) and string parsing to
create a CMake list variable containing those file dependencies.  Then
use that variable as the object of the add_custom_command DEPENDS, and
you are done.

Another way to do this that skips the file(READ...) and string parsing steps
is to have your external dependency generation script that you execute with
execute_process create a file that contains the single line of CMake logic,

set(LANGUAGE_DEPENDS depend1 depend2 ... dependn)

You then simply include that file and use

add_custom_command(... DEPENDS ${LANGUAGE_DEPENDS})

I hope these ideas help.

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
__________________________


More information about the CMake mailing list