How can I check for a library version, and if it is below a certain version (i.e. missing feature X) set a define ?

Currently I have this code, which checks for libsoup and its version. It seems to work.

conf.check_cfg(package='libsoup-2.4', mandatory=True)
conf.check_cfg(package='libsoup-2.4', uselib_store='SOUP', msg='Checking for \'libsoup\' < 2.40', args=['libsoup-2.4 < 2.40', '--cflags', '--libs'], mandatory=False, define_variable={'OLD_SOUP':1,'FRESH_SOUP':0})
conf.check_cfg(package='libsoup-2.4', uselib_store='SOUP', msg='Checking for \'libsoup\' >= 2.40', args=['libsoup-2.4 >= 2.40', '--cflags', '--libs'], mandatory=False, define_variable={'OLD_SOUP':0,'FRESH_SOUP':1})

Is there anything simpler and shorter to do the same job, i.e. with check_cc?

有帮助吗?

解决方案

I ended up with this, I simply overlooked one of check_cfg's many options

ctx.check_cfg(package='libsoup-2.4', uselib_store='SOUP', args=['--cflags', '--libs'], mandatory=True)
ctx.define ('FRESH_SOUP', (ctx.check_cfg(modversion='libsoup-2.4') >= '2.40'))

http://waf.googlecode.com/svn/docs/apidocs/tools/c_config.html#waflib.Tools.c_config.check_cfg

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top