与brew一起安装时,cmake无法使用pkg_search_module找到“ cairo”

时间:2019-10-05 22:40:45

标签: cmake homebrew pkg-config

在使用brew安装软件包的Mac Mojave上,CMake失败

find_package(PkgConfig)
pkg_search_module(CAIRO REQUIRED cairo>=1.12.16)

出现错误消息:

CMake Error at /usr/local/Cellar/cmake/3.15.2/share/cmake/Modules/FindPkgConfig.cmake:696 (message):
  None of the required 'cairo>=1.12.16' found

运行:

pkg-config --modversion cairo

输出当前安装的有效版本1.16.0,但仍未在CMake中找到。

1 个答案:

答案 0 :(得分:0)

运行

pkg-config --exists --print-errors cairo

实际上给出了为什么找不到它的答案:

Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libffi', required by 'gobject-2.0', not found

按照建议,将libffi添加到pkg-config路径将解决此问题。将此添加到您的.bash_profile或仅添加到您的env变量。

export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"

运行brew info libffi时也会给出此信息。