gtest_submodule
gtest_submodule copied to clipboard
CPP Project with Google test submodule and Github Actions
Cmake + googletest (git submodule) + Github actions
A toy project showcasing the following features:
-
cmake
build for C++ project source files; -
googletest
as agit submodule
; -
github-actions
pipeline for running build and tests.
In short, you see a C++ project that uses google test as a git submodule and integrates a Github CI pipeline (which in Github-terms is called Github actions).
Initially the pipeline run on travis CI. In October 2022 I updated the repo to use Github Actions instead.
I was inspired by the projects from the acknowledgement section, and at the sime time want improve on that: the goal is to use git submodules in order to avoid copying google test in the current repo.
Directory structure
-
CMakeLists.txt
cmake project files -
include/
header files (*.h
) -
src/
source files (*.cpp
) -
test/
test files (*.cpp
)
Cloning the project
Use git clone --recursive ...
to download the project and its git submodules.
Otherwise from the project root repository one needs to download the submodules:
git submodule update --init
.
Building the project
- Creating the executables follows standard
cmake
procedure:
cmake -B build
- Compile the code (it will also compile the gtest for the first time):
cmake --build build
- Run executable:
./build/project1
- Cmake supports
add_test
function, then the tests can be launchmake test
orctest
commands.
./build/runUnitTests
alternatively, in the build
directory, run:
ctest
Acknowledgement
The acknowledgments go to:
-
Gunnar and this repository, for providing a minimal working example of gtest, travis-ci, and cmake.
-
David Y. Zhang and this repo. For setting up a repo with gtest and cmake.
Maintainer
Dr. Konstantin Selyunin, for suggestions/questions/comments please contact: selyunin [dot] k [dot] v [at] gmail [dot] com