<div dir="ltr"><div>Hi Brian,<br></div><div><br></div><div>  Have you consider ExternaProject() ? It has a patching feature.</div><div><br></div><div><a href="https://cmake.org/cmake/help/v3.0/module/ExternalProject.html">https://cmake.org/cmake/help/v3.0/module/ExternalProject.html</a><br></div><div><br></div>Cheers<br></div><br><div class="gmail_quote"><div dir="ltr">On Mon, 6 Nov 2017 at 07:35 brian heim <<a href="mailto:brianlheim@gmail.com">brianlheim@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi list,<br><br>Hope you're doing well. I have a question about using CMake to patch the source code in a project I work on. This is the situation:<br><br>- Project includes C++ transpiled from a different specialized language<br>- That transpiler is not cross-platform, so we include transpiled C++ in our source tree<br>- The generated code does not compile with MSVC 2013 because of a bug (specifically <a href="https://support.microsoft.com/en-us/help/315481/bug-too-many-unnested-loops-incorrectly-causes-a-c1061-compiler-error" target="_blank">https://support.microsoft.com/en-us/help/315481/bug-too-many-unnested-loops-incorrectly-causes-a-c1061-compiler-error</a>)<br>- Vendor of transpiler will not patch for this case, so we need to modify the source ourselves<div><br></div><div>We don't want to _directly_ modify the source because that means we'll have to [remember to] do it on a regular basis, when new or updated source files are added. The patching is simple enough that it can be done with a regex. I am not very experienced with CMake, but I'm aware that two ways of modifying source files are:</div><div><br></div><div>1. configure_file(), which doesn't seem to give tools for this purpose.</div><div>2. file(READ ...) followed by file(WRITE ...). I've gotten my regex to work with it, but my attempt overwrites the source file in-place, unlike configure_file() which places the modified file in the build tree.</div><div><br></div><div>Is there a way to do (2) correctly? By which I mean, can I do a form of configure_file() using a regex? Or is there an altogether easier solution that's staring me in the face?</div><div><br></div><div>Thank you very much in advance for your help,</div><div><br></div><div>Brian H</div></div>
--<br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a></blockquote></div>