From 206f126617602ffa0b46b4eb45a9d41b6047d24f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 12 Aug 2023 16:29:46 +1000 Subject: [PATCH] Fix regression in remove_cc_flag macro Recent change in [0] caused the CFLAGS variables not to be manipulated by remove_cc_flag. Unfortunately EVAL is needed to set a variable that references a variable name. [0]: e95e6ad66a8341641b6086806ebcc5988ed12ac0 --- build_files/cmake/macros.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 5acb3bd13c5..cef3b31001d 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -753,7 +753,12 @@ macro(remove_cc_flag foreach(_flag ${ARGV}) foreach(_var ${_flag_vars}) - string(REGEX REPLACE ${_flag} "" "${_var}" "${${_var}}") + # Expands to an expression like: + # `string(REGEX REPLACE "${_flag}" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")` + cmake_language( + EVAL CODE + "string(REGEX REPLACE \"\$\{_flag\}\" \"\" ${_var} \"\$\{${_var}\}\")" + ) endforeach() endforeach()