CMake
Dependencies
- Ubuntu/Debian
- Arch
- macOS
warning
Ubuntu 23.10 (Mantic Minotaur) ships with a broken lcov
package,
see this issue. You can install lcov
from source or use
the version from noble.
Install dependencies
sudo apt install cmake clang llvm lcov
Ubuntu versions >=24.04 also require libclang-rt-dev
:
Install libclang-rt-dev
sudo apt install libclang-rt-dev
sudo pacman -S cmake clang llvm lcov
brew install cmake llvm lld lcov
Adjust the following environment variables to support fuzzing with the latest LLVM versions:
export PATH="$(brew --prefix)/opt/llvm/bin:$PATH"
export LDFLAGS="-L$(brew --prefix)/opt/llvm/lib -Wl,-rpath,$(brew --prefix)/opt/llvm/lib/c++ -Wl,-rpath,$(brew --prefix)/opt/llvm/lib/unwind -fuse-ld=lld $LDFLAGS"
export CPPFLAGS="-I$(brew --prefix)/opt/llvm/include $CPPFLAGS"
Version requirements
info
Running CI Fuzz with LLVM versions <= 16 on Linux can cause fuzzing runs to randomly crash. Have a look at the troubleshooting guide for instructions to fix this issue.
Initialize your project
Initialize CI Fuzz in the root directory of your CMake project with the following command:
cifuzz init
Add the following commands before any add_library
or add_executable
directives to your top level CMakeLists.txt
file:
find_package(cifuzz NO_SYSTEM_ENVIRONMENT_PATH)
enable_fuzz_testing()