ohj1og
Last Updated: February 25, 2016
·
3.585K
· davidag
12bc786

C++ Google Test & Mock CMake Template

Google Test/Mock CMake template

Basic template for C++ development using Google Test/Mock and CMake. It was initially created for a C++ Testing Hacklab on March 2013.

Usage

  1. Clone my template repository: git clone git://github.com/davidag/gtestmock-cmake-template.git myproject
  2. Run setup.sh to download and install Google Test/Mock and setup debug/release directories.

Other alternatives

Say Thanks
Respond

3 Responses
Add your response

10172
3eae340e049abecfb4a117ad7a907bd1

Personally, I prefer using ExternalProject to retrieve and compile GTest. I also link against GTest default main instead of defining my own.

@see https://github.com/opatry/cpp-cmake-template/tree/master/test

over 1 year ago ·
10181
12bc786

I didn't know about ExternalProject, it seems a nice utility, thank you! And your git repository is a good example of CMake usage, I'll keep an eye on it.

I'll also look into ExternalProject, but for now I think I'll continue to use an environment variable, as it is a quite simple solution and makes me feel more comfortable.

over 1 year ago ·
10219
3eae340e049abecfb4a117ad7a907bd1

Yes you're right it's a straight forward and explicit way, but think about developing with a team and an undetermined number of CI build nodes where your build is effectively executed ;)

Another CMake built-in way to find libraries is find_* (see http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries and official manual for further informations)

over 1 year ago ·
Filed Under