[CMake] REGEX for CONFIGURE_FILE

Alexander Neundorf a.neundorf-work at gmx.net
Thu Jun 8 05:06:52 EDT 2006


Hi,

> Von: "Brandon J. Van Every" <bvanevery at gmail.com>
> 
> I have a file csc.scm.in that I cannot change because 2 other build 
> systems depend on it.  It has variables of the form %BLAH_BLAH% that 
> need to be substituted.  I can't change them to @BLAH_BLAH@ or 
> ${BLAH_BLAH}.  I'm not sure if there's a Scheme preprocessor facility I 
> could use to get around this; I definitely can't use the usual C 
> preprocessor #ifdef tricks as it's all Scheme code.  I don't know that 
> polluting the code would go over well anyways.
> 
> 1 build system simply copies the file from csc.scm.in to csc.scm 
> unchanged.  This is the extremely dumb vcbuild.bat system, which is 
> meant to run in a tools-poor Windows enviornment.  It's brain dead but 
> it works.
> 
> The 2nd build system is a ./configure Makefile.am getup.  It performs 
> sed substitutions on csc.scm.in to generate csc.scm.  Since it has full 
> regex capabilities it doesn't care that the substitution convention is 
> %BLAH_BLAH%.  It also worries about escaping quotes in various places.
> 
> So now with CMake my options with CONFIGURE_FILE are exceedingly 
> limited.  Really I can't do it that way.
> 
> I've learned about ${CMAKE_COMMAND} -P scripting.  There are no input 
> parameters and no internal variables are retained from the calling 
> CMake.  All it "knows" is the directory in which it was called, as 
> either ${CMAKE_SOURCE_DIR} or ${CMAKE_BINARY_DIR}.  They're both the 
> same thing.  Apparently the CVS version has a -D option that works in 
> conjunction with -P, but I need this to work with straight 2.4.2. I 
> tried various permutations of -P -DMYVAR:STRING=myfilename.scm and it 
> doesn't work.  

There must be something you are doing wrong. This work and it does that already since quite some time, so definitely in 2.4.2.
You could have a look at KDE4Macros.cmake (macro KDE4_ADD_UI_FILES) and kde4uic.cmake in KDE svn, which do just that.
In kde4uic.cmake a generated source file is read and stuff is replaced using STRING(REGEX REPLACE ...)

Bye
Alex

-- 


Echte DSL-Flatrate dauerhaft für 0,- Euro*!
"Feel free" mit GMX DSL! http://www.gmx.net/de/go/dsl


More information about the CMake mailing list