Bug #757
Don't match '-l' in '-L/usr/lib/x86_64-linux-gnu/hdf5/serial' in FindNETCDF _netcdf_dashl regex
Status: | Closed | Start date: | 2015-08-24 | |
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assignee: | % Done: | 0% | ||
Category: | - | |||
Target version: | Candidate for next bugfix release | |||
Affected version: | 5.1.x | Platform: | Linux |
Description
The netcdf transition in Debian has started as part of the ongoing GCC 5 transitions in which netcdf was upgraded from 4.1.3 to 4.4.0-rc2.
The build of the gmt Debian package fails because the _netcdf_dashl regex in FindNETCDF incorrectly matches '-linux-gnu/hdf5/serial' as a linker flag.
The attached patch fixes the regex by requiring '-l' to be preceded a space or be the first character in the string.
History
#1
Updated by Paul over 5 years ago
- Status changed from New to In Progress
- Assignee set to Florian
Passing this to Florian for review and adoption.
#2
Updated by Remko over 5 years ago
- In the patch file there is this expression:
string (REGEX REPLACE "(^| )-l" "" _netcdf_lib "${_netcdf_dashl}")
In case the -l is preceded by a space, this will eat the space. I don't think that will hurt anybody, but I would like to point it out. - I think the same should be done with the "-L", i.e.
string (REGEX MATCHALL "(^| )-L[^ ]+" _netcdf_dashL ${NETCDF_CONFIG_LIBS}) string (REGEX REPLACE "(^| )-L" "" _netcdf_libpath "${_netcdf_dashL}")
#3
Updated by Bas over 5 years ago
- File netcdf-library-regex2.patch
added
Remko wrote:
I see two issues with this patch.
- In the patch file there is this expression:
[...]
In case the -l is preceded by a space, this will eat the space. I don't think that will hurt anybody, but I would like to point it out.
That's why the REGEX REPLACE
strips the preceding space too:
string (REGEX MATCHALL "(^| )-l[^ ]+" _netcdf_dashl ${NETCDF_CONFIG_LIBS}) string (REGEX REPLACE "(^| )-l" "" _netcdf_lib "${_netcdf_dashl}")
The resulting _netcdf_lib
will be without spaces as expected:
netcdf;hdf5_hl;hdf5;pthread;z;dl;m;curl
Here's some debugging output of the variables in question without this patch:
-- NETCDF_CONFIG_CFLAGS(pre): -I/usr/include -I/usr/include/hdf5/serial -- _netcdf_dashI: -I/usr/include;-I/usr/include/hdf5/serial -- _netcdf_includepath: /usr/include;/usr/include/hdf5/serial -- _netcdf_cflags_other: -- NETCDF_CONFIG_LIBS(pre): -L/usr/lib -L/usr/lib/x86_64-linux-gnu/hdf5/serial -lnetcdf -lhdf5_hl -lhdf5 -lpthread -lz -ldl -lm -lcurl -- _netcdf_dashl: -linux-gnu/hdf5/serial;-lnetcdf;-lhdf5_hl;-lhdf5;-lpthread;-lz;-ldl;-lm;-lcurl -- _netcdf_lib: inux-gnu/hdf5/serial;netcdf;hdf5_hl;hdf5;pthread;z;dl;m;curl -- _netcdf_dashL: -L/usr/lib;-L/usr/lib/x86_64-linux-gnu/hdf5/serial -- _netcdf_libpath: /usr/lib;/usr/lib/x86_64-linux-gnu/hdf5/serial -- NETCDF_CONFIG_CFLAGS(post): -I/usr/include -I/usr/include/hdf5/serial -- NETCDF_CONFIG_LIBS(post): -L/usr/lib -L/usr/lib/x86_64-linux-gnu/hdf5/serial -lnetcdf -lhdf5_hl -lhdf5 -lpthread -lz -ldl -lm -lcurl -- _netcdf_lib(pre): inux-gnu/hdf5/serial;netcdf;hdf5_hl;hdf5;pthread;z;dl;m;curl -- _netcdf_lib(post): inux-gnu/hdf5/serial;hdf5_hl;hdf5;pthread;z;dl;m;curl
And with this patch:
-- NETCDF_CONFIG_CFLAGS(pre): -I/usr/include -I/usr/include/hdf5/serial -- _netcdf_dashI: -I/usr/include;-I/usr/include/hdf5/serial -- _netcdf_includepath: /usr/include;/usr/include/hdf5/serial -- _netcdf_cflags_other: -- NETCDF_CONFIG_LIBS(pre): -L/usr/lib -L/usr/lib/x86_64-linux-gnu/hdf5/serial -lnetcdf -lhdf5_hl -lhdf5 -lpthread -lz -ldl -lm -lcurl -- _netcdf_dashl: -lnetcdf; -lhdf5_hl; -lhdf5; -lpthread; -lz; -ldl; -lm; -lcurl -- _netcdf_lib: netcdf;hdf5_hl;hdf5;pthread;z;dl;m;curl -- _netcdf_dashL: -L/usr/lib;-L/usr/lib/x86_64-linux-gnu/hdf5/serial -- _netcdf_libpath: /usr/lib;/usr/lib/x86_64-linux-gnu/hdf5/serial -- NETCDF_CONFIG_CFLAGS(post): -I/usr/include -I/usr/include/hdf5/serial -- NETCDF_CONFIG_LIBS(post): -L/usr/lib -L/usr/lib/x86_64-linux-gnu/hdf5/serial -lnetcdf -lhdf5_hl -lhdf5 -lpthread -lz -ldl -lm -lcurl -- _netcdf_lib(pre): netcdf;hdf5_hl;hdf5;pthread;z;dl;m;curl -- _netcdf_lib(post): hdf5_hl;hdf5;pthread;z;dl;m;curl
- I think the same should be done with the "-L", i.e.
[...]
Applying the same change to the -I
& -L
regexes is a good idea, but not strictly required.
The include & libraries paths are much less likely to include "-I" or "-L" in their paths as is the case for "-l" in the Multi-Arch library path.
I've updated the patch to apply the change to the other regexes too.
#4
Updated by Remko over 5 years ago
- Status changed from In Progress to Resolved
Fixed in r14773 thanks to patch by Bas.