CppDepend Guide: Analyzing Game Engines via .sln or compile_commands.json
Workflow Overview
When working with modern C++ game engines like Unreal Engine, CryEngine, Godot, or proprietary studio engines, CppDepend requires a complete view of source files, include directories, preprocessor definitions, and compiler flags.
You can feed your codebase into CppDepend using two main workflows:
- •Visual Studio Solution (.sln): the quickest option when your engine setup generates standard Visual Studio projects.
- •JSON Compilation Database (compile_commands.json): the most accurate option for CMake-based engines and custom build systems like UnrealBuildTool (UBT).
Method 1: Analyzing via Visual Studio Solution (.sln)
If your game engine setup or custom build script generates a .sln and associated .vcxproj files (e.g., standard Unreal/CryEngine generated solutions), CppDepend can parse them directly.
Steps:
- 1.Launch CppDepend.
- 2.Click Create a new CppDepend Project.
- 3.Under Analysis Inputs, click Add Visual Studio Projects.
- 4.Select Visual Studio Solution (
.sln) or Projects (.vcxproj). - 5.Select the target Build Configuration (e.g.,
Development_Editor | x64orDebugGame | Win64).
Configure Scope & Filters
Game Modules Only: to analyze only your gameplay code and bypass third-party libraries, go to Filters / Exclude Files and add exclusions (e.g., *\Engine\Source\ThirdParty\* or *\SDKs\*).
Method 2: Analyzing via JSON Compilation Database (compile_commands.json)
For engines built with CMake (like CryEngine or Godot C++ modules) or custom build setups like UnrealBuildTool, exporting a JSON compilation database provides 100% flag precision.
Step 1: Generate the compile_commands.json File
A. For CMake-based Engines (CryEngine V, O3DE, Godot C++):
Run CMake with the export flag enabled:
cmake -B build -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
This generates compile_commands.json inside your build/ directory.
B. For Unreal Engine:
Refer to the dedicated guide: How to Analyze an Unreal Engine Project with CppDepend.
Step 2: Import into CppDepend
- 1.Open CppDepend.
- 2.Create a new project and under Analysis Inputs, select Import CMake / Clang JSON Compilation Database (
compile_commands.json). - 3.Browse to and select the generated
compile_commands.jsonfile.
Step 3: Run Analysis & Inspect Engine Architecture
Click Run Analysis (F5).
CppDepend reads the input configurations, parses the AST, calculates metrics, and builds the code model. You can then inspect the engine architecture with the dependency graph, the dependency matrix and the interactive dashboard.
| Approach | Best Used For | Key Advantage |
|---|---|---|
| Visual Studio (.sln) | Native MSVC projects, standard Visual Studio setups, engine sln files. | Plug-and-play setup directly inside the IDE or standalone tool. |
| JSON (compile_commands.json) | CMake builds, Unreal Engine (UBT), cross-platform setups, Ninja/Clang toolchains. | Exact compiler state capture; highly accurate across custom build systems. |
Try CppDepend Today
Start your 14-day free trial with full access to all documentation features. No credit card required.
