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 cannot find it in pkg-config
. From mesonbuild
's documentation, should I use declare_dependency
, I don't have its source code to treat it as my sub-project. If I use dependency()
to define it, I can't find the correct argument to define a customized location.
How to declare dependency for a non-standard third party library?
As documented here and here
and
You can, instead, use
find_library()
provided by thecompiler
object andinclude_directories()
.find_library()
returns an object just like the onedeclare_dependency()
returns.include_directories()
returns an opaque object which contains the directories.Assuming you are using a C compiler and your 3rd party library and its header file are
/opt/hello/libhello.so
and/opt/hello/hello.h
, you can do:Refer to
meson
object here : current_source_dir() method returns a string to the current source directory.Use it for the case
libhello.so
andlibhello.h
are located in<workspace>/hello
directoryIn
<workspace>/hello/meson.build
:In
<workspace>/meson.build
: