Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force cmake to link against homebrew keg-only libraries

I have third party cmake project that depends on gnu readline library. So I installed readline by brew install readline. The problem is, readline is a keg-only formula and cmake tries to link it against libedit which shadows libreadline but it lacks some functionalities.

My question is, how can I force cmake to prefer brew version of this library over the system library?

Also, since this would be a osx only problem, it would be great if solution can be applied via command line (instead of changing CMakeList.txt).

like image 536
Pouya Avatar asked May 31 '16 14:05

Pouya


1 Answers

Excerpt from 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"

CMake uses pkg-config for finding a library, so the second paragraph should apply.

like image 92
equal-l2 Avatar answered Nov 14 '22 22:11

equal-l2