为什么推荐包含googletest源文件

Why is it recommended to include googletest source files

只是一个简短的问题, 为什么建议通过包含源文件在每个项目中编译 googletest 和 googlemock(而不是使用 cmake 以“.a”扩展名存档库,然后将其链接到许多项目)。

来源:https://www.jetbrains.com/help/clion/creating-google-test-run-debug-configuration-for-test.html

因为 googletest 生成的“.a”文件会因编译器标志而异。您要进行的不同测试项目可能会设置不同,如果它们引用通用的 googletest“.a”文件,这可能会导致问题。

来自'make install' considered harmful

In the README file for gtest and gmock, we said that you could install compiled gtest and gmock libraries on *nix systems using 'make install'. Then every user of your machine can write tests without recompiling gtest or gmock.

This seemed like a good idea when we wrote the README, but it has a got-cha: every user needs to compile his tests using the same compiler flags used to compile the installed gtest/gmock libraries; otherwise he may run into undefined behaviors (i.e. the tests can behave strangely and may even crash for no obvious reasons).