<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 16/01/14 7:08 AM, Ben Phillips
wrote:<br>
</div>
<blockquote
cite="mid:CAERX0p1RCeGkjMQVjuFHr+D=ffDbtKV9s052n2vbRJrrBtttQQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>
<div><span style="color:rgb(0,0,0)"><span
style="background-color:rgb(255,255,255)">Hello
list,<br>
<br>
</span></span></div>
<span style="color:rgb(0,0,0)"><span
style="background-color:rgb(255,255,255)">I came
across this problem when I tried to write a
CMakeLists.txt that prevents building in the
source tree. So I would try something like this:<br>
<br>
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}"
"${CMAKE_BINARY_DIR}" _is_in_src)<br>
</span></span></div>
<span style="color:rgb(0,0,0)"><span
style="background-color:rgb(255,255,255)">if(_is_in_src)<br>
</span></span></div>
<div><span style="color:rgb(0,0,0)"><span
style="background-color:rgb(255,255,255)">
file(REMOVE_RECURSE $</span></span><span
style="color:rgb(0,0,0)"><span
style="background-color:rgb(255,255,255)">{CMAKE_SOURCE_DIR}/CMakeFiles
</span></span><span style="color:rgb(0,0,0)"><span
style="background-color:rgb(255,255,255)"><span
style="color:rgb(0,0,0)"><span
style="background-color:rgb(255,255,255)">$</span></span><span
style="color:rgb(0,0,0)"><span
style="background-color:rgb(255,255,255)">{CMAKE_SOURCE_DIR}/CMakeCache.txt</span></span>)</span></span></div>
<div><span style="color:rgb(0,0,0)"><span
style="background-color:rgb(255,255,255)">
message(FATAL_ERROR "Aborting...in-source builds
are forbidden")<br>
</span></span></div>
<span style="color:rgb(0,0,0)"><span
style="background-color:rgb(255,255,255)">endif(_is_in_src)<br>
<br>
</span></span></div>
<span style="color:rgb(0,0,0)"><span
style="background-color:rgb(255,255,255)">When running
"cmake ." the error is given as expected. However, the
source directory is polluted with CMakeFiles and
CMakeCache.txt. I expect they can't be removed while
the CMakeLists.txt is being interpreted (perhaps they
are but are just created before exit again). <br>
<br>
</span></span></div>
<span style="color:rgb(0,0,0)"><span
style="background-color:rgb(255,255,255)">Is there a
better way to do this? Perhaps some function/macro that
aborts the process abnormally, cleaning up as if nothing
ever happened exists?<br>
</span></span></div>
</div>
</div>
</blockquote>
Hi Ben,<br>
<br>
I have found that doing an "out-of-source" build makes it much
easier to do clean up.<br>
<br>
For example :<br>
<br>
$cd /tmp/<some-dev-dir><br>
$cmake <cmake-flags-you-want>
/home/ben/project/myawesomeproject<br>
<br>
Hope that helps.<br>
<br>
Cheers<br>
<pre class="moz-signature" cols="72">--
Nicholas Yue
Graphics - RenderMan, Visualization, OpenGL, HDF5
Custom Dev - C++ porting, OSX, Linux, Windows
<a class="moz-txt-link-freetext" href="http://au.linkedin.com/in/nicholasyue">http://au.linkedin.com/in/nicholasyue</a>
<a class="moz-txt-link-freetext" href="https://vimeo.com/channels/naiadtools">https://vimeo.com/channels/naiadtools</a></pre>
</body>
</html>