[Cmake] out of source builds

Brad King brad.king at kitware.com
Tue Aug 3 15:47:57 EDT 2004


David Somers wrote:
> In MSVC, I have a custom build which does the following (and is dependent
> upon the three files$(InputDir)/doc/fonts.style, $(InputDir)/doc/page.style,
> $(InputDir)/doc/cxref.style) and simply outputs $(InputDir)\latex-style.c:
> 
> echo /** The style files needed for LaTeX. **/ >  $(InputDir)\latex-style.c
> echo.                                          >> $(InputDir)\latex-style.c
> echo /*+ The fonts style file as a string. +*/ >> $(InputDir)\latex-style.c
> echo char *latex_fonts_style=                  >> $(InputDir)\latex-style.c
> sed "s/\\/\\\\/g" $(InputDir)/doc/fonts.style | gawk
> "{print\"\\\"\"$0\"\\n\\\"\"}" >> $(InputDir)\latex-style.c
[snip]
> echo Created $(InputDir)\latex-style.c
> 
> Trying to put all those commands in as a chain of custom build statements
> seems overkill... so the ability to have a custom command run a series of
> commands would be ideal :-)

It's probably not too hard to implement.  Please add this as a feature 
request here:

http://www.cmake.org/Bug

I do not know when we will be able to get to this, but you will 
automatically be notified of progress when we do.

>  So as I previously said, I think the only way to
> do this in cmake would be to get the custom command to call a batch file to
> do all the above.

You could write a program in C or C++ to do all these operations to 
generate the file instead of depending on programs like "sed" and "gawk" 
being installed on the machine and in the path.  Then just run this 
single program as the custom command.  If you add the executable as a 
dependency, then CMake will setup proper rules to make sure the 
generator executable is built before this custom rule is executed.

-Brad



More information about the Cmake mailing list