Skip to content

PkgConfig: Fix error not being printed when library version was specified

Gautier Pelloux-Prayer requested to merge bagage/cmake:master into master

Currently, if one uses pkg_check_modules with the following syntax pkg_check_modules(somelibrary>=3.22) when the library is not found by pkg-config, cmake output will be:

 -- Checking for modules 'lib1;lib2>=3.14.0;libsoup-2.4=2.48'
--   No package 'lib1' found
--   
--   
CMake Error at /usr/share/cmake-3.7/Modules/FindPkgConfig.cmake:415 (message):
  A required package was not found

While it is expected to be:

 -- Checking for modules 'lib1;lib2>=3.14.0;libsoup-2.4=2.48'
--   No package 'lib1' found
--   No package 'lib2' found
--   Requested 'libsoup-2.4 = 2.48' but version of libsoup is 2.56.0
CMake Error at /usr/share/cmake-3.7/Modules/FindPkgConfig.cmake:416 (message):
  A required package was not found

Here is a minimal CMakeLists.txt for info:

cmake_minimum_required(VERSION 3.7)

include(FindPkgConfig)

pkg_check_modules(DEPS REQUIRED
    lib1
    lib2>=3.14.0
    libsoup-2.4=2.48
)

Merge request reports