Building
This document walks you through building Touca SDK for C++ and its side components from its source code. Refer to our Installing Instructions to learn how to pull Touca as a third-party dependency.
Requirements
You can build Touca on Linux, macOS, and Windows platforms. We support C++11 and newer standards. We use CMake as our build system. You would need CMake v3.14 or newer to build Touca. We formally support the following compilers:
Compiler | Min Version |
---|---|
x86-64 gcc | 7.1 |
x86-64 clang | 7.0.0 |
x64 MSVC | 1900 |
Obtaining the Source Code
Touca SDK for C++ is available
on GitHub under the
Apache-2.0 license. Clone this repository to a directory of your choice. We
refer to this directory as <project_directory>
.
git clone git@github.com:trytouca/trytouca.git
cd sdk/cpp
Using Our Helper Script
Touca SDK for C++ has five main components.
Name | Build Argument |
---|---|
Core Library | |
Test Framework | --with-framework |
Sample Regression Test Tools | --with-examples |
Utility Command Line Tool | --with-cli |
Unit Tests | --with-tests |
We provide build scripts build.sh
and build.bat
for Unix and Windows
platforms, respectively. The build scripts build the core library and the test
framework by default. You can pass the appropriate argument shown in the table
above to build other components as needed.
As an example, the command below builds all the components except the unit tests.
./build.sh --with-cli --with-examples
You can build all of the components using the --all
argument.
./build.sh --all
Using CMake Directly
If, for any reason, you do not want to build Touca using our helper scripts, you
can always use CMake directly. To do so, we recommend running the following
command first, to configure the build targets and specify the path in which
build artifacts should be generated. While you can change the build directory to
the directory of your choice, the subsequent instructions assume the default
value of ./local/build
.
cmake -B"<project_directory>/local/build" -H"<project_directory>"
By default, the above-mentioned command configures CMake to build the core Touca Client Library. But Touca has several other components that can be enabled by passing the appropriate options to the command above, as listed in the table below.
Component Name | CMake Option | Default |
---|---|---|
Test Framework | TOUCA_BUILD_FRAMEWORK | ON |
Command-Line Application | TOUCA_BUILD_CLI | OFF |
Sample Test Tools | TOUCA_BUILD_EXAMPLES | OFF |
Unit-Tests | TOUCA_BUILD_TESTS | OFF |
As an example, the command below enables building sample Touca tests.
cmake -B"<project_directory>/local/build" -H"<project_directory>" -DTOUCA_BUILD_EXAMPLES=ON
We can build the source code via CMake which uses the native build tool of your platform.
cmake --build "<project_directory>/local/build" --parallel
Optionally, as a last step, we can install the build artifacts in a directory of our choice for easier packaging.
cmake --install "<project_directory>/local/build" --prefix "<project_directory>/local/dist"