Get cmake and home-brew to work together

后端 未结 1 1285
Happy的楠姐
Happy的楠姐 2021-01-04 15:01

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条回答
  •  执笔经年
    2021-01-04 15:36

    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)
    

    0 讨论(0)
提交回复
热议问题