View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014310CMakeModulespublic2013-07-24 20:492016-06-10 14:31
ReporterMichał Sawicz 
Assigned ToKitware Robot 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionmoved 
PlatformLinuxOSUbuntuOS Version13.10
Product VersionCMake 2.8.11.2 
Target VersionFixed in Version 
Summary0014310: pkg_check_modules(FOO REQUIRED foo) completes even if foo's pkgconfig dependencies failed
DescriptionWhen a .pc file contains a "Required: bar", CMake should fail if the module was REQUIRED and bar wasn't found.

pkg-config exits with exit code 1, but CMake proceeds like nothing happened, FOO_FOUND is set to 1, while all the other FOO_* remain empty.

This obfuscates missing dependencies and lets the build process continue, failing then due to missing headers / libraries.
Steps To ReproduceCMakeLists.txt
==============
cmake_minimum_required(VERSION 2.8)

include(FindPkgConfig)

pkg_check_modules(FOO REQUIRED foo)

message("${FOO_FOUND}")
message("${FOO_INCLUDE_DIRS}")


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

Current
=======
quiet failure
Additional InformationCMake Output
============

$ PKG_CONFIG_PATH=. cmake .
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.26")
-- checking for module 'foo'
-- found foo, version 0
Package bar was not found in the pkg-config search path.
Perhaps you should add the directory containing `bar.pc'
to the PKG_CONFIG_PATH environment variable
# === repeated multiple times ===
1

-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/tmp
TagsNo tags attached.
Attached Filespatch file icon cmake-pkgconfig-required.patch [^] (5,060 bytes) 2013-11-15 03:43 [Show Content]

 Relationships

  Notes
(0034453)
Arnaud Fontaine (reporter)
2013-11-15 03:42

I get the same issue when pkgconfig fails when being called from _pkgconfig_invoke_dyn (FindPkgConfig.cmake as of cmake 2.8.12) for cflags as the exit status is not checked at this stage but only before.

I have attached a patch which fixes this issue even though it may not be that clean as I don't know cmake so well.
(0035032)
Arnaud Fontaine (reporter)
2014-02-03 21:33

Anyone has had time to review the patch? Thanks.
(0037466)
sobczyk (reporter)
2014-12-16 06:24

Are there any plans to fix this?
(0039679)
Dan Kegel (reporter)
2015-10-26 11:35

Still present as of 3.4-rc1.

I'm considering working around it by only passing one library at a time,
and checking FOO_LIBRARIES rather than FOO_FOUND. If FOO_LIBRARIES is empty,
we've hit this bug, and I'll terminate my CMakeLists.txt.
(0042325)
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.

 Issue History
Date Modified Username Field Change
2013-07-24 20:49 Michał Sawicz New Issue
2013-11-15 03:42 Arnaud Fontaine Note Added: 0034453
2013-11-15 03:43 Arnaud Fontaine File Added: cmake-pkgconfig-required.patch
2014-02-03 21:33 Arnaud Fontaine Note Added: 0035032
2014-12-16 06:24 sobczyk Note Added: 0037466
2015-10-26 11:35 Dan Kegel Note Added: 0039679
2016-06-10 14:29 Kitware Robot Note Added: 0042325
2016-06-10 14:29 Kitware Robot Status new => resolved
2016-06-10 14:29 Kitware Robot Resolution open => moved
2016-06-10 14:29 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team