I've added a new dependency to my build, libcaca:
caca_dep = dependency('caca', version : '>= 0.99.beta14', required : get_option('caca'))
option('caca',
type : 'feature',
value : 'auto',
description : 'Enable/disable caca support')
When I run ninja reconfigure I get:
Dependency caca found: NO
yet the meson log has this to say:
Determining dependency 'caca' with pkg-config executable '/usr/local/bin/pkg-config'
Called `/usr/local/bin/pkg-config --modversion caca` -> 0
0.99.beta19
Dependency caca found: NO
So clearly it finds it but then it claims it does not?!
This is because our version comparison doesn't handle non-numeric characters very well.
Why does meson rolls its own version compare and does not rely on pkg-config for that?
Because we need to support other dependency providers than pkg-config.
Sure but if the tool you use for lookup already supports giving you the right version, why not use that? And for dependency providers that do not offer that, you could do the version compare in meson?
(I probably miss some caveat here why this can't work)
pkg-config does not have a way to both check whether the dependency is new enough and also tell us what the version is, so we'd have to call it twice just to do a single version check, and then we also support multiple version requirements for a dependency, so once for each. This quickly becomes unworkable.
We also need the version checking code to work the same for all dependencies, like Jussi said, and the results must be consistent because the same dependency is often provided in three different ways on different systems: pkg-config, config-tool, internal (subproject).
Thanks for clarifying.
If you'd like to work on this, the pkg-config version compare algorithm is well-known (the same as rpm's) although pkgconf's implementation might be easier to read. We need to change our version_compare() function to use that same algorithm.
My python skills are not that good that I would end up writing not completely horrible code for this, so I don't think I should do this.
I realized I've actually written rpmvercmp in python once already: https://github.com/jon-turney/calm/blob/master/calm/version.py, so maybe I can take a quick look at this...
Most helpful comment
If you'd like to work on this, the pkg-config version compare algorithm is well-known (the same as rpm's) although pkgconf's implementation might be easier to read. We need to change our
version_compare()function to use that same algorithm.