FindPkgConfig does not report *which* required package is missing
Hello there. I would like to preface this by saying I am a relatively new to CMake, and even newer to using pkg-config. I wanted to start this as an issue because I am not sure if the problem I'm facing is due to me maybe just doing this in a very poor way, or if it is actually something that should be remedied.
In my application, I currently try to find some libraries via pkg-config like this:
pkg_check_modules(MYLIBS REQUIRED
libsoup-2.4
json-glib-1.0
protobuf
)
However, when there is a failure (say libsoup isn't available), the error reported from CMake is cryptic
CMake Error at /usr/share/cmake-3.16/Modules/FindPkgConfig.cmake:463 (message):
A required package was not found
without indication of which of the three packages wasn't found. This makes it cumbersome to correct the issue, as I have to just guess which package is missing.
By poking around, I was able to get more info by editing line 463 in FindPkgConfig.cmake to:
if(_pkg_check_modules_failed)
# fail when requested
if (${_is_required})
message(FATAL_ERROR "A required package was not found: ${_pkg_check_modules_pkg_name}")
endif ()
However, I'd like to know if I'm missing something here that would make this change unnecessary. Perhaps some kind of flag to be passed to pkg-config? Guidance would be appreciated!
Addendum: from my command you can see I am running CMake 3.16. However, I checked and this behavior is still present on the master branch.