View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0015795 | CMake | Modules | public | 2015-10-16 10:41 | 2016-06-10 14:31 | ||||
Reporter | Sam Thursfield | ||||||||
Assigned To | Rolf Eike Beer | ||||||||
Priority | normal | Severity | minor | Reproducibility | always | ||||
Status | closed | Resolution | moved | ||||||
Platform | OS | OS Version | |||||||
Product Version | CMake 3.3.2 | ||||||||
Target Version | CMake 3.7 | Fixed in Version | |||||||
Summary | 0015795: pkg_check_modules produces incorrect results depending on contents of CMakeCache.txt | ||||||||
Description | I got bitten by a bug involving pkg_check_modules. If I run cmake, then edit my CMakeLists.txt to change the parameters passed to pkg_check_modules, and rerun cmake, it ignores the change that I made to CMakeLists.txt. I needed to delete the CMakeCache.txt file to get the right results. This seems like a cache invalidation bug to me -- a change in the parameters passed to to pkg_check_modules() should cause the cached values to be invalidated. I've attached a small script that reproduces the issue. | ||||||||
Steps To Reproduce | Use attached script. It uses the 'avahi' library as an example, so needs the avahi-devel or libavahi-dev package (or whatever else your distro calls it) to be installed. Any two pkg-config modules will trigger the same error. Output on my machine: Creating initial CMakeLists.txt Avahi libs should be: avahi-gobject AVAHI LIBS: avahi-gobject;avahi-common;avahi-client;avahi-glib;glib-2.0 Updating pkg_check_modules call Avahi libs should be: avahi-gobject;avahi-common;avahi-client;avahi-glib;glib-2.0 AVAHI LIBS: avahi-gobject;avahi-common;avahi-client;avahi-glib;glib-2.0 Removing cache and trying again Avahi libs should be: avahi-gobject;avahi-common;avahi-client;avahi-glib;glib-2.0 AVAHI LIBS: avahi-gobject;avahi-common;avahi-client;avahi-glib;glib-2.0 | ||||||||
Tags | No tags attached. | ||||||||
Attached Files | testcase.sh [^] (854 bytes) 2015-10-16 10:41 | ||||||||
Relationships | |
Relationships |
Notes | |
(0039622) Sam Thursfield (reporter) 2015-10-16 10:45 |
Oops, the output of the test case I posted is with an existing CMakeCache.txt. If you run with no CMakeCache.txt you will see this: Creating initial CMakeLists.txt Avahi libs should be: avahi-gobject AVAHI LIBS: avahi-gobject Updating pkg_check_modules call Avahi libs should be: avahi-gobject;avahi-common;avahi-client;avahi-glib;glib-2.0 AVAHI LIBS: avahi-gobject Removing cache and trying again Avahi libs should be: avahi-gobject;avahi-common;avahi-client;avahi-glib;glib-2.0 AVAHI LIBS: avahi-gobject;avahi-common;avahi-client;avahi-glib;glib-2.0 Both examples show that something is wrong! |
(0041131) FlorianM (reporter) 2016-06-02 15:49 edited on: 2016-06-02 15:51 |
Recently this issue came up again on SO, see http://stackoverflow.com/questions/37026867/how-to-make-cmake-recheck-versions-of-dependencies-automatically [^] After doing some testing, I believe that adding `${ARGV}` to `__pkg_config_checked_${_prefix}` variable would retrigger the scanning for the package when arguments to the `pkg_check_modules()` or `pkg_search_module()` calls are changed. Thanks in advance for any feedback on this proposed fix. Here is my patch for FindPkgConfig.cmake version as of 21th March, 2016: --- FindPkgConfig.cmake +++ FindPkgConfig.cmake @@ -523,11 +523,13 @@ #]========================================] macro(pkg_check_modules _prefix _module0) # check cached value - if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) + if (NOT DEFINED __pkg_config_checked_${_prefix} OR + NOT __pkg_config_checked_${_prefix} STREQUAL "${PKG_CONFIG_VERSION},${ARGV}" OR + NOT ${_prefix}_FOUND) _pkgconfig_parse_options (_pkg_modules _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path "${_module0}" ${ARGN}) _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" ${_no_cmake_path} ${_no_cmake_environment_path} "${_prefix}" ${_pkg_modules}) - _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION}) + _pkgconfig_set(__pkg_config_checked_${_prefix} "${PKG_CONFIG_VERSION},${ARGV}") endif() endmacro() @@ -550,7 +552,9 @@ #]========================================] macro(pkg_search_module _prefix _module0) # check cached value - if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) + if (NOT DEFINED __pkg_config_checked_${_prefix} OR + NOT __pkg_config_checked_${_prefix} STREQUAL "${PKG_CONFIG_VERSION},${ARGV}" OR + NOT ${_prefix}_FOUND) set(_pkg_modules_found 0) _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path "${_module0}" ${ARGN}) @@ -575,7 +579,7 @@ endif() endif() - _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION}) + _pkgconfig_set(__pkg_config_checked_${_prefix} "${PKG_CONFIG_VERSION},${ARGV}") endif() endmacro() |
(0042858) Kitware Robot (administrator) 2016-06-10 14:29 |
Resolving issue as `moved`. This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page. |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2015-10-16 10:41 | Sam Thursfield | New Issue | |
2015-10-16 10:41 | Sam Thursfield | File Added: testcase.sh | |
2015-10-16 10:45 | Sam Thursfield | Note Added: 0039622 | |
2016-06-02 15:49 | FlorianM | Note Added: 0041131 | |
2016-06-02 15:51 | FlorianM | Note Edited: 0041131 | |
2016-06-02 15:52 | Brad King | Assigned To | => Rolf Eike Beer |
2016-06-02 15:52 | Brad King | Status | new => assigned |
2016-06-02 15:52 | Brad King | Target Version | => CMake 3.7 |
2016-06-10 14:29 | Kitware Robot | Note Added: 0042858 | |
2016-06-10 14:29 | Kitware Robot | Status | assigned => resolved |
2016-06-10 14:29 | Kitware Robot | Resolution | open => moved |
2016-06-10 14:31 | Kitware Robot | Status | resolved => closed |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |