[CMake] ExternalProjectAdd and patch on Windows

Kris Thielemans kris.f.thielemans at gmail.com
Fri Jun 21 03:08:54 EDT 2019


Thanks Cristian

 

That works wonderfully!

 

Kris

 

From: Cristian Adam 
Sent: 20 June 2019 12:28
To: Kris Thielemans

Cc: CMake Mail List <cmake at cmake.org>
Subject: Re: [CMake] ExternalProjectAdd and patch on Windows

 

Hi,

 

If the users have git installed, you could try find_program(git...), and then "git apply", which should work to apply patches.

 

Cheers,

Cristian.

 

On Thu, Jun 20, 2019 at 1:21 PM Kris Thielemans wrote:

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.ForEachObjectCommand

 

 

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

-- 

Powered by www.kitware.com <http://www.kitware.com> 

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190621/8b8c0f81/attachment-0001.html>


More information about the CMake mailing list