claremacrae / ApprovalTests.cpp.CMakeSamples

CMake code for various scenarios, for including in the ApprovalTests.cpp cmake docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ApprovalTests.cpp.CMakeSamples

Contents

Build Status

CMake code for various scenarios, for including in the ApprovalTests.cpp cmake docs, and for copying as templates for new projects.

Using ApprovalTests.cpp with CMake

add_subdirectory_approvaltests_catch2

Topic Detail
Directory add_subdirectory_approvaltests_catch2
Purpose Demo how to build your tests against clones or forks of ApprovalTests.cpp and Catch2.
Those source code of those dependencies will be included in your IDE, alongside your own source code.
This allows you to make edits to the dependent projects.
Dependencies ApprovalTests.cpp - cloned on your machine
Catch2 - cloned on your machine
Mechanism Uses CMake's add_subdirectory()
More Detail See Use own ApprovalTests.cpp and Catch2 clones

fetch_content_approvaltests

Topic Detail
Directory fetch_content_approvaltests
Purpose Demo how to build your tests using CMake's FetchContent_Declare and FetchContent_MakeAvailable to clone ApprovalTests.cpp, and use its copy of Catch2.
The source code of this dependency will be cloned inside your CMake build space, and will not be shown inside your IDE.
This requires at least CMake 3.14.
Dependencies ApprovalTests.cpp - cloned automatically by CMake
Catch2 - the version in the ApprovalTests.cpp repo will be used
Mechanism Uses CMake's FetchContent module.
More Detail See Make CMake clone ApprovalTests.cpp

fetch_content_approvaltests_catch2

Topic Detail
Directory fetch_content_approvaltests_catch2
Purpose Demo how to build your tests using CMake's FetchContent_Declare and FetchContent_MakeAvailable to clone ApprovalTests.cpp and Catch2.
The source code of those dependencies will be cloned inside your CMake build space, and will not be shown inside your IDE.
This requires at least CMake 3.14.
Dependencies ApprovalTests.cpp - cloned automatically by CMake
Catch2 - cloned automatically by CMake
Mechanism Uses CMake's FetchContent module.
More Detail See Make CMake clone ApprovalTests.cpp and Catch2

Using ApprovalTests.cpp with CMake and Conan

conan_cmake_find_package

Topic Detail
Directory conan_cmake_find_package
Purpose Demo how to build your tests using Conan's cmake_find_package and optionally cmake_paths generators to download single headers for specific releases of ApprovalTests.cpp and Catch2.
The released headers of those dependencies will be downloaded inside your CMake build space, and will not be shown inside your IDE.
Dependencies ApprovalTests.cpp - downloaded automatically by Conan
Catch2 - downloaded automatically by Conan
Mechanism Uses Conan's cmake_find_package and (optionally) cmake_paths generators.
More Detail See Example 1. Using Conan's cmake_find_package and cmake_paths generators

conan_cmake

Topic Detail
Directory conan_cmake
Purpose Demo how to build your tests using Conan's cmake generator to download single headers for specific releases of ApprovalTests.cpp and Catch2.
The released headers of those dependencies will be downloaded inside your CMake build space, and will not be shown inside your IDE.
Dependencies ApprovalTests.cpp - downloaded automatically by Conan
Catch2 - downloaded automatically by Conan
Mechanism Uses Conan's cmake generator.
More Detail See Example 2. Using Conan's cmake generator

cmake_invoking_conan

Topic Detail
Directory cmake_invoking_conan
Purpose Demo how to build your tests by getting CMake to invoke Conan, to download single headers for specific releases of ApprovalTests.cpp and Catch2.
The released headers of those dependencies will be downloaded inside your CMake build space, and will not be shown inside your IDE.
Dependencies ApprovalTests.cpp - downloaded automatically by CMake invoking Conan
Catch2 - downloaded automatically by CMake invoking Conan
Mechanism Uses the cmake-conan CMake module to invoke Conan automatically from within CMake.
More Detail See Example 3. Making CMake invoke Conan

Using ApprovalTests.cpp with CMake and vcpkg

vcpkg_cmake

Topic Detail
Directory vcpkg_cmake
Purpose Demo how to build your tests using vcpkg to obtain Catch2 and ApprovalTests.cpp.

A specific version of vcpkg is cloned automatically by CMake, via FetchContent() in the top level CMakeLists.txt, and then built inside your CMake build space.

The benefit of this approach for obtaining vcpkg is that the project can specify the exact version of vcpkg to use, and obtain it automatically - on all platforms. This keeps both build instructions and CI configurations simple.

The alternative would be to have to write instructions for developers to say how to manually obtain and build the required vcpkg version - which would be tedious and error-prone.

Note that the first time this is run in any given build space, there is a significant wait for vcpkg to be set up, but subsequent runs are much faster.

If you have multiple build spaces, vcpkg will be cloned and built multiple times, so this mechanism may be best used when you are only building one or two configurations.

Dependencies ApprovalTests.cpp - obtained automatically by vcpkg
Catch2 - obtained automatically by vcpkg
Mechanism Uses CMake's FetchContent() to obtain and build a specific version of vcpkg inside the build space.

Uses vcpkg's manifest mode to specify the dependencies.

More Detail See ApprovalTests.cpp Vcpkg Integration docs - TODO Update that page to add descriptive info for this example

Developing ApprovalTests.cpp with CMake

dev_approvals

Topic Detail
Directory dev_approvals
Purpose Demo how to build the ApprovalTests.cpp project against your clones or forks of all its dependencies.
Those source code of those dependencies will be included in your IDE, alongside your own source code.
This allows you to make edits to the dependent projects.
Dependencies ApprovalTests.cpp - cloned on your machine
All its dependencies also cloned on your machine
Mechanism Uses CMake's find_package() for finding boost, and add_subdirectory() for everything else.
More Detail See Developing ApprovalTests.cpp with test framework sources

dev_approvals_fetch_content

Topic Detail
Directory dev_approvals_fetch_content
Purpose Demo how to build the ApprovalTests.cpp project using CMake's FetchContent_Declare and FetchContent_MakeAvailable to clone its dependencies.
The source code of the dependencies will be cloned inside your CMake build space, and will not be shown inside your IDE.
This requires at least CMake 3.14.
Dependencies ApprovalTests.cpp - cloned on your machine
All its dependencies also cloned on your machine, inside each build space
Mechanism Uses CMake's FetchContent module.
More Detail

About

CMake code for various scenarios, for including in the ApprovalTests.cpp cmake docs


Languages

Language:CMake 67.8%Language:Python 14.3%Language:Shell 12.1%Language:C++ 5.8%