I have a subproject in meson that uses imgui. Due to a bug in meson, I have to override a command line argument for imgui, otherwise things won't compile:
i.e. I do something like this:
imgui_lib = library(
'imgui',
sources : [imgui_sources],
dependencies : [dependency('imgui')],
include_directories : [
'../../../ext/imgui/bindings'
],
cpp_args : ['-DIMGUI_USER_CONFIG="imgui_user_config.h"'])
imgui_dep = declare_dependency(
link_with:imgui_lib,
include_directories: [
'.',
imgui_bindings,
])
The bug is that meson deletes quotations in variables so -DIMGUI_USER_CONFIG="imgui_user_config.h"
becomes -DIMGUI_USER_CONFIG=imgui_user_config.h
Which is trivially wrong and causes compilation errors.
This works fine, however it requires me to repeat this pattern whenever I use imgui, i.e. I have to do that override every single time, which is not fun.
I want, as part of my imgui_dep
object for the imgui path to be part of the includes, i.e. I want something like:
imgui_dep = declare_dependency(
link_with:imgui_lib,
include_directories: [
'.',
imgui_bindings,
imgui.get_include_dirs()
])
So far I tried:
imgui.get_variable('includedir')
But this results in the error:
ERROR: Could not get pkg-config variable and no default provided for <PkgConfigDependency imgui: True None>
All I want is the path to the include directories in that dependency, that's it, how do I fetch them?
What I usually do is simple:
my_lib_inc_dir = './my_lib/includes'
# Create dependency
my_lib_dep = declare_dependency(
dependencies: my_lib,
include_directories: include_directories(my_lib_inc_dir)
)
And then just link your lib with this dependency and it pulls include dir location automatically.