I have a project A that uses meson as the build system and another project B that depends on A.
A runs, compiles and passes all tests. I installed A by doing meson install
, which put all the headers and shared library objects where I needed them to be.
After installing A I want to compile B so I added:
A = dependency('A', include_type : 'system')
exe = executable(
'B',
src,
dependencies: [
A
],
cpp_args : '-DSHADER_PATH="' + meson.current_source_dir() + '/"',)
To the meson.build
of B. meson does find A as a package and starts compiling B but fails to link. A defines a plethora of small utilities, each one as its own independent .so
binary, all of which need to be linked against. Looking at the commands executed when compiling B, the directory where A's .so
libraries are is added to the path using -L
, but none of the libraries in that directory are listed for linking. So linking fials because the symbols in those binaries are not found (obviously they are not linked).
What do I need to specify in A to let it know a given library needs to be linked by default when the project is used as a dependency?
For example this is what one of the utilities of A looks like:
renderer_so_relative_path = \
'' + renderer_lib.full_path().replace(meson.build_root() + '/', '')
peripheral_so_relative_path = \
'' + peripheral_lib.full_path().replace(meson.build_root() + '/', '')
loader_sources = [
'ModuleStorage.cpp',
'CLI.cpp'
]
install_subdir('.', install_dir : 'include/ModuleStorage/')
loader_lib = library(
'ne_loader',
sources : loader_sources,
cpp_args : [
'-DNE_RENDERER_PATH="' + renderer_so_relative_path + '"',
'-DNE_PERIPHERAL_PATH="' + peripheral_so_relative_path + '"'
],
link_with : [],
include_directories : [],
dependencies : [core_dep, image_dep, argparse_dep, glfw],
install: true)
module_storage_dep = declare_dependency(link_with:loader_lib, include_directories: ['..'])
subdir('Imgui')