Build2 package containing Google Test and Google Mock static libraries.
Products of this package are following static libraries:
- gtest static library without main function
- gtest_main static library with main function
- gmock static library (contains also gtest) without main function
- gmock_main static library (contains also gtest) with main function
git clone --recursive https://github.com/rsitko92/googletest-build2.git
Being in root directory of project run:
-
using g++:
bdep init -C @gcc cc config.cxx=g++ b test
-
using clang++:
bdep init -C @clang cc config.cxx=clang++ b test
-
Add libgtest package dependency to
manifest
file:depends: * libgtest >= 0.1.0
-
Add libgtest package repository to
repositories.manifest
file:: role: prerequisite location: https://github.com/rsitko92/googletest-build2.git#master
-
Import one of the below libraries in
buildfile
of target application:-
gtest without main function:
import libs += libgtest%liba{googletest/googletest/gtest}
-
gtest with main function:
import libs += libgtest%liba{googletest/googletest/gtest_main}
-
gmock (contains also gtest) without main function:
import libs += libgtest%liba{googletest/googlemock/gmock}
-
gmock (contains also gtest) with main function:
import libs += libgtest%liba{googletest/googlemock/gmock_main}
-
-
Link one of the choosen libgtest static library in
libs
variable with target:Example linking to
hello
executable target:exe{hello}: {hxx ixx txx cxx}{**} $libs
-
Add appropriate include statement(s) in source/header files:
-
Google Test:
#include <gtest/gtest.h>
-
Google Mock:
#include <gmock/gmock.h>
-