From: Matthias Maier <tamiko@43-1.org>
Date: Tue, 23 May 2023 13:26:11 +0000 (-0500)
Subject: CMake: also escape linker flags of the form -Wl,-rpath -Wl,/path/
X-Git-Tag: v9.5.0-rc1~203^2
X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f927a85ffef443094dc1f8468d74585156353b6;p=dealii.git

CMake: also escape linker flags of the form -Wl,-rpath -Wl,/path/
---

diff --git a/cmake/macros/macro_shell_escape_option_groups.cmake b/cmake/macros/macro_shell_escape_option_groups.cmake
index 5c04853cff..78dca443c0 100644
--- a/cmake/macros/macro_shell_escape_option_groups.cmake
+++ b/cmake/macros/macro_shell_escape_option_groups.cmake
@@ -50,4 +50,14 @@ macro(shell_escape_option_groups _variable)
     "SHELL:(-Xcudafe [^;]+|-Xlinker [^;]+);SHELL:(-Xcudafe [^;]+|-Xlinker [^;]+)"
     "SHELL:\\1 \\2" ${_variable} "${${_variable}}"
     )
+
+  #
+  # In addition try to merge options of the form "-Wl,-flag -Wl,/path". We
+  # do this by detecting all occurences of a flag ("-Wl,-[-]flag") followed
+  # by an option that doesn't start with a dash ("-Wl,[option]"):
+  #
+  string(REGEX REPLACE
+    "(-Wl,[-]+[^;]*);(-Wl,[^-][^;]+)"
+    "SHELL:\\1 \\2" ${_variable} "${${_variable}}"
+    )
 endmacro()