Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:CARLA simulator Carla CMake Configure Build

From Leeroopedia
Knowledge Sources
Domains Build_System, Development
Last Updated 2026-02-15 00:00 GMT

Overview

Concrete tool for configuring the CARLA CMake build system with the Ninja generator, custom toolchain, and Unreal Engine integration in the CARLA build pipeline.

Description

This implementation invokes CMake to generate the Ninja build files that will be used for all subsequent CARLA build targets. The configuration command specifies the Ninja generator, points to CARLA's custom toolchain file (which selects the Clang compiler from the Unreal Engine SDK for ABI compatibility), sets the build type to Release, and provides the path to the compiled Unreal Engine 5 installation.

The generated build files are placed in the Build/ directory. Once configuration succeeds, individual build targets (Python API, editor launch, packaging) can be built using cmake --build Build --target <name>.

Usage

Run this command after all prerequisites are installed, Unreal Engine 5 is built, and content assets are downloaded. The configuration step only needs to be re-run when build options change, new CMake variables are added, or the CMakeLists.txt files are modified.

Code Reference

Source Location

  • Repository: CARLA
  • File: CMakeLists.txt:L1-141, CMakePresets.json:L1-50, CMake/Toolchain.cmake

Signature

cmake -G Ninja -S . -B Build \
  --toolchain=$PWD/CMake/Toolchain.cmake \
  -DCMAKE_BUILD_TYPE=Release \
  -DCARLA_UNREAL_ENGINE_PATH=$UE5_ROOT

I/O Contract

Inputs

Name Type Required Description
-G Ninja Generator name Yes Specifies the Ninja build generator for fast parallel builds.
-S . Source path Yes Path to the CARLA source tree root (where the top-level CMakeLists.txt resides).
-B Build Build path Yes Output directory for generated build files. Convention is Build/.
--toolchain File path Yes Path to CMake/Toolchain.cmake, which configures the UE SDK Clang compiler.
CMAKE_BUILD_TYPE CMake variable Yes Build type: Release (optimized), Debug (with symbols), or RelWithDebInfo.
CARLA_UNREAL_ENGINE_PATH CMake variable Yes Absolute path to the compiled Unreal Engine 5 root directory.

Outputs

Name Type Description
Build/build.ninja Ninja build file The main Ninja build file containing all build rules and targets.
Build/CMakeCache.txt CMake cache Cached CMake variables for subsequent reconfiguration and build commands.
Build/CMakeFiles/ Directory CMake internal files including compiler detection results and generated sources.
Configuration summary stdout Summary of detected compiler, engine path, enabled features, and any warnings.
Exit code Integer 0 on success; non-zero if configuration fails (missing dependency, invalid path, etc.).

Usage Examples

Basic Example

# Set the Unreal Engine path
export UE5_ROOT=~/UnrealEngine5.3

# Navigate to the CARLA repository root
cd CarlaUE5

# Run CMake configuration
cmake -G Ninja -S . -B Build \
  --toolchain=$PWD/CMake/Toolchain.cmake \
  -DCMAKE_BUILD_TYPE=Release \
  -DCARLA_UNREAL_ENGINE_PATH=$UE5_ROOT

Debug Build Configuration

# Configure a debug build with full symbols for debugging
cmake -G Ninja -S . -B BuildDebug \
  --toolchain=$PWD/CMake/Toolchain.cmake \
  -DCMAKE_BUILD_TYPE=Debug \
  -DCARLA_UNREAL_ENGINE_PATH=$UE5_ROOT

Using CMake Presets

# List available presets defined in CMakePresets.json
cmake --list-presets

# Configure using a named preset (if available)
cmake --preset default

Reconfiguring After Changes

# If CMakeLists.txt files change, reconfigure the existing build directory
cmake -B Build

# Or wipe and reconfigure from scratch
rm -rf Build
cmake -G Ninja -S . -B Build \
  --toolchain=$PWD/CMake/Toolchain.cmake \
  -DCMAKE_BUILD_TYPE=Release \
  -DCARLA_UNREAL_ENGINE_PATH=$UE5_ROOT

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment