openmicroscopy/bioformats — pull request #1322 by rleigh-dundee (2014-09-04 17:08:38+00:00)
Title: cpp: Add embedded gtest

Add the content of the gtest-1.7.0 source distribution, excluding files for non-cmake build systems. It would also be possible to exclude the samples and tests if required, but this would lead to some failure scenarios since the sample and test building would be exposed to the end user, and they would abort the build if enabled.

Rather than unilaterally dictating that the embedded copy will always be used, we default to using the embedded copy only if a system copy is not available (this may be explicitly overridden). This allows for a distribution-provided or custom build of gtest to be used, which may have patches not in the stock distribution.

Note that this embeds gtest directly, which is what a number of gtest-using projects do. It's also possible to use external sources which can be downloading the zip or checking out the svn. However, this approach is less simple to integrate with our cmake build e.g. to pick up the correct library paths inside the gtest tree. We can consider this for gtest and other libraries, but at present I would like to get things working on Windows without such a radical change, and I've also yet to see an example of this done in a non-platform-specific manner, so it will need further investigation.

--------

Testing. There are three possible configuration scenarios:

1. External gtest specified with GTEST_ROOT
2. Internal gtest without GTEST_ROOT being specified (fallback in the absence of a system GTEST)
3. Internal gtest explicitly enabled (in the presence of a system GTEST)

The respective `cmake` invocation for these, respectively, is:

```
cmake -DGTEST_ROOT=/path/to/gtest /path/to/bioformats
cmake /path/to/bioformats
cmake -DGTEST_ROOT=/path/to/gtest -Dembedded-gtest=ON /path/to/bioformats
```