<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7651.59">
<TITLE>RE: [CMake] @MY_VAR@ are replaced by empty string !</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<BR>
<BR>
<BR>
<BR>
<BR>

<P><FONT SIZE=2>-----Original Message-----<BR>
From: Bill Hoffman [<A HREF="mailto:bill.hoffman@kitware.com">mailto:bill.hoffman@kitware.com</A>]<BR>
Sent: Thu 2/14/2008 2:45 PM<BR>
To: Martin Lütken; cmake<BR>
Subject: Re: [CMake] @MY_VAR@ are replaced by empty string !<BR>
<BR>
Martin Lütken wrote:<BR>
&gt;<BR>
&gt;<BR>
&gt;<BR>
&gt;<BR>
&gt;<BR>
&gt; -----Original Message-----<BR>
&gt; From: Bill Hoffman [<A HREF="mailto:bill.hoffman@kitware.com">mailto:bill.hoffman@kitware.com</A>]<BR>
&gt; Sent: Wed 2/13/2008 7:50 PM<BR>
&gt; To: Martin Lütken<BR>
&gt; Cc: cmake@cmake.org<BR>
&gt; Subject: Re: [CMake] @MY_VAR@ are replaced by empty string !<BR>
&gt;<BR>
&gt; Martin Lütken wrote:<BR>
&gt;&nbsp; &gt; SHORT:<BR>
&gt;&nbsp; &gt; It's seems impossible to contruct a string containing something like<BR>
&gt; this:<BR>
&gt;&nbsp; &gt; &quot;@MY_VAR@&quot;. The whole thing gets replaced by an empty string regardless<BR>
&gt;&nbsp; &gt; whether<BR>
&gt;&nbsp; &gt; the MY_VAR variable is set or not. It is possible to create a string<BR>
&gt;&nbsp; &gt; like &quot;@ MY_VAR@&quot;,<BR>
&gt;&nbsp; &gt; but that is not quite the same.<BR>
&gt;&nbsp; &gt;<BR>
&gt;&nbsp; &gt;<BR>
&gt;&nbsp; &gt; ACTUAL PROBLEM DESCRIPTION:<BR>
&gt;&nbsp; &gt; I am trying to create cmake files for Gtk+ and asssociated libs among<BR>
&gt;&nbsp; &gt; those Pango!<BR>
&gt;&nbsp; &gt;<BR>
&gt;&nbsp; &gt; In order to run the glib-mkenums perl script from CMake I need to be<BR>
&gt;&nbsp; &gt; able to contruct<BR>
&gt;&nbsp; &gt; a custom command with strings containing the above &quot;@MY_VAR@&quot; construct<BR>
&gt;&nbsp; &gt; which the script<BR>
&gt;&nbsp; &gt; uses in a similar fashion as CMake does in it's CONFIGURE_FILE command.<BR>
&gt;&nbsp; &gt;<BR>
&gt;&nbsp; &gt; Any suggestions? Or do I need to file a bug-report ?<BR>
&gt;&nbsp; &gt;<BR>
&gt;<BR>
&gt; Can you use COPY_ONLY?&nbsp; Or do you need to configure some variables in<BR>
&gt; the file, just not all of them?<BR>
&gt;<BR>
&gt; Actually I need that as part of running a CUSTOM_COMMAND. So I need to<BR>
&gt; construct parameters like that<BR>
&gt; for a perlscript that creates c-source code from a bunch of header files.<BR>
&gt;<BR>
<BR>
I still don't get it...&nbsp;&nbsp; You want to run a perl script from a custom<BR>
command, that much I get...&nbsp; However, I don't know why it needs to be<BR>
configured?<BR>
<BR>
-Bill<BR>
<BR>
<BR>
Hi again I might have figured most of it out now. I learned from another posting here that I should not quote the commands.<BR>
That helped and after a lot of &quot;escaping&quot; it allmost works! Now I just seem to have a problem with the WORKING_DIRECTORY which seems to be ignored completely! I am using CMake version &quot;2.4-patch 7&quot;.<BR>
<BR>
--- My original makefile was like this: ---<BR>
<BR>
( cd $(srcdir) &amp;&amp; $(GLIB_MKENUMS) \<BR>
&nbsp; --fhead &quot;#undef GTK_DISABLE_DEPRECATED\n#define GTK_ENABLE_BROKEN\n#include \&quot;gtk.h\&quot;\n#include \&quot;gtkprivate.h\&quot;\n#include \&quot;gtkalias.h\&quot;\n&quot; \<BR>
&nbsp; --ftail &quot;#define __GTK_TYPE_BUILTINS_C__\n#include \&quot;gtkaliasdef.c\&quot;\n&quot; \<BR>
&nbsp; --fprod &quot;\n/* enumerations from \&quot;@filename@\&quot; */&quot; \<BR>
&nbsp; --vhead &quot;GType\n@enum_name@_get_type (void)\n{\n&nbsp; static GType etype = 0;\n&nbsp; if (etype == 0) {\n&nbsp;&nbsp;&nbsp; static const G@Type@Value values[] = {&quot; \<BR>
&nbsp; --vprod &quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { @VALUENAME@, \&quot;@VALUENAME@\&quot;, \&quot;@valuenick@\&quot; },&quot; \<BR>
&nbsp; --vtail &quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { 0, NULL, NULL }\n&nbsp;&nbsp;&nbsp; };\n&nbsp;&nbsp;&nbsp; etype = g_@type@_register_static (g_intern_static_string (\&quot;@EnumName@\&quot;), values);\n&nbsp; }\n&nbsp; return etype;\n}\n&quot; \<BR>
&nbsp; $(gtk_public_h_sources) ) gtktypebuiltins.c&nbsp;<BR>
<BR>
<BR>
--- And I got it transformed to: ---<BR>
<BR>
ADD_CUSTOM_TARGET ( gtkMkEnumsTarget ALL echo &quot;Creating ....&quot; )<BR>
SET ( type&nbsp; )<BR>
SET ( outFileName &quot;gtktypebuiltins&quot; )<BR>
ADD_CUSTOM_COMMAND(<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/${outFileName}.c<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SOURCE gtk.symbols<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMAND&nbsp; ${glib-mkenums_EXECUTABLE} --fhead \&quot;\#undef GTK_DISABLE_DEPRECATED\\n\#define GTK_ENABLE_BROKEN\\n\#include \\&quot;gtk.h\\&quot;\\n\#include \\&quot;gtkprivate.h\\&quot;\\n\#include \\&quot;gtkalias.h\\&quot;\\n\&quot; --ftail \&quot;\#define __GTK_TYPE_BUILTINS_C__\\n\#include \\&quot;gtkaliasdef.c\\&quot;\\n\&quot; --fprod \&quot;\\n/* enumerations from \\&quot;@filename@\\&quot; */\&quot; --vhead \&quot;GType\\n@enum_name@_get_type \(void\)\\n{\\n&nbsp; static GType etype = 0;\\n&nbsp; if \(etype == 0\) {\\n&nbsp;&nbsp;&nbsp; static const G@Type@Value values[] = {\&quot; --vprod \&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { @VALUENAME@, \\&quot;@VALUENAME@\\&quot;, \\&quot;@valuenick@\\&quot; },\&quot; --vtail \&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { 0, NULL, NULL }\\n&nbsp;&nbsp;&nbsp; };\\n&nbsp;&nbsp;&nbsp; etype = g_@type@_register_static \(g_intern_static_string \(\\&quot;@EnumName@\\&quot;\), values\);\\n&nbsp; }\\n&nbsp; return etype;\\n}\\n\&quot; ${${CBS_CURRENT}_PUBLIC_HEADER} &gt;&nbsp; ${CMAKE_CURRENT_BINARY_DIR}/${outFileName}.c<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TARGET gtkMkEnumsTarget<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}<BR>
)<BR>
ADD_SOURCE_FILE ( ${CMAKE_CURRENT_BINARY_DIR}/${outFileName}.c&nbsp; )<BR>
SET_SOURCE_FILES_PROPERTIES( ${CMAKE_CURRENT_BINARY_DIR}/${outFileName}.c GENERATED&nbsp;&nbsp;&nbsp;&nbsp; )<BR>
<BR>
----------<BR>
But the generated makefile does not switch to the requested WORKING_DIRECTORY but instead to<BR>
the CMAKE_CURRENT_BINARY_DIR regardless of what I set as WORKING_DIRECTORY.<BR>
<BR>
--- It looks something like this in the CMake generated makefile: ---<BR>
<BR>
@echo &quot;Generating gtktypebuiltins.c&quot;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cd /home/ml/code/cpaf/build_cbs/kdev_release/lgpl/gtk/gtk &amp;&amp; ../../glib-main/gobject/glib-mkenums --fhead &quot;#undef GTK_DISABLE_DEPRECATED\n#define GTK_ENABLE_BROKEN\n#include \&quot;gtk.h\&quot;\n#include \&quot;gtkprivate.h\&quot;\n#include \&quot;gtkalias.h\&quot;\n&quot; --ftail &quot;#define __GTK_TYPE_BUILTINS_C__\n#include \&quot;gtkaliasdef.c\&quot;\n&quot; --fprod &quot;\n/* enumerations from \&quot;@filename@\&quot; */&quot; --vhead &quot;GType\n@enum_name@_get_type (void)\n{\n static GType etype = 0 \n if (etype == 0) {\n static const G@Type@Value values[] = {&quot; --vprod &quot; { @VALUENAME@, \&quot;@VALUENAME@\&quot;, \&quot;@valuenick@\&quot; },&quot; --vtail &quot; { 0, NULL, NULL }\n } \n etype = g_@type@_register_static (g_intern_static_string (\&quot;@EnumName@\&quot;), values) \n }\n return etype \n}\n&quot; gtk.h ( ... LOTS_OF_HEADER_FILES .... ) &gt; /home/ml/code/cpaf/build_cbs/kdev_release/lgpl/gtk/gtk/gtktypebuiltins.c<BR>
<BR>
--- problem: ---<BR>
The glib-mkenums script cannot find the header files since it's executed from the wrong working directory!<BR>
<BR>
Any suggestions ?<BR>
<BR>
-Martin Lutken<BR>
</FONT>
</P>

</BODY>
</HTML>