[英]How to get the library paths of a meson dependency?
用例:我有一个回退到子项目的依赖项:
./
./subprojects/
./subprojects/mylib.wrap
src/meson.build
包含:
mylib_dep = dependency('mylib') # Searches for mylib with pkg-config then fall backs to mylib.wrap.
myexec_exe = executable ('myexec', 'myexec.c', dependencies : mylib_dep)
依赖mylib_dep
提供库,如果系统上没有安装这些库,会使我的项目的主要可执行文件无法使用:
$ meson build && cd build && meson compile src/my_exec
...snip'd...
$ src/my_exec
src/my_exec: error while loading shared libraries: libmylib.so: cannot open shared object file: No such file or directory
我的测试脚本build/tests/mytests.sh
是来自tests/mytests.sh.in
的configure_file
d 以指示myexec
的位置,我想将库路径传递给它,以便它可以调整LD_LIBRARY_PATH
并运行可执行。 例如,在tests/meson.build
:
conf_data = configuration_data ()
conf_data.set_quoted ('MYEXEC_PATH', myexec_exe.full_path ())
conf_data.set_quoted ('MYLIB_PATH', mylib_dep.??????)
mytest_exe = configure_file (input : 'mytests.sh.in', output : 'mytests.sh', configuration : conf_data)
在tests/mytests.sh.in
:
MYEXEC_PATH=@MYEXEC_PATH@
MYLIB_PATH=@MYLIB_PATH@
export LD_LIBRARY_PATH=$(dirname "$MYLIB_PATH"):$LD_LIBRARY_PATH
$MYEXEC_PATH
问题: ??????
应该在什么地方????? 多于? 换句话说,给定一个依赖项 object,我如何提取其中的库,并获取它们的完整路径?
通常在介子中你不会 configure_file 这个,你会在测试命令中将库/可执行文件作为 arguments 传递给脚本:
test(
'mytest',
find_program('mytest.sh')
args : [executable_target, library_target, ...],
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.