Commit 83b439f7 authored by Simon McVittie's avatar Simon McVittie

cmake: Match AC_DEFINE more precisely, respecting [] quoting

The regular expression previously used here to select the second
comma-delimited argument won't work when we introduce an argument
containing a comma, which I need to do now. We can address this by
recognising Autoconf's quoting mechanism (which uses square

This is not 100% right (it doesn't understand nested square brackets),
but it's good enough in practice.
Signed-off-by: Simon McVittie's avatarSimon McVittie <>
Acked-by: Philip Withnall's avatarPhilip Withnall <>
parent 3c031ef5
......@@ -108,7 +108,7 @@ macro(autodefine name)
foreach(line ${_configure_ac})
if(line MATCHES ".*AC_DEFINE(.*${name}.*).*")
string (REGEX REPLACE ".*AC_DEFINE(.*).*" "\\1" value ${line})
string (REGEX REPLACE ".*,(.*),.*" "\\1" value2 ${value})
string (REGEX REPLACE "[^[]*\\[[^]]*\\], *\\[([^]]*)\\],.*" "\\1" value2 ${value})
string (REPLACE "[" "" value3 ${value2})
string (REPLACE "]" "" value4 ${value3})
set(${name} ${value4})
......@@ -258,6 +258,9 @@ fi
# default (unless you don't have GLib), because they don't bloat the library
# or binaries.
dnl Don't do anything too subtle here, because the CMake build system
dnl parses these lines with regular expressions. If necessary, adjust
dnl cmake/modules/MacrosAutotools.cmake to compensate.
AC_DEFINE([GLIB_VERSION_MIN_REQUIRED], [GLIB_VERSION_2_40], [Ignore post-2.40 deprecations])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment