<div dir="ltr">Hi,<div><br></div><div>If the users have git installed, you could try find_program(git...), and then "git apply", which should work to apply patches.</div><div><br></div><div>Cheers,</div><div>Cristian.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 20, 2019 at 1:21 PM Kris Thielemans <<a href="mailto:kris.f.thielemans@gmail.com">kris.f.thielemans@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="EN-GB"><div class="gmail-m_-1538230711769541937WordSection1"><p class="MsoNormal">Hi all<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">I have a superbuild project where I need to patch a library (HDF5) after download. In Windows, there’s no “patch” or “sed” command, and  this has to run on other people’s computer. I can almost achieve what I want in Powershell like so<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">get-content ConfigureChecks.cmake<u></u><u></u></p><p class="MsoNormal">| %{$_ -replace "H5_HAVE_TIMEZONE 1","H5_HAVE_TIMEZONE 0"} > xx;move-item -Force xx ConfigureChecks.cmake<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">(all on 1 line).<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Unfortunately, Powershell has now converted the file in some other encoding (I guess UTF-8), which doesn’t make sense for the subsequent compilation.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Supposing I could resolved that, I have trouble passing this to PATCH_COMMAND. I tried<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">  ExternalProject_Add(${proj}<u></u><u></u></p><p class="MsoNormal">    ${${proj}_EP_ARGS}<u></u><u></u></p><p class="MsoNormal">    …<u></u><u></u></p><p class="MsoNormal">    PATCH_COMMAND powershell -Command “get-content ConfigureChecks.cmake | %{$_ -replace \"H5_HAVE_TIMEZONE 1\",\"H5_HAVE_TIMEZONE 0\"} > xx; move-item -Force xx ConfigureChecks.cmake “<u></u><u></u></p><p class="MsoNormal">   …<u></u><u></u></p><p class="MsoNormal">   )<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">But the semi-colon doesn’t seem to work<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black">2>  Performing patch step for 'HDF5'<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black">2>  ForEach-Object : Cannot bind parameter 'RemainingScripts'. Cannot convert the "move-item" value of type<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black">2>  "System.String" to type "System.Management.Automation.ScriptBlock".<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black">2>  At line:1 char:50<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black">2>  + ... cks.cmake | %{$_ -replace "H5_HAVE_TIMEZONE 1","H5_HAVE_TIMEZONE 0"}  ...<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black">2>  +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black">2>      + CategoryInfo          : InvalidArgument: (:) [ForEach-Object], ParameterBindingException<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black">2>      + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.ForEachObjectCommand<u></u><u></u></span></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Trying to split it up as 2 commands (for instance the first powershell and the next cmd, but I could have used powershell as well)<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">    PATCH_COMMAND<u></u><u></u></p><p class="MsoNormal">      powershell -Command "get-content ConfigureChecks.cmake | %{$_ -replace \"H5_HAVE_TIMEZONE 1\",\"H5_HAVE_TIMEZONE 0\"} > xx"<u></u><u></u></p><p class="MsoNormal">      move /Y xx ConfigureChecks.cmake<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">gives almost the same error message (but now with “move” as opposed to “move-item”)<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Anyone any suggestions?<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Many thanks<u></u><u></u></p><p class="MsoNormal">Kris<u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p></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="https://cmake.org/mailman/listinfo/cmake" rel="noreferrer" target="_blank">https://cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div>