Skip to main content
This guide helps you set up an efficient development environment for working on KiCad.

Development Tools

Essential Tools

Version Control

  • Git - Version control system
  • GitLab account - For hosting your fork and submitting merge requests

Build System

  • CMake 3.22+ (3.28.1+ for MSVC ARM)
  • Make or Ninja build system
  • ccache (optional) - Speeds up recompilation
  • distcc (optional) - Distributed compilation

Compilers

KiCad requires C++20 support:
  • GCC 10+ (Linux)
  • Clang 11+ (macOS, Linux)
  • MSVC 2019+ (Windows)

Code Editors and IDEs

Visual Studio Code
  • C/C++ extension
  • CMake Tools extension
  • GitLens extension
  • clang-format extension
CLion
  • Full CMake integration
  • Built-in debugger
  • Code analysis tools
Qt Creator
  • CMake support
  • Good C++ support
Vim/Neovim
  • YouCompleteMe or coc.nvim for code completion
  • vim-cmake plugin

Debugging Tools

  • GDB (Linux)
  • LLDB (macOS, Linux)
  • Visual Studio Debugger (Windows)
  • Valgrind - Memory debugging and profiling
  • Address Sanitizer (ASan) - Memory error detection
  • Thread Sanitizer (TSan) - Data race detection

Setting Up Your Environment

Fork and Clone the Repository

  1. Fork the repository on GitLab:
  2. Clone your fork:
  3. Add upstream remote:

Configure Your GitLab Fork

Configure your personal fork with the following settings:
  1. Settings → General → Visibility
    • CI/CD should be enabled and set to “Everyone with access”
  2. Settings → CI/CD → General pipelines
    • Timeout should be set to 3 hours or longer
  3. When creating merge requests
    • Check “Allow commits from members who can merge to the target branch” at the bottom of your merge request

Build Directory Structure

Recommended directory layout:

Initial Build Setup

Debug Build

The CMAKE_EXPORT_COMPILE_COMMANDS=ON option generates compile_commands.json, which many IDEs and language servers use for code intelligence.

Release Build for Testing

Development Workflow

Keeping Your Fork Updated

Creating a Feature Branch

Always create new branches for merge requests instead of using your fork’s master branch.

Incremental Builds

After making code changes:
CMake will automatically detect changed files and rebuild only what’s necessary.

Running Tests

Debugging

Using GDB (Linux)

Common GDB commands:

Using Sanitizers

Address Sanitizer

ASan will detect:
  • Use-after-free
  • Heap/stack/global buffer overflow
  • Use-after-scope
  • Memory leaks

Thread Sanitizer

TSan will detect:
  • Data races
  • Deadlocks
Warning: Do not use sanitizers with the gold linker.

Using Valgrind

Code Intelligence and Formatting

compile_commands.json

CMake generates compile_commands.json in your build directory (when CMAKE_EXPORT_COMPILE_COMMANDS=ON is set). Many tools use this:
  • clangd language server
  • VSCode C++ extension
  • CLion
  • vim-clang
Create a symlink in your source root:

Code Formatting

KiCad uses clang-format for code formatting. The configuration is in _clang-format at the repository root. Format a file:
Check formatting without modifying:
See the Code Style guide for more details.

Performance Optimization

Using ccache

ccache speeds up recompilation by caching previous compilations:

Using Precompiled Headers

KiCad uses precompiled headers by default to speed up builds:

Parallel Builds

Always use parallel builds:

Platform-Specific Notes

Linux

GTK3 Development Files Required:
Wayland Support: KiCad supports Wayland natively on Linux:

macOS

Xcode Command Line Tools:
Homebrew Dependencies:

Windows

MSVC with parallel compilation:
Using vcpkg for dependencies:

Troubleshooting

Build Cache Issues

If you encounter strange build errors:

IDE Not Finding Headers

  1. Ensure compile_commands.json is generated and symlinked
  2. Rebuild the project to update the compile commands
  3. Restart your IDE/language server

Library Version Conflicts

Use the exact library versions that CI uses. Check .gitlab-ci.yml in the repository for reference.

Additional Resources

Next Steps

  1. Review the code style guidelines
  2. Start with a starter issue
  3. Learn how to submit merge requests