Get cmake and home-brew to work together

▼魔方 西西 提交于 2019-12-21 12:18:16

问题


When I install libraries with homebrew cmake can't seem to find them. Is there a simple way to fix this for an arbitrary library installed with brew.


回答1:


Default

By default brew's libraries installed to /usr/local/lib folder:

> ls /usr/local/lib/liblzma.dylib 
/usr/local/lib/liblzma.dylib@

Check that this path exists in CMAKE_SYSTEM_PREFIX_PATH variable. In this case find is trivial:

message("system: ${CMAKE_SYSTEM_PREFIX_PATH}")
find_library(LZMA_LIBRARY lzma)
message("lzma: ${LZMA_LIBRARY}")

Result:

system: /usr/local;/usr;/;...
lzma: /usr/local/lib/liblzma.dylib

Otherwise

If it is not you need to modify CMAKE_PREFIX_PATH or CMAKE_LIBRARY_PATH before find_library command:

list(APPEND CMAKE_PREFIX_PATH /usr/local)


来源:https://stackoverflow.com/questions/21685809/get-cmake-and-home-brew-to-work-together

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!