GridX Matching Engine is a high-performance, low-latency matching engine written in C++20. The project uses CMake, Conan 2, LLVM Clang, Ninja, and CTest for dependency management, builds, and testing.
Install the following tools before building the project:
- LLVM Clang
- clang-format
- clang-tidy
- CMake 3.24 or newer
- Conan 2.x
- Ninja
The project is standardized on:
- Compiler: LLVM Clang
- Build System: CMake
- Build Generator: Ninja
- Package Manager: Conan 2
- Test Framework: GoogleTest
- Test Runner: CTest
Install the required tools:
brew install llvm cmake ninja conanConfigure LLVM Clang for the current terminal session:
export PATH="$(brew --prefix llvm)/bin:$PATH"
export CC=clang
export CXX=clang++To make these settings permanent, add the commands above to your shell configuration file (for example, ~/.zshrc or ~/.bashrc) and reload your shell:
source ~/.zshrcVerify the compiler:
which clang++
clang++ --versionThe reported compiler should be the LLVM version installed by Homebrew.
Install the required tools:
sudo apt update
sudo apt install -y \
clang \
clang-tools \
cmake \
ninja-build \
python3-pip
python3 -m pip install --user conanConfigure Clang for the current terminal session:
export CC=clang
export CXX=clang++To make these settings permanent, add the commands above to your shell configuration file (for example, ~/.bashrc or ~/.zshrc) and reload your shell:
source ~/.bashrcVerify the compiler:
which clang++
clang++ --versionInstall the required tools:
sudo dnf install -y \
clang \
clang-tools-extra \
cmake \
ninja-build \
python3-pip
python3 -m pip install --user conanConfigure Clang:
export CC=clang
export CXX=clang++To make these settings permanent, add the commands above to your shell configuration file and reload your shell.
Verify the compiler:
which clang++
clang++ --versionRun the following commands once after cloning the repository.
Generate the local Conan profile:
conan profile detect --forceGenerate the Debug configuration:
conan install . \
--build=missing \
-s build_type=Debug \
-c tools.cmake.cmaketoolchain:generator=NinjaGenerate the Release configuration:
conan install . \
--build=missing \
-s build_type=Release \
-c tools.cmake.cmaketoolchain:generator=NinjaImportant
The project exposes the high-level CMake presets
debugandrelease. These presets inherit from Conan-generated presets. Both Debug and Releaseconan installcommands must be executed before using the project presets.
Ensure the corresponding Debug or Release Conan configuration has been generated during the initial project setup before using these presets.
cmake --preset debug
cmake --build --preset debugcmake --preset release
cmake --build --preset releaseDebug build:
./build/Debug/matching-engineRelease build:
./build/Release/matching-engineThe matching engine loads its runtime configuration from environment variables.
Copy the example environment file:
cp env.example .envUpdate the values in .env as needed for your local environment.
Before running the matching engine, export the variables into your current shell:
set -a
source .env
set +aThen start the application:
./build/Debug/matching-engineNote
The matching engine reads configuration from the process environment using
std::getenv(). It does not read the.envfile directly. The.envfile must be sourced (or injected by Docker Compose or another process manager) before launching the application.
Run the Debug test suite:
ctest --preset debug --output-on-failureRun the Release test suite:
ctest --preset release --output-on-failureTypical development workflow:
# Configure once
conan install . \
--build=missing \
-s build_type=Debug \
-c tools.cmake.cmaketoolchain:generator=Ninja
# Configure CMake (only required after CMake or Conan changes)
cmake --preset debug
# Build after source code changes
cmake --build --preset debug
# Load environment variables
set -a
source .env
set +a
# Run tests
ctest --preset debug
# Run the executable
./build/Debug/matching-engineconan install only needs to be executed again when:
- Building the project for the first time
- The
build/directory has been removed - Dependencies in
conanfile.pyhave changed - Conan or toolchain configuration has changed
Editing .cpp or .hpp files does not require running conan install again.
matching-engine/
├── include/ # Public headers
├── src/ # Source files
├── tests/
│ ├── unit/ # Unit tests
│ └── integration/ # Integration tests
├── build/ # Generated build files (ignored)
├── CMakeLists.txt
├── CMakePresets.json
├── conanfile.py
└── README.md
The project uses the following tools to maintain code quality:
- clang-format for source code formatting
- clang-tidy for static analysis
- GoogleTest for unit and integration testing
- CTest as the test runner
Format all source files:
cmake --build --preset debug --target formatVerify formatting without modifying files:
cmake --build --preset debug --target format-checkRun static analysis:
cmake --build --preset debug --target lintNote
The
linttarget requires the project to be configured first so that CMake generates thecompile_commands.jsoncompilation database:cmake --preset debug
All code submitted to the repository should:
- Pass
format-check - Pass
lint - Compile without warnings (
-Werror) - Pass all unit and integration tests