Eliott
Eliott

Reputation: 342

CMake pkg_check_modules does not search the CMAKE_PREFIX_PATH

I am trying to compile a project that uses CMake and pkg_check_modules where I cannot get pkg_check_modules to find libraries located under CMAKE_PREFIX_PATH.

I believe the following example recreates the problem:

If I have libtest.so located in /home/user/test/lib, then given the CMakeLists.txt:

include(FindPkgConfig)
pkg_check_modules(
  TEST
  REQUIRED
  libtest
)

...and running it with:

cmake -DPKG_CONFIG_USE_CMAKE_PREFIX_PATH=TRUE -DCMAKE_PREFIX_PATH=/home/user/test .

...results in the error:

No package 'libtest' found

I also tried running against strace -v -f, which does include an access attempt for /home/user/test/lib/pkgconfig, but logs nothing for libtest.

I am using Ubuntu 16.04 and CMake 3.5.1

Upvotes: 1

Views: 8556

Answers (1)

Tsyvarev
Tsyvarev

Reputation: 66118

Macro pkg_check_modules is a wrapper around pkg-config utility, which searches .pc file and read it. The error

No package 'libtest' found

means that you have no .pc corresponded to the package, or CMake cannot find that file.

Upvotes: 3

Related Questions