<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 10-Dec-15 12:52, Attila
Krasznahorkay wrote:<br>
</div>
<blockquote
cite="mid:7BE45809-B42D-42CD-AC30-4368852D99BA@gmail.com"
type="cite">
<pre wrap="">Hi QP,
Probably not the intended solution, but what I’m doing in such cases is that in a patch step I create a shell script that does the configuration for me. With all the environment settings and everything. Like:
PATCH_COMMAND ${CMAKE_COMMAND} -E echo “cd someDir/; CC=\”something\” ./configure” > configure.sh
CONFIGURE_COMMAND sh configure.sh
</pre>
</blockquote>
...<br>
<br>
<blockquote
cite="mid:7BE45809-B42D-42CD-AC30-4368852D99BA@gmail.com"
type="cite">
<pre wrap="">
Unfortunately this makes the code quite unportable, as it will only work on POSIX platforms like this.</pre>
</blockquote>
Even on *nix platforms such code will not always works as expected.
As documentation states
(<a class="moz-txt-link-freetext" href="https://cmake.org/cmake/help/v3.4/module/ExternalProject.html">https://cmake.org/cmake/help/v3.4/module/ExternalProject.html</a>):<br>
<blockquote>Behavior of shell operators like <code class="docutils
literal"><span class="pre">&&</span></code> is not
defined.<br>
</blockquote>
I've hit this on practice by using `LOG_* 1` feature. You can try
this example (I've moved PATCH_COMMAND to CONFIGURE_COMMAND since
there is no LOG_PATCH option):<br>
<br>
<blockquote><a class="moz-txt-link-freetext" href="https://gist.github.com/ruslo/e8c7be03521f167ae8f0">https://gist.github.com/ruslo/e8c7be03521f167ae8f0</a><br>
</blockquote>
<br>
Result:<br>
<blockquote>[ 62%] Performing configure step for 'Foo'<br>
cd /.../Foo-prefix/src/Foo-build && /.../cmake -P
/.../Foo-prefix/src/Foo-stamp/Foo-configure-.cmake<br>
CMake Error at
/.../Foo-prefix/src/Foo-stamp/Foo-configure-.cmake:16 (message):<br>
Command failed: 1<br>
</blockquote>
The reason of the failure is because CMake collect all arguments
into one command and run execute_process:<br>
<blockquote>set(command "/.../cmake;-E;echo;cd
..;>;configure.sh")<br>
execute_process(COMMAND ${command} RESULT_VARIABLE result)<br>
</blockquote>
which of course doesn't make sense.<br>
<br>
This makes writing ExternalProject_Add steps with modification of
environment quite non-trivial task (at least doing it correctly).
This feature definitely missing in CMake. I've mentioned it once
already:
<a class="moz-txt-link-freetext" href="https://cmake.org/pipermail/cmake-developers/2015-August/026053.html">https://cmake.org/pipermail/cmake-developers/2015-August/026053.html</a><br>
<br>
but I've changed my mind about the approach because of LOG_* issue.
Now I do the next:<br>
<br>
* wrap each step with CMake script, i.e. instead of `CC=something
./configure` do<br>
<blockquote>set(ENV{CC} "something")<br>
execute_process(COMMAND ./configure ...)<br>
</blockquote>
* run CMake script in *_COMMAND:<br>
<br>
<blockquote>CONFIGURE_COMMAND<br>
"${CMAKE_COMMAND}" -P "/path/to/configure.cmake"<br>
</blockquote>
This makes it cross-platform and *_LOG friendly but require more
tricks. Like if you're building in source (non-cmake packages) you
have to copy script before execution since CMake will remove source
directory on DOWNLOAD step. Which makes it looks like this:<br>
<br>
<blockquote>CONFIGURE_COMMAND<br>
"${CMAKE_COMMAND}" -E copy "/path/to/source/configure.cmake"
"/path/to/unpacked/configure.cmake"<br>
COMMAND<br>
"${CMAKE_COMMAND}" -P "/path/to/unpacked/configure.cmake"<br>
<br>
</blockquote>
PS I'm hitting problems in ExternalProject with environment
variables all the time. E.g. at this moment fixing MinGW + Boost:
<a class="moz-txt-link-freetext" href="https://github.com/ruslo/hunter/pull/273">https://github.com/ruslo/hunter/pull/273</a><br>
<br>
Ruslo<br>
<br>
<blockquote
cite="mid:7BE45809-B42D-42CD-AC30-4368852D99BA@gmail.com"
type="cite">
<pre wrap=""> But I guess that’s the case anyway once you start setting environment variables.
Cheers,
Attila
P.S. I often create build.sh and install.sh scripts as well in additional patch commands.
</pre>
<blockquote type="cite">
<pre wrap="">On Dec 10, 2015, at 5:35 AM, Qingping Hou <a class="moz-txt-link-rfc2396E" href="mailto:dave2008713@gmail.com"><dave2008713@gmail.com></a> wrote:
Hi all,
I am trying to setup an ExternalProject in cmake but got stuck in the
configuration step. I am using ccache to speed up the compilation:
```
ExternalProject_Add(
...
CONFIGURE_COMMAND CC="ccache arm-linux-gnueabihf-gcc" ./configure
...
)
```
However, when cmake generates the Makefile, it moves the quotes around
and breaks the command:
```
"CC=ccache arm-linux-gnueabihf-gcc" ./configure
```
I have tried various escaping method to try to get it work properly
without any luck. Is this a bug or an unintended feature?
Thanks,
QP
--
Powered by <a class="moz-txt-link-abbreviated" href="http://www.kitware.com">www.kitware.com</a>
Please keep messages on-topic and check the CMake FAQ at: <a class="moz-txt-link-freetext" href="http://www.cmake.org/Wiki/CMake_FAQ">http://www.cmake.org/Wiki/CMake_FAQ</a>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:
CMake Support: <a class="moz-txt-link-freetext" href="http://cmake.org/cmake/help/support.html">http://cmake.org/cmake/help/support.html</a>
CMake Consulting: <a class="moz-txt-link-freetext" href="http://cmake.org/cmake/help/consulting.html">http://cmake.org/cmake/help/consulting.html</a>
CMake Training Courses: <a class="moz-txt-link-freetext" href="http://cmake.org/cmake/help/training.html">http://cmake.org/cmake/help/training.html</a>
Visit other Kitware open-source projects at <a class="moz-txt-link-freetext" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a>
Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://public.kitware.com/mailman/listinfo/cmake">http://public.kitware.com/mailman/listinfo/cmake</a>
</pre>
</blockquote>
<pre wrap="">
</pre>
</blockquote>
<br>
</body>
</html>