From d1b1a633819da586461b96c6a2b1bdf02df059b2 Mon Sep 17 00:00:00 2001
From: Thomas Debesse <dev@illwieckz.net>
Date: Fri, 31 May 2019 17:59:56 +0200
Subject: [PATCH] msys2/bundle: properly parse ldd output for dll bundling on
 windows

- properly filters out Windows dll using case insensitive grep
- filters out non .dll lines in ldd output, avoid empty lines and ??? lines
- copy dll preserving timestamps
---
 CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c13b2ca8..74984508 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -216,7 +216,7 @@ if (BUILD_BINARIES)
         if (BUNDLE_LIBRARIES)
             add_custom_command(TARGET ${target} POST_BUILD
                     COMMAND bash
-                    ARGS -c "ldd '$<TARGET_FILE:${target}>' | grep -v /c/Windows | awk '{ print $1 }' | while read dll; do cp \"$(which $dll)\" '${PROJECT_BINARY_DIR}'; done"
+                    ARGS -c "ldd '$<TARGET_FILE:${target}>' | egrep -i '\\.dll ' | grep -iv '/c/Windows' | awk '{ print $1 }' | while read dll; do cp --preserve=timestamps \"$(which $dll)\" '${PROJECT_BINARY_DIR}'; done"
                     VERBATIM
                     )
         endif ()
-- 
2.39.5