From 3cf267cfbf740e8c8dc28f132fff5042c7201d3d Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Fri, 7 Jul 2017 22:38:52 +0200 Subject: FindPkgConfig: do not always rerun pkg_check_modules() with 2 arguments Since commit v3.8.0-rc1~47^2 (FindPkgConfig: Recheck pkg-config on parameter change, 2017-01-17) calling `pkg_check_modules` always re-runs. The problem is that if there are only 2 arguments passed to `pkg_check_modules```, then `_module0` will be set and `ARGN` will be empty. When this is written to cache it will be stored as just the value of `_module0` without any semicolon, so on the next run this doesn't match the expected value and the search is rerun. Revise the logic to handle the case of empty `ARGN` separately. Fixes: #17003 --- Modules/FindPkgConfig.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index a5357fa..8ac1691 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -584,7 +584,9 @@ endmacro() macro(pkg_check_modules _prefix _module0) _pkgconfig_parse_options(_pkg_modules _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path _imp_target "${_module0}" ${ARGN}) # check cached value - if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND OR NOT "${__pkg_config_arguments_${_prefix}}" STREQUAL "${_module0};${ARGN}") + if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND OR + (NOT "${ARGN}" STREQUAL "" AND NOT "${__pkg_config_arguments_${_prefix}}" STREQUAL "${_module0};${ARGN}") OR + ( "${ARGN}" STREQUAL "" AND NOT "${__pkg_config_arguments_${_prefix}}" STREQUAL "${_module0}")) _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} "${_prefix}" ${_pkg_modules}) _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION}) -- cgit v0.12