Tag Archives: CMake

Unit testing with gtest and cmake

After coding two years for Google, I got used to unit tests. Fortunately, part of the google testing framework is open source, it is called gtest. Using gtest is great, but it is usually not installed on the machine on which I want to compile my stuff. One option to address this problem would be to copy gtest sources in all my projects. That is not very satisfying.

I came up with another solution. Since I’m using cmake anyway, I wrote cmake files that would download sources and compile gtest at project compilation time. This solution avoids code duplication and limits system dependency to subversion which is rather common and easy to install on most development platforms.

If you like the simplicity of this approach, have a look at it and let me know if it works for you. Your pull requests on github are welcome if there is something wrong.