meson
meson copied to clipboard
[Feature] Default options for cmake wraps
PR https://github.com/mesonbuild/meson/pull/11730 recently added CMake wraps.
Still, meson is missing a way to provide default options to the CMake subproject. This is required quite frequently, for example to disable tests or set the buildtype.
See https://github.com/mesonbuild/meson/pull/11730#issuecomment-1574291316 for context.
Current workaround:
Add the cmake wrap, then use the cmake module as usual:
dep = dependency('name', required: false)
if not dep.found()
cmake_options = cmake.subproject_options()
cmake_options.add_cmake_defines(...)
subp = cmake.subproject('name', options: cmake_options)
dep = subp.dependency('target'),