This guide provides comprehensive instructions for building the Faker C++ library with different compilers and build systems.
- Prerequisites
- Quick Start
- Building with Different Compilers
- Alternative Build Systems
- Running Tests
- Troubleshooting
- Advanced Options
- CMake 3.22 or higher
- C++ Compiler with C++20 support:
- GCC 13+
- Clang 16+
- Apple Clang 16+
- MSVC 143 (Visual Studio 2022)+
# Clone the repository
git clone https://github.com/cieslarmichal/faker-cxx.git
cd faker-cxx
git submodule update --init --recursive
# Configure and build (Linux/macOS with default compiler)
cmake -B ./build -DFAKER_BUILD_TESTING=ON
cmake --build ./build
# Run tests
ctest --test-dir ./buildNote: All compilers require cloning first. Do this once:
git clone https://github.com/cieslarmichal/faker-cxx.git cd faker-cxx git submodule update --init --recursive
1. Install GCC:
sudo apt install cmake ninja-build g++-132. Configure and build:
cmake -B ./build -DCMAKE_CXX_COMPILER=g++-13 -DFAKER_BUILD_TESTING=ON
cmake --build ./build
ctest --test-dir ./build1. Install Clang:
sudo apt install clang-182. Configure and build:
cmake -B ./build -DCMAKE_CXX_COMPILER=clang++ -DFAKER_BUILD_TESTING=ON
cmake --build ./build
ctest --test-dir ./build1. Install Apple Clang:
brew install llvm@18
export PATH="/opt/homebrew/opt/llvm@18/bin:$PATH"2. Configure and build:
cmake -B ./build -DCMAKE_CXX_COMPILER=clang++ -DFAKER_BUILD_TESTING=ON
cmake --build ./build
ctest --test-dir ./build1. Configure and build:
cmake -B ./build -G "Visual Studio 17 2022"
cmake --build ./build
ctest --test-dir ./buildThe project includes CMake presets for standardized builds across different environments.
cmake --list-presets # List all presets
cmake -S . --preset unixlike-gcc-debug-static # Configure
cmake --build --preset unixlike-gcc-debug-static # Buildconan install conanfile.txt --build=missing
cmake --preset=conan-release -DUSE_SYSTEM_DEPENDENCIES:BOOL=ON
cmake --build --preset=conan-releasebazel build //:faker-cxx
bazel test //tests:allUsing CTest:
ctest --test-dir ./build # Run all tests
ctest --test-dir ./build --verbose # With verbose output
ctest --test-dir ./build -R "PersonTest" # Run specific testsDirect execution:
./build/tests/faker-cxx-UT # Linux/macOS
./build/tests/Debug/faker-cxx-UT.exe # WindowsCMake can't find the compiler:
export CXX=/usr/bin/g++-13
cmake -B ./build -DCMAKE_CXX_COMPILER=$CXXSubmodule not initialized:
git submodule update --init --recursiveTests not found:
cmake -B ./build -DFAKER_BUILD_TESTING=ONcmake -B ./build \
-DUSE_SYSTEM_DEPENDENCIES=ON \
-DFAKER_BUILD_TESTING=OFF \
-DCMAKE_INSTALL_PREFIX=/custom/path \
-G Ninja