This is a GTest example project that integrates GoogleTest into CMake in three different ways:
- CMake's own
FetchContent_Declare(...)
andFetchContent_MakeAvailable(...)
. vcpkg
with thegtest
port.conan
with thegtest
recipe.
Apart from having CMake installed in your enviroment, you just have to run the following commands.
cd fetch-content
cmake . -Bbuild && cmake --build build
Make sure you have conan
2.x installed, then install the dependencies.
cd conan
conan install -of "conan" . --build=missing
Once conan
has installed/build the dependencies, configure and build with CMake as usual, while passing the generated CMAKE_TOOLCHAIN_FILE
:
cmake . \
-Bbuild \
-DCMAKE_TOOLCHAIN_FILE="conan/conan_toolchain.cmake"
cmake --build build
Make sure you have a recent version of vcpkg
installed, then simply call cmake
with the correct toolchain file.
cmake . \
-Bbuild \
-DCMAKE_TOOLCHAIN_FILE="${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
cmake --build build
Where ${VCPKG_ROOT}
is the path to the root installation of your vcpkg
.