View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015810CMakeModulespublic2015-10-27 01:292016-03-07 09:12
Reporterbchretien 
Assigned ToBrad King 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product VersionCMake 3.3.2 
Target VersionCMake 3.5Fixed in VersionCMake 3.5 
Summary0015810: FindPkgConfig.cmake: error returned to the user may be wrong when checking for package existence
DescriptionIn 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 ReproduceI 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 InformationI 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
TagsNo tags attached.
Attached Filespatch file icon 0001-FindPkgConfig-return-the-actual-error-when-a-package.patch [^] (2,271 bytes) 2015-10-27 01:29 [Show Content]
patch file icon 0001-FindPkgConfig-return-the-actual-error-when-a-package2.patch [^] (2,993 bytes) 2015-10-27 11:12 [Show Content]

 Relationships

  Notes
(0039681)
Brad King (manager)
2015-10-27 09:34

Thanks for working on this. Do the --print-errors --short-errors options exist on all (old) versions of pkg-config?

Also this change makes the RunCMake.FindPkgConfig test fail. Please revise accordingly.
(0039682)
bchretien (reporter)
2015-10-27 09:49

According to the pkg-config changelog (http://cgit.freedesktop.org/pkg-config/tree/ChangeLog [^] at least the one until 2009), --print-errors was added in 2001, and --short-errors in 2005 (release 0.20).

I will update the patch with the fixed test.
(0039683)
bchretien (reporter)
2015-10-27 11:13

AFAIK, I could not upload a patch with the same name or remove the previous one, so I uploaded 0001-FindPkgConfig-return-the-actual-error-when-a-package2.patch.
(0039697)
Brad King (manager)
2015-10-28 10:22

Thanks, applied:

 FindPkgConfig: return actual error when a package is not found
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1bfb527f [^]
(0039698)
bchretien (reporter)
2015-10-28 10:50

Perfect, thanks!
(0040630)
Robert Maynard (manager)
2016-03-07 09:12

Closing resolved issues that have not been updated in more than 4 months.

 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
2015-10-27 09:34 Brad King Note Added: 0039681
2015-10-27 09:49 bchretien Note Added: 0039682
2015-10-27 11:12 bchretien File Added: 0001-FindPkgConfig-return-the-actual-error-when-a-package2.patch
2015-10-27 11:13 bchretien Note Added: 0039683
2015-10-28 10:22 Brad King Note Added: 0039697
2015-10-28 10:22 Brad King Assigned To => Brad King
2015-10-28 10:22 Brad King Status new => resolved
2015-10-28 10:22 Brad King Resolution open => fixed
2015-10-28 10:22 Brad King Fixed in Version => CMake 3.5
2015-10-28 10:22 Brad King Target Version => CMake 3.5
2015-10-28 10:50 bchretien Note Added: 0039698
2016-03-07 09:12 Robert Maynard Note Added: 0040630
2016-03-07 09:12 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team