Cho*_*ong 8 c dependencies meson-build
我的项目(在C中)在构建时具有第三方依赖.但是,默认情况下,第三方库是安装的,/opt/而不是/lib,我找不到它pkg-config.从mesonbuild我的文档中,我应该使用declare_dependency,我没有其源代码将其视为我的子项目.如果我用dependency()它来定义它,我找不到正确的参数来定义自定义位置.
如何声明非标准第三方库的依赖关系?
Yas*_*oji 12
这个[
declare_dependency()] 的主要用例是子项目.
和
[
dependency()]找到一个外部依赖...用pkg-config[或]库特定的回退检测逻辑...
相反,您可以使用
对象find_library()提供的内容. 返回一个对象,就像返回一个对象一样. 返回包含目录的opaque对象.compilerinclude_directories()find_library()declare_dependency()include_directories()
假设你使用的是C编译器和您的第三方库和头文件中/opt/hello/libhello.so和/opt/hello/hello.h,你可以这样做:
project('myproj', 'c')
cc = meson.get_compiler('c')
lib_hello = cc.find_library('hello',
dirs : ['/opt/hello'])
inc_hello = include_directories('/opt/hello')
exec = executable('app',
'main.c',
dependencies : [lib_hello],
include_directories : inc_hello)
Run Code Online (Sandbox Code Playgroud)