#1401 CMake doesn't always honor environment variables like CXXFLAGS
Metadata
Property | Value |
---|---|
Reported by | Steffen Müthing (steffen.muething@iwr.uni-heidelberg.de) |
Reported at | Dec 18, 2013 23:11 |
Type | Bug Report |
Version | Git (pre2.4) [autotools] |
Operating System | Mac OS |
Last edited by | Steffen Müthing (steffen.muething@iwr.uni-heidelberg.de) |
Last edited at | Jan 29, 2014 12:57 |
Closed by | Steffen Müthing (steffen.muething@iwr.uni-heidelberg.de) |
Closed at | Jan 29, 2014 12:57 |
Closed in version | 2.3 |
Resolution | Fixed |
Comment | Fixed in dune-common b01c777 |
Description
When playing around with CMake, I noticed that it didn't pick up my settings for the compilers and their flags. After digging around in dunecontrol for a little bit, I think the culprit is the following piece of regex magic to extract variables like CXX and CXXFLAGS from CONFIGURE_FLAGS:
cflags=echo "$PARAMS" | sed "s/.*($i="[^"]*"|$i='[^']*'|$i=[^s^ ]*).*/1/"
That line is supposed to extract something like CXXFLAGS="…" from CONFIGURE_FLAGS ($PARAMS is identical to that variable here). The variable to extract is given in $i. The regex tries to cater to the three cases CXXFLAGS="…", CXXFLAGS='…' and CXX=gcc-4.9 (three different quotation styles). My CONFIGURE_FLAGS contain the two latter styles, which the expression fails to extract.
I got it to work by replacing sed with "perl -pe" and removing some escapes from the parentheses etc.:
cflags=echo "$PARAMS" | perl -pe "s/.*($i="[^"]*"|$i='[^']*'|$i=[^s ]*).*/1/"
I know that some people don't want to rely too much on perl in the build system, but I really don't have time to sink into fixing that regex to be POSIX-compatible (I think POSIX doesn't have s, for example) and work correctly in conjunction with the shell escaping, so are there any objections to switching to perl for this? I think a system with cmake will probably also have perl available...