How I Set Up Every Audio Plugin C++ Project with JUCE, CMake, and Unit Tests [TEMPLATE REPO]

Share

Summary

This video provides a step-by-step guide on setting up a C++ audio plugin project using JUCE, CMake, CPM (CMake Package Manager), and integrating Google Test for unit testing. It covers creating a project from scratch, managing dependencies, configuring compiler settings, and building a basic VST3 plugin.

Highlights

Introduction to JUCE, CMake, and CPM for Audio Plugin Development
00:00:00

The video introduces the use of JUCE C++ framework for audio plugin development and highlights the limitations of the JUCE Producer. It then proposes a better alternative using CMake, a cross-platform tool for generating C++ projects, and CPM (CMake Package Manager) for easier integration of third-party libraries like JUCE and Google Test.

Setting Up the Basic CMake Project
00:02:10

The tutorial begins by showing how to create a basic `CMakeLists.txt` file, specifying the minimum required CMake version and defining the project name. It also emphasizes setting the C++ standard to C++23 for Greenfield projects and configuring compiler warning options to treat all warnings as errors for robust code.

Integrating CPM and JUCE Framework
00:05:01

This section demonstrates how to integrate CPM (CMake Package Manager) into the project to manage dependencies. It shows how to download and include the CPM script, and then use the `CPMAddPackage` command to fetch the JUCE framework from its GitHub repository, ensuring all third-party libraries are stored locally within the project's `Libs` folder.

Creating the Audio Plugin Structure
00:13:46

The video guides through creating the directory structure for the plugin, including `plugin`, `include`, and `source` folders. It then populates these folders with JUCE's plugin template files, specifically `PluginProcessor.h`, `PluginEditor.h`, `PluginProcessor.cpp`, and `PluginEditor.cpp`.

Configuring the JUCE Plugin with CMake
00:16:13

This part details how to use JUCE's custom CMake commands, specifically `juce_add_plugin`, to configure the audio plugin. It covers setting various parameters like company name, synth status, MIDI input/output, manufacturer code, plugin code, desired formats (VST3), and product name. It also addresses and resolves initial build errors related to linking libraries and warning flags by adding JUCE's recommended configurations.

Adding Unit Tests with Google Test
00:25:09

The tutorial introduces how to add unit tests to the project using Google Test. It explains how to add Google Test as a dependency using CPM, create a `test` folder with its own `CMakeLists.txt` and test source file, and then link the test executable against the main audio plugin and Google Test libraries. It resolves include path issues and confirms the test setup by verifying a failing test.

Leveraging CMake and Additional Recommendations
00:35:13

The video concludes by highlighting the flexibility gained with CMake and CPM, such as seamless integration with Visual Studio, Visual Studio Code, and the potential for GitHub Actions for continuous integration. It also suggests further improvements like using namespaces, git hooks for formatting with `pre-commit`, and caching dependencies in CI/CD pipelines. The presenter also mentions an alternative template (Pamplejuce) but prefers the demonstrated CPM approach for its clarity and version control.

Recently Summarized Articles

Loading...