<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
On 04.09.2019 11:55, Edoardo Pasca wrote:<br>
<blockquote type="cite"
cite="mid:CAJZDnTj=m8NoDYk=XpnokFv6OtCGc5EydLi2zW4+bBsqTzEi9g@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">Dear all,
<div><br>
</div>
<div class="cye-lm-tag">I'm using ExternalProjectAdd to build an
external package. </div>
<div class="cye-lm-tag"><br>
</div>
<div class="cye-lm-tag">On the CONFIGURE_COMMAND I have to pass
some variables to the configure script in this form:</div>
<div class="cye-lm-tag"><br>
</div>
<div class="cye-lm-tag">configure CPPFLAGS="-I/dir/include
-L/dir/lib" </div>
<div class="cye-lm-tag"><br>
</div>
<div class="cye-lm-tag">To do this I use </div>
<div class="cye-lm-tag"><br>
</div>
<div class="cye-lm-tag">CONFIGURE_COMMAND ${CMAKE_COMMAND} -E
env ${CMAKE_BINARY_DIR}/configure CPPFLAGS="-I/dir/include
-L/dir/lib" </div>
<div class="cye-lm-tag"><br>
</div>
<div class="cye-lm-tag">However, when cmake issues that command
(you can see that with make VERBOSE=1) it wraps the CPPFLAGS
parameters with quotation marks (as below) and the configure
script fails</div>
<div class="cye-lm-tag"><br clear="all">
<div class="cye-lm-tag">
<div class="gmail-cye-lm-tag cye-lm-tag">configure
"CPPFLAGS=\"-I/dir/include -L/dir/lib\""</div>
<div class="gmail-cye-lm-tag"><br>
</div>
<div class="gmail-cye-lm-tag cye-lm-tag">Below you can find
a minimal CMakeLists.txt to test this. </div>
<div class="gmail-cye-lm-tag cye-lm-tag"><br>
</div>
<div class="gmail-cye-lm-tag cye-lm-tag">I'd appreciate any
help on how I'd remove those quotation marks.</div>
<div class="gmail-cye-lm-tag cye-lm-tag"> </div>
<div class="gmail-cye-lm-tag cye-lm-tag">Thanks</div>
<div class="gmail-cye-lm-tag cye-lm-tag"><br>
</div>
<div class="gmail-cye-lm-tag cye-lm-tag">Edo</div>
</div>
</div>
</div>
</blockquote>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">What I do is let CMake handle this
itself by defining a (list) variable for the configure command:<br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">set(cmd
"${CMAKE_BINARY_DIR}/configure")</div>
<div class="moz-cite-prefix">list(APPEND cmd
"CPPFLAGS=-I/dir/include -L/dir/lib")</div>
<div class="moz-cite-prefix">ExternalProject_Add(...</div>
<div class="moz-cite-prefix"> CONFIGURE_COMMAND ${CMAKE_COMMAND} -E
env ${cmd}</div>
<div class="moz-cite-prefix"> ...)</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">Since cmd is a list, CMake knows that
the -L/dir/lib belongs to the CPPFLAGS=-I/dir/include part, and
puts double quotes around the entire thing, e.g. the actual
command line will look something like this:<br>
</div>
<p><xxx>/configure "CPPFLAG=-Idir/include -L/dir/lib"
</p>
<div class="moz-cite-prefix">This works with GNU autoconf. I've
found that in general, dealing with quoting in ExternalProject_Add
is a gigantic pain, so if the method above is not sufficient, I
use configure_file or file(WRITE) to generate a shell script
(Linux) or batch file (Windows) with the correct parameters and
call that instead.<br>
</div>
<p>With kind regards,<br>
Eric Dönges<br>
</p>
<div class="moz-signature">
<div style="width:480px; text-align: left; font-family: Arial,
Helvetica, sans-serif;">
<p style="color: #062d64; font-size: 14px; text-align: left;
font-family: Arial, Helvetica, sans-serif;"><b>Dr. Eric Dönges
</b><br>
Senior Software Engineer
</p>
<p style="color: #062d64; font-size: 12px; text-align: left;
font-family: Arial, Helvetica, sans-serif;">MVTec Software
GmbH | Arnulfstr. 205 | 80634 Munich | Germany<br>
<a style="font-size: 12px; font-family: Arial, Helvetica,
sans-serif; color: #062d64;" href="mailto:doenges@mvtec.com">doenges@mvtec.com</a>
| Tel: +49 89 457 695-0 | <a style="font-size: 12px;
font-family: Arial, Helvetica, sans-serif; color: #062d64;"
href="http://www.mvtec.com">www.mvtec.com</a>
</p>
<p style="color: #062d64; font-size: 12px; text-align: left;
font-family: Arial, Helvetica, sans-serif;"><img
src="https://mvtec.com/fileadmin/Redaktion/newsletter/mail-signature/newsletter-icon.png"
valign="bottom" width="16" height="16"> <a style="font-size:
12px; font-family: Arial, Helvetica, sans-serif; color:
#062d64; font-weight: bold;"
href="http://www.mvtec.com/newsletter">Sign up</a> for our
MVTec Newsletter!</p>
<p style="margin: 0px; color: #666; font-size: 12px; text-align:
left; font-family: Arial, Helvetica, sans-serif;">Geschäftsführer:
Dr. Wolfgang Eckstein, Dr. Olaf Munkelt<br>
Amtsgericht München HRB 114695</p>
<p style="margin: 0px; color: #666; font-size: 12px; text-align:
left; font-family: Arial, Helvetica, sans-serif;"> </p>
<img
src="https://www.mvtec.com/fileadmin/Redaktion/newsletter/mail-signature/mvtec-logo-line.png"
alt="MVTec Software GmbH Logo"></div>
</div>
</body>
</html>