[cmake-developers] [CMake 0015810]: FindPkgConfig.cmake: error returned to the user may be wrong when checking for package existence

Mantis Bug Tracker mantis at public.kitware.com
Tue Oct 27 01:29:38 EDT 2015


The following issue has been SUBMITTED. 
====================================================================== 
https://cmake.org/Bug/view.php?id=15810 
====================================================================== 
Reported By:                bchretien
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15810
Category:                   Modules
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2015-10-27 01:29 EDT
Last Modified:              2015-10-27 01:29 EDT
====================================================================== 
Summary:                    FindPkgConfig.cmake: error returned to the user may
be wrong when checking for package existence
Description: 
In some cases, CMake returns the following error:

-- Checking for module 'foo'
--   Package 'foo' not found

When the actual error returned by pkg-config is actually:

  Package 'bar', required by 'foo', not found

This seems related to https://cmake.org/Bug/view.php?id=14310, however I did not
have the exact same problem: CMake does stop with an error, just not the correct
one.

Steps to Reproduce: 
I used the same example as in https://cmake.org/Bug/view.php?id=14310

CMakeLists.txt
==============

cmake_minimum_required(VERSION 2.8)
include(FindPkgConfig)
pkg_check_modules(FOO REQUIRED foo)

foo.pc
======

Name: foo
Description: foo
Version: 0

Requires: bar
Cflags: -I/usr/include/foo

Steps
=====

# store both files in a directory
$ PKG_CONFIG_PATH=. cmake .

Expected
========

Failure, explaining that 'foo' was found but `bar` was not.

Current
======

Failure, explaining that 'foo' was not found.

Additional Information: 
I made a patch that solves this issue. Now, the actual error is forwarded to the
user, for instance:

-- Checking for module 'foo'
--   Package 'bar', required by 'foo', not found

For the standard case (i.e. the package was indeed not found), the CMake error
was:

-- Checking for module 'foo'
--   Package 'foo' not found

But with this patch, it now prints:

-- Checking for module 'foo'
--   No package 'foo' found
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2015-10-27 01:29 bchretien      New Issue                                    
2015-10-27 01:29 bchretien      File Added:
0001-FindPkgConfig-return-the-actual-error-when-a-package.patch                 
  
======================================================================



More information about the cmake-developers mailing list