#964221 googletest: meson support

#964221#5
Date:
2020-07-03 20:14:18 UTC
From:
To:
googletest is weirdly special in that it is supposed to be compiled together
with the project that is being tested, using the same flags. As such it ships
with source files and not just a shared library that can be imported using
pkg-config. Right now it supports cmake as-is.

Meson is a (new?) build system that is gaining in popularity. Right now what a
meson-using upstream project can do to manage its dependencies tightly is to
use so-called "wraps" that patch meson.build build system definitions from the
internet on top of an arbitrary upstream source that does not support meson
yet. So for gtest there is [1], which ships a zip for 1.10.0 at [2] that
contains three meson.build files and one LICENSE.build.

Would it be possible for googletest in Debian to ship these meson.build files
alongside the source in the library packages? That way packages could
build-depend on libgtest-dev without requiring them to use CMake.

Kind regards and thanks
Philipp Kern

[1] https://wrapdb.mesonbuild.com/gtest
[2] https://wrapdb.mesonbuild.com/v1/projects/gtest/1.10.0/1/get_wrap

#964221#10
Date:
2020-10-20 01:25:16 UTC
From:
To:
It's a reasonable request.  Where in the filesystem would you like to see these
three files?

#964221#13
Date:
2020-10-20 01:26:20 UTC
From:
To:
It's a reasonable request.  Where in the filesystem would you like to see these
three files?

#964221#18
Date:
2020-10-28 09:37:07 UTC
From:
To:
Hey Steven,

The wrap is pretty specific in that googletest and googlemock have to be
subdirectories. So effectively the wrap is unzipped today at the
/usr/src/googletest level - which seems very reasonable to me as it
mimics the existing CMakeLists.txt layout as well.

Kind regards and thanks
Philipp Kern

#964221#23
Date:
2021-09-16 02:32:28 UTC
From:
To:
these

You may have noticed its almost a year later and I did not address this bug.
:-(

I just packaged new googletest 1.11.0.  I did look for a meson wrap but was
not successful.  The wrap files for 1.10 are pretty simple and I thought about
just blindly using them -- but I don't want to be guessing.  Do you have a
suggestion on how to test this meson-wrapped gtest?

#964221#28
Date:
2021-09-24 18:44:12 UTC
From:
To:
Hi Steve,
The simplest way is to set up a meson subproject "gtest" by
symlinking to /usr/src/googletest. I attached a toy project as an
example.

Unfortunately, the symlink has to be created manually as a hack, because

a) the meson developers have a rather strict policy to not include
arbitrary external folders as "subdirectories", such as it could be
done with CMake via

     add_subdirectory(/usr/src/googletest googletest-build)


b) there is no way yet[1] for Debian to intercept wrap downloads
and substitute them with locally installed versions.

Personally, I don't see much reason to force a compile from source
for GTest anyway (besides the usual one, Google being Google wants
to do it their way), so I'd simply go with

     gtest_main_dep = dependency(
         'gtest_main',
	fallback: ['gtest', 'gtest_main_dep']
     )

This will find GTest using pkg-config and use the wrapper as
fallback if it is not available.

Cheers
Timo


[1] The maven package in Debian has a cool implementation for this,
maybe the concept can be adopted for meson.