Installing
This document walks you through adding the Touca SDK for C++ and its components as a dependency to your own project. Refer to our Build Instructions if you like to build Touca from source.

Using CMake

Assuming that your project is already using CMake, the easiest way to pull Touca as a dependency is to use CMake v3.11 or newer which includes CMake's FetchContent module.
1
FetchContent_Declare(
2
touca
3
GIT_REPOSITORY https://github.com/trytouca/touca-cpp.git
4
GIT_TAG v1.4.1
5
)
6
FetchContent_MakeAvailable(touca)
Copied!

Building Extra Components

The above code pulls the latest stable release of the Touca SDK for C++ and generates a touca_client CMake target that you can link to.
We can use the slightly more verbose FetchContent_GetProperties pattern to customize the set of build targets, to include building Touca command-line application and example projects or to exclude building the test framework:
1
FetchContent_Declare(
2
touca
3
GIT_REPOSITORY https://github.com/trytouca/touca-cpp.git
4
GIT_TAG v1.4.1
5
)
6
7
FetchContent_GetProperties(touca)
8
if(NOT touca_POPULATED)
9
FetchContent_Populate(touca)
10
set(TOUCA_BUILD_UTILS ON)
11
set(TOUCA_BUILD_EXAMPLES ON)
12
add_subdirectory(${touca_SOURCE_DIR})
13
endif()
Copied!

Enabling HTTPS

The SDK has an optional dependency on OpenSSL for communicating with the Touca server over HTTPS. In most platforms, this library is automatically discovered and used by the build recipe. If OpenSSL is not installed in the default location, we may need to provide its root directory as a hint to the library’s build recipe. Here is a typical way to do so on macOS when OpenSSL is installed through homebrew.
1
set(OPENSSL_ROOT_DIR /usr/local/opt/openssl)
Copied!

Using Conan

As an alternative, you can use Conan to pull Touca as a dependency. Conan is a cross-platform package manager that enables efficient management of project dependencies. Refer to Conan documentation to learn more.

Setting Up Conan

If you do not have Conan locally installed, the preferred way to install it is through the Python Package Index using the pip command:
1
pip install conan
Copied!
If this is the first time you are using Conan, we recommend that you setup a Conan profile based on your system environment.
1
conan profile new default --detect
2
conan profile update settings.compiler.libcxx=libstdc++11 default
Copied!

Installing Touca

We can now install Touca using the Conan package manager. To do so, we first register Touca's Conan remote repository.
1
conan remote add touca-cpp https://getweasel.jfrog.io/artifactory/api/conan/touca-cpp
Copied!
We can now ask Conan to install Touca as a dependency and generate a CMake find module that we can integrate with our build system.
1
conan install -if "${dir_build}" -g cmake_find_package -b missing "touca/[email protected]_/_"
Copied!
Where ${dir_build} is the path to the CMake build directory.

Discovering Conan Packages

Assuming we use ${dir_build} as our CMake binary directory, to discover and use the Conan-generated CMake find module we can ensure ${dir_build} is part of our CMake module path.
1
list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
2
find_package("touca" QUIET)
Copied!
This lets us link the Touca client library or test framework with our project like any other library.
1
target_link_libraries(<YOUR_PROJECT> PRIVATE touca_framework)
Copied!
Last modified 17h ago