FindPkgConfig fails to honor CMAKE_SYSTEM_PREFIX_PATH (set via CMAKE_INSTALL_PREFIX)
I frequently use CMAKE_INSTALL_PREFIX
to work on projects in local (non system-wide) folders. This includes installing library dependencies locally as well. However I've noticed that the pkg_check_modules
in FindPkgConfig.cmake
fails to check these local folders when scanning for packages. This is because it checks subfolders of CMAKE_PREFIX_PATH
but not CMAKE_SYSTEM_PREFIX_PATH
(see https://gitlab.kitware.com/cmake/cmake/blob/v3.21.4/Modules/FindPkgConfig.cmake#L316-326). Should CMAKE_SYSTEM_PREFIX_PATH
be added to the list of variables for completeness?
I've attached a sample project to illustrate the problem. Instructions below...
$ tar -xzvf hello-sqlite3.tar.gz
$ mkdir -p hello-sqlite3/third_party/build && cd hello-sqlite3/third_party/build
$ cmake .. -DCMAKE_INSTALL_PREFIX=../../out
$ make
$ cd ..
$ mkdir build && cd build
$ cmake .. -DCMAKE_INSTALL_PREFIX=../out
$ make
Edited by Brad King