<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:p="urn:schemas-microsoft-com:office:powerpoint" xmlns:a="urn:schemas-microsoft-com:office:access" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns:b="urn:schemas-microsoft-com:office:publisher" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:odc="urn:schemas-microsoft-com:office:odc" xmlns:oa="urn:schemas-microsoft-com:office:activation" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:q="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rtc="http://microsoft.com/officenet/conferencing" xmlns:D="DAV:" xmlns:Repl="http://schemas.microsoft.com/repl/" xmlns:mt="http://schemas.microsoft.com/sharepoint/soap/meetings/" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:ppda="http://www.passport.com/NameSpace.xsd" xmlns:ois="http://schemas.microsoft.com/sharepoint/soap/ois/" xmlns:dir="http://schemas.microsoft.com/sharepoint/soap/directory/" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:udc="http://schemas.microsoft.com/data/udc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sub="http://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/" xmlns:ec="http://www.w3.org/2001/04/xmlenc#" xmlns:sp="http://schemas.microsoft.com/sharepoint/" xmlns:sps="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:udcs="http://schemas.microsoft.com/data/udc/soap" xmlns:udcxf="http://schemas.microsoft.com/data/udc/xmlfile" xmlns:udcp2p="http://schemas.microsoft.com/data/udc/parttopart" xmlns:wf="http://schemas.microsoft.com/sharepoint/soap/workflow/" xmlns:dsss="http://schemas.microsoft.com/office/2006/digsig-setup" xmlns:dssi="http://schemas.microsoft.com/office/2006/digsig" xmlns:mdssi="http://schemas.openxmlformats.org/package/2006/digital-signature" xmlns:mver="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns:mrels="http://schemas.openxmlformats.org/package/2006/relationships" xmlns:spwp="http://microsoft.com/sharepoint/webpartpages" xmlns:ex12t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ex12m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:pptsl="http://schemas.microsoft.com/sharepoint/soap/SlideLibrary/" xmlns:spsl="http://microsoft.com/webservices/SharePointPortalServer/PublishedLinksService" xmlns:Z="urn:schemas-microsoft-com:" xmlns:st="&#1;" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Courier New";}
span.EmailStyle19
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=WordSection1>

<p class=MsoNormal>Hi,<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>I am new to using cmake, and trying to get a custom build
command to embed quotes for a project that I&#8217;m compiling in MS visual studio on
a windows machine.<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>I have this in my cmake file:<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='margin-left:.5in'>COMMAND ${FLEX_EXECUTABLE} -t
${WEBCORE_DIR}/css/tokenizer.flex | &quot;${PERL_EXECUTABLE}&quot;
${MAKE_TOKENIZER} &gt; ${DERIVED_SOURCES_DIR}/tokenizer.cpp<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>I need to achieve this custom build step in my generated
vcproj file:<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='margin-left:.5in'>C:\cygwin\bin\flex.exe -t
E:\Wolverine\git-Jason\git-WebKit\WebCore\css\tokenizer.flex |
&quot;C:\cygwin\bin\perl.exe&quot; E:\Wolverine\git-Jason\git-WebKit\WebCore\css\maketokenizer
&gt; E:\Wolverine\git-Jason\git-WebKit\WebKitBuild\DerivedSources\tokenizer.cpp<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Please note the wrapping quotes around &quot;C:\cygwin\bin\perl.exe&quot;.&nbsp;
That&#8217;s critical, or the DOS shell complains that &#8216;C:&#8217; is not a valid command.<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Cmake is removing the quotes and giving me this:<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='margin-left:.5in'>C:\cygwin\bin\flex.exe -t
E:\Wolverine\git-Jason\git-WebKit\WebCore\css\tokenizer.flex |
C:\cygwin\bin\perl.exe
E:\Wolverine\git-Jason\git-WebKit\WebCore\css\maketokenizer &gt; E:\Wolverine\git-Jason\git-WebKit\WebKitBuild\DerivedSources\tokenizer.cpp<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Which fails like I said.&nbsp; DOS complains that &#8216;C:&#8217; is
not a valid command, and doesn&#8217;t parse it correctly without the quotes around
the path to perl.exe.<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>When I try to escape the quotes, like this:<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='margin-left:.5in'>COMMAND ${FLEX_EXECUTABLE} -t
${WEBCORE_DIR}/css/tokenizer.flex | \&quot;${PERL_EXECUTABLE}\&quot;
${MAKE_TOKENIZER} &gt; ${DERIVED_SOURCES_DIR}/tokenizer.cpp<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Cmake preserves the backslashes, and generates this:<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='margin-left:.5in'>C:\cygwin\bin\flex.exe -t
E:\Wolverine\git-Jason\git-WebKit\WebCore\css\tokenizer.flex |
\&#8221;C:\cygwin\bin\perl.exe\&#8221;
E:\Wolverine\git-Jason\git-WebKit\WebCore\css\maketokenizer &gt;
E:\Wolverine\git-Jason\git-WebKit\WebKitBuild\DerivedSources\tokenizer.cpp<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>I have also tried to work around it by performing a double
macro expansion like this:<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='margin-left:.5in'>SET(cmd &#8220;${FLEX_EXECUTABLE} -t
${WEBCORE_DIR}/css/tokenizer.flex | \&quot;${PERL_EXECUTABLE}\&quot;
${MAKE_TOKENIZER} &gt; ${DERIVED_SOURCES_DIR}/tokenizer.cpp&#8221;)<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>COMMAND ${cmd}<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>It doesn&#8217;t help... I get this:<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='margin-left:.5in'>&#8220;C:\cygwin\bin\flex.exe -t
E:\Wolverine\git-Jason\git-WebKit\WebCore\css\tokenizer.flex |
\&#8221;C:\cygwin\bin\perl.exe\&#8221;
E:\Wolverine\git-Jason\git-WebKit\WebCore\css\maketokenizer &gt;
E:\Wolverine\git-Jason\git-WebKit\WebKitBuild\DerivedSources\tokenizer.cpp&#8221;<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>The backslashes to escape the quotes were preserved
(breaking it) and the wrapping quotes around the outside of the whole command
string were also preserved, which makes the DOS shell think this is one long
file name.<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Whatever I try, the quotes are either completely removed, or
the backslashes to escape them are preserved as \&#8221; instead of becoming a simple
&#8220;<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>I also tried putting the quotes in their own escaped substrings
like this: &quot;\&quot;&quot;${PERL_EXECUTABLE}&quot;\&quot;&quot;<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'>COMMAND
${FLEX_EXECUTABLE} -t ${WEBCORE_DIR}/css/tokenizer.flex |
&quot;\&quot;&quot;${PERL_EXECUTABLE}&quot;\&quot;&quot; ${MAKE_TOKENIZER} &gt;
${DERIVED_SOURCES_DIR}/tokenizer.cpp<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>And I was surprised to see this output:<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<pre style='margin-left:.5in'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>C:\cygwin\bin\flex.exe -t E:/Wolverine/git-Jason/git-WebKit/WebCore/css/tokenizer.flex | \&quot; C:/cygwin/bin/perl.exe\&quot;\&quot;\&quot; E:/Wolverine/git-Jason/git-WebKit/WebCore/css/maketokenizer &gt; E:/Wolverine/git-Jason/git-WebKit/WebKitBuild/DerivedSources/tokenizer.cpp<o:p></o:p></span></pre><pre><span
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'><o:p>&nbsp;</o:p></span></pre>

<p class=MsoNormal>So then I tried to put just the &#8220; into its own expansion
like this:<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'>SET(QUOTE
\&quot;)<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'>COMMAND
${FLEX_EXECUTABLE} -t ${WEBCORE_DIR}/css/tokenizer.flex |
${QUOTE}${PERL_EXECUTABLE}${QUOTE} ${MAKE_TOKENIZER} &gt;
${DERIVED_SOURCES_DIR}/tokenizer.cpp<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>But the backslash to escape the quote is still preserved that
way too, and I get this:<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<pre style='margin-left:.5in'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>C:\cygwin\bin\flex.exe -t E:/Wolverine/git-Jason/git-WebKit/WebCore/css/tokenizer.flex | \&quot;C:/cygwin/bin/perl.exe\&quot; E:/Wolverine/git-Jason/git-WebKit/WebCore/css/maketokenizer &gt; E:/Wolverine/git-Jason/git-WebKit/WebKitBuild/DerivedSources/tokenizer.cpp<o:p></o:p></span></pre><pre><span
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'><o:p>&nbsp;</o:p></span></pre>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Is there any way to make this generate the output that I
need?&nbsp; Is this a bug in the version of cmake that I&#8217;m using (2.6 for windows
ce) or is there a trick to the cmake syntax?<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>For reference details, the complete context of my custom
command comes from this macro:<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'>SET(MAKE_TOKENIZER
${WEBCORE_DIR}/css/maketokenizer)<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'># - Create
${DERIVED_SOURCES_DIR}/tokenizer.cpp<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'>#
GENERATE_TOKENIZER()<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'>MACRO(GENERATE_TOKENIZER)<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'>&nbsp; # do a
little dance to embed quotes around perl.exe, or cmake messes them up<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'>&nbsp;
ADD_CUSTOM_COMMAND(<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'>&nbsp;&nbsp;&nbsp;
OUTPUT ${DERIVED_SOURCES_DIR}/tokenizer.cpp<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'>&nbsp;&nbsp;&nbsp;
DEPENDS ${WEBCORE_DIR}/css/tokenizer.flex ${MAKE_TOKENIZER}<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'>&nbsp;&nbsp;&nbsp;
COMMAND ${FLEX_EXECUTABLE} -t ${WEBCORE_DIR}/css/tokenizer.flex |
&quot;${PERL_EXECUTABLE}&quot; ${MAKE_TOKENIZER} &gt;
${DERIVED_SOURCES_DIR}/tokenizer.cpp<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'>&nbsp;&nbsp;&nbsp;
VERBATIM)<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'>ENDMACRO()<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in;text-autospace:none'>GENERATE_TOKENIZER()
# this is called out in a separate file<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>I am using cmake 2.6 for Windows CE because that&#8217;s the
version that was branched to support builds for Windows CE (so unfortunately if
this is a bug that has been fixed, I can&#8217;t update to cmake 2.8 - was there a
work-around in cmake 2.6?)<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='line-height:11.05pt;text-autospace:none'><b><o:p>&nbsp;</o:p></b></p>

<p class=MsoNormal style='line-height:11.05pt;text-autospace:none'><b>Ris
Misner </b><o:p></o:p></p>

<p class=MsoNormal style='line-height:11.05pt;text-autospace:none'>Sr. Software
Engineer I<o:p></o:p></p>

<p class=MsoNormal style='line-height:11.05pt;text-autospace:none'>d:
1.330.864.2300 x229 <o:p></o:p></p>

<p class=MsoNormal style='line-height:11.05pt;text-autospace:none'>m:
1.330.329.2843<o:p></o:p></p>

<p class=MsoNormal style='line-height:11.05pt;text-autospace:none'>email:
rism@bsquare.com <o:p></o:p></p>

<p class=MsoNormal>www.bsquare.com<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</body>

</html>