Skip to content
Snippets Groups Projects
Commit 8d71fa92 authored by Gautier Pelloux-Prayer's avatar Gautier Pelloux-Prayer
Browse files

FindPkgConfig: use new version checking "library >= version" syntax

Instead of the deprecated --atleast-version one.
parent cdb6d7df
No related branches found
No related tags found
No related merge requests found
...@@ -360,38 +360,25 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma ...@@ -360,38 +360,25 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma
set(_pkg_check_modules_pkg_ver) set(_pkg_check_modules_pkg_ver)
endif() endif()
# handle the operands _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_VERSION)
if (_pkg_check_modules_pkg_op STREQUAL ">=") _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_PREFIX)
list(APPEND _pkg_check_modules_exist_query --atleast-version) _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_INCLUDEDIR)
endif() _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_LIBDIR)
if (_pkg_check_modules_pkg_op STREQUAL "=")
list(APPEND _pkg_check_modules_exist_query --exact-version)
endif()
if (_pkg_check_modules_pkg_op STREQUAL "<=") list(APPEND _pkg_check_modules_packages "${_pkg_check_modules_pkg_name}")
list(APPEND _pkg_check_modules_exist_query --max-version)
endif()
# create the final query which is of the format: # create the final query which is of the format:
# * --atleast-version <version> <pkg-name> # * <pkg-name> >= <version>
# * --exact-version <version> <pkg-name> # * <pkg-name> = <version>
# * --max-version <version> <pkg-name> # * <pkg-name> <= <version>
# * --exists <pkg-name> # * --exists <pkg-name>
list(APPEND _pkg_check_modules_exist_query --print-errors --short-errors)
if (_pkg_check_modules_pkg_op) if (_pkg_check_modules_pkg_op)
list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_ver}") list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_name} ${_pkg_check_modules_pkg_op} ${_pkg_check_modules_pkg_ver}")
else() else()
list(APPEND _pkg_check_modules_exist_query --exists) list(APPEND _pkg_check_modules_exist_query --exists)
list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_name}")
endif() endif()
list(APPEND _pkg_check_modules_exist_query --print-errors --short-errors)
_pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_VERSION)
_pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_PREFIX)
_pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_INCLUDEDIR)
_pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_LIBDIR)
list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_name}")
list(APPEND _pkg_check_modules_packages "${_pkg_check_modules_pkg_name}")
# execute the query # execute the query
execute_process( execute_process(
......
@ECHO OFF @ECHO OFF
:LOOP
IF "%1"=="" ( IF "%1"=="" (
EXIT /B 255 EXIT /B 255
) )
IF "%1"=="--version" ( IF "%1"=="--version" (
ECHO 0.0-cmake-dummy ECHO 0.0-cmake-dummy
EXIT /B 0 EXIT /B 0
...@@ -13,6 +17,11 @@ IF "%1"=="--exists" ( ...@@ -13,6 +17,11 @@ IF "%1"=="--exists" (
ECHO Found: %PKG_CONFIG_PATH% ECHO Found: %PKG_CONFIG_PATH%
IF NOT "%*"=="%PKG_CONFIG_PATH%" ( IF NOT "%*"=="%PKG_CONFIG_PATH%" (
EXIT /B 1 EXIT /B 1
) ELSE (
EXIT /B 0
) )
) )
EXIT /B 0 SHIFT
IF NOT "%~1"=="" GOTO LOOP
EXIT /B 255
...@@ -4,18 +4,20 @@ ...@@ -4,18 +4,20 @@
# to the --exists argument with the PKG_CONFIG_PATH environment variable # to the --exists argument with the PKG_CONFIG_PATH environment variable
# and returns 1 if they are different. # and returns 1 if they are different.
case $1 in while [ $# -gt 0 ]; do
--version) case $1 in
echo "0.0-cmake-dummy" --version)
;; echo "0.0-cmake-dummy"
--exists) exit 0
shift ;;
eval last=\${$#} --exists)
echo "Expected: ${last}" shift
echo "Found: ${PKG_CONFIG_PATH}" eval last=\${$#}
[ "${last}" = "${PKG_CONFIG_PATH}" ] || exit 1 echo "Expected: ${last}"
;; echo "Found: ${PKG_CONFIG_PATH}"
*) [ "${last}" = "${PKG_CONFIG_PATH}" ] && exit 0 || exit 1
exit 255 ;;
;; esac
esac shift
done
exit 255
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment