Reputation: 292
I'm really new to cmake, I'm using it because I want to build gtest for multiple versions of VS at the same time. I havent been able to generate anything using cmake yet.. maybe its overkill for my application?
How can I build gtest for multiple versions of VS using cmake, either at the same time, or using some kind of parameters?.
Upvotes: 3
Views: 4520
Reputation: 10197
Something which may help would be to build gtest as part of your main CMake build. That way, gtest will always use the same compiler and settings as your main build and you then shouldn't need to pre-build it for each of the different compilers you want to support. Making gtest part of your build also has the advantage that it's really easy to link your tests against gtest, since CMake already knows about the gtest library target, so you don't have to use find_package(GTtest) or tell CMake where to find the gtest libraries.
I recently wrote a blog article about how to do this which may help you. You can find it here:
https://crascit.com/2015/07/25/cmake-gtest/
Update: This approach is now also part of the googletest documentation.
Upvotes: 5