From 7f927a85ffef443094dc1f8468d74585156353b6 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Tue, 23 May 2023 08:26:11 -0500 Subject: [PATCH] CMake: also escape linker flags of the form -Wl,-rpath -Wl,/path/ --- cmake/macros/macro_shell_escape_option_groups.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) 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() -- 2.39.5