<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 4, 2013 at 6:01 AM, Daniele E. Domenichelli <span dir="ltr"><<a href="mailto:daniele.domenichelli@gmail.com" target="_blank">daniele.domenichelli@gmail.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
One benefit is that it would allow to easily remove all cmake files when<br>
you wrongly run cmake in the source directory instead of in the build one.<br><div class=""><div class="h5"><br></div></div></blockquote><div> </div><div style>A while ago I found the attached macro online[1]. It stops the build process early on preventing an in source build.</div>
<div style>Since it has to start the process to work you still get a CMakeCache.txt file and CMakeFiles directory but those are easy enough to remove compared to picking through your whole source tree.</div><div style><br>
</div><div style>To use it place the Macro as close to the top of your master CMakeLists.txt file as you can and call it with something like:</div><div style><br></div><div style><div># Appends the path where you are keeping this Macro</div>
<div>set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})</div><div><br></div><div>#Forces out of source builds just in case.</div><div>include(MacroOutOfSourceBuild)</div><div>macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source build.")</div>
</div><div> </div><div style>-Brian</div><div><br></div><div>[1] <a href="https://github.com/DisCODe/DisCODe/blob/master/cmake/modules/MacroOutOfSourceBuild.cmake">https://github.com/DisCODe/DisCODe/blob/master/cmake/modules/MacroOutOfSourceBuild.cmake</a></div>
</div></div></div>