如何强制cmake链接自制的keg-only库

Pou*_*uya 10 c++ homebrew cmake readline

我有第三方cmake项目,依赖于gnu readline库.所以我安装了readline brew install readline.问题是,readline是一个只有keg的公式,而cmake试图将它链接到libedit哪个阴影libreadline但它缺少一些功能.

我的问题是,如何强制cmake更喜欢这个库的brew版本而不是系统库?

此外,由于这只是一个osx问题,如果可以通过命令行应用解决方案(而不是更改CMakeList.txt),那将会很棒.

equ*_*-l2 1

摘自brew info readline

For compilers to find readline you may need to set:
  export LDFLAGS="-L/usr/local/opt/readline/lib"
  export CPPFLAGS="-I/usr/local/opt/readline/include"

For pkg-config to find readline you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/readline/lib/pkgconfig"
Run Code Online (Sandbox Code Playgroud)

CMake 使用 pkg-config 来查找库,因此第二段应该适用。