Fix patching for poly on windows (#7513)
authorGereon Kremer <nafur42@gmail.com>
Wed, 27 Oct 2021 19:58:48 +0000 (12:58 -0700)
committerGitHub <noreply@github.com>
Wed, 27 Oct 2021 19:58:48 +0000 (19:58 +0000)
This PR is another step to fix our windows nightlies.
It moves the patch steps for libpoly in a separate script. Apparently, it is impossible to properly escape this stuff to work on all platforms and all cmake versions.

cmake/FindPoly.cmake
cmake/deps-utils/Poly-windows-patch.sh [new file with mode: 0755]

index b55eca939a7f0ee8d5b47b7126b5491dee0bb735..f363147cc9e3ebc75a6fca005d62a6e706e3a6ad 100644 (file)
@@ -59,18 +59,8 @@ if(NOT Poly_FOUND_SYSTEM)
 
   check_if_cross_compiling(CCWIN "Windows" "")
   if(CCWIN)
-    # Roughly following https://stackoverflow.com/a/44383330/2375725
-    set(patchcmd
-        # Avoid %z and %llu format specifiers
-        COMMAND find <SOURCE_DIR>/ -type f ! -name "*.orig" -exec
-                sed -i.orig "s/%z[diu]/%\\\" PRIu64 \\\"/g" {} +
-        COMMAND find <SOURCE_DIR>/ -type f ! -name "*.orig" -exec
-                sed -i.orig "s/%ll[du]/%\\\" PRIu64 \\\"/g" {} +
-        # Make sure the new macros are available
-        COMMAND find <SOURCE_DIR>/ -type f ! -name "*.orig" -exec
-                sed -i.orig "s/#include <stdio.h>/#include <stdio.h>\\\\n#include <inttypes.h>/" {} +
-        COMMAND find <SOURCE_DIR>/ -type f ! -name "*.orig" -exec
-                sed -i.orig "s/#include <cstdio>/#include <cstdio>\\\\n#include <inttypes.h>/" {} +
+    set(patchcmd COMMAND
+      ${CMAKE_SOURCE_DIR}/cmake/deps-utils/Poly-windows-patch.sh <SOURCE_DIR>
     )
   else()
     unset(patchcmd)
diff --git a/cmake/deps-utils/Poly-windows-patch.sh b/cmake/deps-utils/Poly-windows-patch.sh
new file mode 100755 (executable)
index 0000000..3b613bc
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# Roughly following https://stackoverflow.com/a/44383330/2375725
+# Avoid %z and %llu format specifiers
+find $1/ -type f ! -name "*.orig" -exec \
+     sed -i.orig "s/%z[diu]/%\\\" PRIu64 \\\"/g" {} +
+find $1/ -type f ! -name "*.orig" -exec \
+     sed -i.orig "s/%ll[du]/%\\\" PRIu64 \\\"/g" {} +
+
+# Make sure the new macros are available
+find $1/ -type f ! -name "*.orig" -exec \
+     sed -i.orig "s/#include <stdio.h>/#include <stdio.h>\\n#include <inttypes.h>/" {} +
+find $1/ -type f ! -name "*.orig" -exec \
+     sed -i.orig "s/#include <cstdio>/#include <cstdio>\\n#include <inttypes.h>/" {} +
\ No newline at end of file