[CMake] ExternalProjectAdd and patch on Windows
Kris Thielemans
kris.f.thielemans at gmail.com
Thu Jun 20 07:21:10 EDT 2019
Hi all
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
get-content ConfigureChecks.cmake
| %{$_ -replace "H5_HAVE_TIMEZONE 1","H5_HAVE_TIMEZONE 0"} > xx;move-item
-Force xx ConfigureChecks.cmake
(all on 1 line).
Unfortunately, Powershell has now converted the file in some other encoding
(I guess UTF-8), which doesn't make sense for the subsequent compilation.
Supposing I could resolved that, I have trouble passing this to
PATCH_COMMAND. I tried
ExternalProject_Add(${proj}
${${proj}_EP_ARGS}
.
PATCH_COMMAND powershell -Command "get-content ConfigureChecks.cmake |
%{$_ -replace \"H5_HAVE_TIMEZONE 1\",\"H5_HAVE_TIMEZONE 0\"} > xx; move-item
-Force xx ConfigureChecks.cmake "
.
)
But the semi-colon doesn't seem to work
2> Performing patch step for 'HDF5'
2> ForEach-Object : Cannot bind parameter 'RemainingScripts'. Cannot
convert the "move-item" value of type
2> "System.String" to type "System.Management.Automation.ScriptBlock".
2> At line:1 char:50
2> + ... cks.cmake | %{$_ -replace "H5_HAVE_TIMEZONE 1","H5_HAVE_TIMEZONE
0"} ...
2> +
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2> + CategoryInfo : InvalidArgument: (:) [ForEach-Object],
ParameterBindingException
2> + FullyQualifiedErrorId :
CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.ForEachObjectCo
mmand
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)
PATCH_COMMAND
powershell -Command "get-content ConfigureChecks.cmake | %{$_ -replace
\"H5_HAVE_TIMEZONE 1\",\"H5_HAVE_TIMEZONE 0\"} > xx"
move /Y xx ConfigureChecks.cmake
gives almost the same error message (but now with "move" as opposed to
"move-item")
Anyone any suggestions?
Many thanks
Kris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190620/144d01c2/attachment.html>
More information about the CMake
mailing list