Search code examples
cmakedependenciesversionversioningdependency-management

pkg_config_modules dependency fails because version in "Uncontrolled"


The Problem

I've got a CMakeLists.txt file with this content:

pkg_check_modules(FOO REQUIRED foo>=0.1.0.1)

When I run Cmake v3.17.2 with cmake3 -G Ninja . in that directory:

Checking for module 'foo>=0.1.0.1'
  Requested 'foo >= 0.1.0.1' but version of foo is Uncontrolled

Details

  • This is running inside RHEL7
  • yum info foo | grep Version returns Version : 0.1.0.1.20200417git602d018
  • The foo module is created by the team I'm on

The Question

How can I tell CMake what version my foo library is so that it isn't "Uncontrolled"?


Solution

  • In the output of the foo project, inside of the generated lib64 directory, there's a pkgconfig directory which contains foo.pc.

    Inside of that file, version info is as follows:

    Version: HEAD

    Change this to be the intended version. In my case this was automated by the build process of foo, so what was required was to add a git tag for the current version and rebuild.