Clean up and modernize googletest bundling and usage - Redmine #3033
There is a little bit of noise left from https://gerrit.gromacs.org/c/gromacs/+/7502 but there is also some house keeping we can do.
Because we have moved to CMake 3.9, we could start using the
https://cmake.org/cmake/help/v3.9/module/GoogleTest.html and
https://cmake.org/cmake/help/latest/module/GoogleTest.html#command:gtest_add_tests
We would also like to store a single copy of the googletest source in
the repository, but we need to find a good way to use the bundled source
when building the python_packaging/sample_restraint
tests in the same
build tree.
modernizing usage in CMake
-
Reduce use of global CMake variables for tests and test support targets (https://gerrit.gromacs.org/c/gromacs/+/12197) -
Move custom googletest CMakeLists.txt file out of the way so that we can have a more standard googletest distribution in place. -
Remove global definitions of variables that are redundant with properties of the gtest and gmock targets. -
Import missing googletest files that allow for standard definitions of gtest and gmock targets. Replace GROMACS custom targets with standard targets. -
Migrate consuming targets from variable usage to target dependencies and other modern CMake tools
Update: post-release-2020
Mitigation has included a lot of infrastructure in the form of additional CMake macros. There are also several patches applied to the googletest source that are non-trivial to reapply. Maintainability may be improved by
- simplifying infrastructure in terms behavior from more recent versions of CMake
- updating to more recent googletest in need of less patching - done in !1812 (merged)
- maintaining the googletest patch separate from the googletest source - the size of such a patch was minimized in !1812 (merged)
- isolating the googletest CMake environment, such as with ExternalProject, to reduce the need to manage multiple sets of compiler flags (warning suppressions)
The current issue can be closed when these proposals have been applied, rejected, or moved to separately tracked issues.
(from redmine: issue id 3033, created on 2019-07-11 by eirrgang)
- Relations:
- relates #3027 (closed)
- relates #2756 (closed)
- relates #3198 (closed)
- parent #3047 (closed)
- Changesets:
- Revision e97a85b3 by Eric Irrgang on 2019-07-18T13:36:18Z:
Remove extraneous file.
A file was overlooked in Change-Id: I0d847bc2490935e0ddc3170b674d7460a5a08506
Refs #3033
Change-Id: I4fb6af0b6d51b477091c6305872c0c7124e754d6
- Revision 9efd4499 by Eric Irrgang on 2019-08-02T09:09:15Z:
Reduce conflicts with external googletest files.
Move the custom googletest CMakeLists.txt up a level to src/external so
that we can just drop in the downloaded googletest bundle as it is
distributed. In a future change, we can use the gmock and gtest targets
defined in that infrastructure instead of sculpting our own.
Refs #3033
Change-Id: I4c8ed84195f7673fd798301ba149de8c122ccb05
- Revision 1e4d5573 by Eric Irrgang on 2019-08-06T13:19:11Z:
Convert test infrastructure targets to static library targets.
Convert CMake function `gmx_add_unit_test_object_library()` to
`gmx_add_unit_test_library()` and produce STATIC instead of OBJECT
targets. Update `mdrun_test_objlib` to `mdrun_test_infrastructure`
using the helper function.
This allows the target to use `target_link_libraries` to get the
compiler flags, definitions, and include directories necessary for
compatibility with `gmock` and other resources. Resolves some noisiness
from googletest headers under the standard GROMACS `-Wundef` flag.
Relevant to related change that migrate from global GMOCK variables to
modern usage of gtest and gmock CMake targets.
Removed unnecessary TESTUTILS_LIBS variable.
Refs #3033
Change-Id: Id5b47774b679e8e205f899ea80df65153da44516
- Revision f7940fa0 by Eric Irrgang on 2019-08-07T20:13:10Z:
Use gmock and gtest targets from googletest-release-1.8.0
Import a couple of missing files from the googletest-release-1.8.0 and
switch to the upstream definition of the `gmock` and `gtest` targets.
Removed some outdated content from README.Gromacs
Refs #3033
Change-Id: Iaefe4d11b01a3d37e162d7d00bae7ba34a0b5b4e
- Revision 298f4798 by Eric Irrgang on 2019-08-13T11:25:59Z:
Improve sample_restraint project integration.
Build for testing as part of a gmxapi enabled GROMACS build. Fix some
errors and collisions.
* Use distinct CMake options for using bundled pybind sources in
gmxapi Python package and sample_restraint package.
* Distinguish between "umbrella" build and standalone build when
trying to determine googletest source for sample_restraint.
* Avoid a couple of warnings about unused variables.
* Use GTest::Main target more consistently for sample_restraint tests.
Refs #2056
Refs #3027
Refs #3033
Change-Id: I55d20e6228779ecc726587231c83298356192f6f