Googletest (gtest) seems to be an immensely popular unit test framework and I'd like to learn how to build it stand-alone on the g++ compiler, simply and easily, so I can test small libraries and one-off files with it.
I've read the official documentation and readmes here:
- https://github.com/google/googletest
- and here: https://github.com/google/googletest/tree/main/googletest
...but I still can't figure it out.
How can I just build and test with gtest using the gcc/g++ compiler, or the g++-compatible LLVM clang compiler?
I know I can do the following to use cmake, but it doesn't give me the level of granular control I desire, and it still doesn't answer the mystical question of "how do I use these .a static library files when done?".
From: https://github.com/google/googletest/tree/main/googletest#generic-build-instructions
git clone https://github.com/google/googletest.git
cd googletest # Main directory of the cloned repository.
mkdir build # Create a directory to hold the build output.
cd build
time cmake .. # Generate native make build scripts for GoogleTest.
time make # Run those makefiles just autogenerated by cmake above.
You'll now have the following 4 library files built with whatever build settings were pre-specified for you in the cmake files, but I still don't know how to use them:
googletest/build/lib/libgmock.a
googletest/build/lib/libgmock_main.a
googletest/build/lib/libgtest.a
googletest/build/lib/libgtest_main.a