This is a GTest example project that integrates GoogleTest into CMake in three different ways:
- CMake's own
FetchContent_Declare(...)andFetchContent_MakeAvailable(...). vcpkgwith thegtestport.conanwith thegtestrecipe.
Apart from having CMake installed in your enviroment, you just have to run the following commands.
cd fetch-content
cmake . -Bbuild && cmake --build buildMake sure you have conan 2.x installed, then install the dependencies.
cd conan
conan install -of "conan" . --build=missingOnce 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 buildMake 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 buildWhere ${VCPKG_ROOT} is the path to the root installation of your vcpkg.