[CMake] PKGCONFIG("dbus-1 >= 1.0.0" ...) should also possible

Alexander Neundorf a.neundorf-work at gmx.net
Sat Jan 13 08:02:23 EST 2007


Von: Claus Klein <claus.klein at arcormail.de>

> I have reviewed  the code of the new FindPkgConfig.cmake and I think, the
> version check part:
> line209,242
> ---------------------------------------------------------
>       # check whether version is given
>       if (_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*")
>         string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\1"
> _pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}")
>         string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\2"
> _pkg_check_modules_pkg_op   "${_pkg_check_modules_pkg}")
>         string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\3"
> _pkg_check_modules_pkg_ver  "${_pkg_check_modules_pkg}")
>       else(_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*")
>         set(_pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}")
>         set(_pkg_check_modules_pkg_op)
>         set(_pkg_check_modules_pkg_ver)
>       endif(_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*")
> 
>       # handle the operands
>       if (_pkg_check_modules_pkg_op STREQUAL ">=")
>         list(APPEND _pkg_check_modules_exist_query --atleast-version)
>       endif(_pkg_check_modules_pkg_op STREQUAL ">=")
> 
>       if (_pkg_check_modules_pkg_op STREQUAL "=")
>         list(APPEND _pkg_check_modules_exist_query --exact-version)
>       endif(_pkg_check_modules_pkg_op STREQUAL "=")
>       
>       if (_pkg_check_modules_pkg_op STREQUAL "<=")
>         list(APPEND _pkg_check_modules_exist_query --max-version)
>       endif(_pkg_check_modules_pkg_op STREQUAL "<=")
> 
>       # create the final query which is of the format:
>       # * --atleast-version <version> <pkg-name>
>       # * --exact-version <version> <pkg-name>      
>       # * --max-version <version> <pkg-name>
>       # * --exists <pkg-name>
>       if (_pkg_check_modules_pkg_op)
>         list(APPEND _pkg_check_modules_exist_query
> "${_pkg_check_modules_pkg_ver}")
>       else(_pkg_check_modules_pkg_op)
>         list(APPEND _pkg_check_modules_exist_query --exists)
>       endif(_pkg_check_modules_pkg_op)
> ---------------------------------------------------------
> could be simpler and perhaps faster if the pkg-config features would be
> used:
> 
> >from man:pkg-config(1):
> ---------------------------------------------------------
>        --atleast-version=VERSION
>        --exact-version=VERSION
>        --max-version=VERSION
> 
>              Rather than using the version-test options, you can simply
> give a version constraint after each package
>               name, for example:
>                 $ pkg-config --exists 'glib-2.0 >= 1.3.4 libxml = 1.8.3'
>               Remember to use --print-errors if you want error messages.
> ---------------------------------------------------------
> 
> You only have to quote the args to pkg-config as in the example.
> 
> Just to keep it simple :-)

I'm not the author of this module. 
Can you create a patch and check whether it works ?

Bye
Alex

-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer


More information about the CMake mailing list