MesonBuild: How to define dependency to a library that cannot be found by `pkg-config`?

后端 未结 2 1500
遇见更好的自我
遇见更好的自我 2021-02-13 09:26

My project (in C) has a third party dependency at build time. But the third party library is, by default, installed to /opt/ instead of /lib, and I can

2条回答
  •  忘掉有多难
    2021-02-13 10:17

    Refer to meson object here : current_source_dir() method returns a string to the current source directory.

    Use it for the case libhello.so and libhello.h are located in /hello directory

    /main.c
    /meson.build
    
    /hello/libhello.so
    /hello/libhello.h
    /hello/meson.build
    

    In /hello/meson.build:

    lib_hello = cc.find_library('hello', dirs : meson.current_source_dir())
    

    In /meson.build:

    project('myproj', 'c')
    subdir('hello')
    
    inc_hello = include_directories('./')
    exec = executable('app',
                      'main.c',
                      dependencies : [lib_hello],
                      include_directories : inc_hello)
    
    

提交回复
热议问题