Recommended way to set up googletest/googlemock in Visual Studio?

826 views
Skip to first unread message

Mikel Luri

unread,
Nov 21, 2014, 5:07:25 AM11/21/14
to googletes...@googlegroups.com
Hi, 
I've been using gtest/gmock in Visual Studio 2008 for some time now. I initially set it up following the instructions found in http://leefrancis.org/2010/11/17/google-test-gtest-setup-with-microsoft-visual-studio-2008-c/ (there is a link to that in googletest's main page). 

Summarizing, those instructions suggest that you compile gtest using the solution found in the msvc directory, using the right version, according to the C++ Code Generation (/MD or /MT) compiler flag on your project, and then link to gtestd.lib or gtest.lib, depending on the configuration selected, Debug or Release. 

So I did just that with gtest. For gmock, as it did not provide the -md version, I created it, compiled it, set my directory settings in VS, added the "d" to the debug version lib, etc. and well, everything pretty much worked. I initially set everything up for gtest/gmock version 1.6. Upgrading to 1.7 was a bit a pain, having to redo all the steps.

Now, I'm trying to upgrade to VS2013 so I've been taking a look again at how to set gtest/gmock, and I've found that things are not very clear. 
  • To start with, there's still the msvc directory with theprojects and solutions for VS2005 and VS2008, with the -md version for 2005 but not for 2008. Gmock, on the other hand, has three directories in msvc, with versions for VS2005, VS2008 and VS2010 (and up), but no -md version in any of them. 
  • Then we have CMake, which can create the solution and project files we need, with the -md setting you decide. But it doesn't add the "d" to the debug version of the library, so setting it up as a external library is more difficult.
  • So searching how to do it best, I found that it is not recommended to set googletest as a precompiled library (https://groups.google.com/forum/#!topic/googletestframework/Zo7_HOv1MJ0).
So, what is the recommended, most straightforward, way of doing it? Should I copy gmock/gtest to each solution that uses it and add the projects to the solution?

By the way, the first thing I did when tryng to upgrade to VS2013 was to try and find a NuGet package of gtest/gmock. I found one for gtest, but none for gmock. Anyone knows of a NuGet gmock package? That would be really convenient.

Thanks

Mikel

Reply all
Reply to author
Forward
0 new messages