How to set up a JUCE + CMake + VS Code workflow on macOS?

Hi everyone,

I’m new to the JUCE framework and I’m trying to set up a modern, lightweight development environment on my macOS machine. Due to limited disk space, I’m trying to avoid using the full Xcode IDE and would love to build my projects directly with VS Code and CMake.

I’ve noticed that the latest versions of JUCE have excellent CMake support, and I’ve been looking at the CMakeLists.txt template provided in the examples/CMake/AudioPlugin directory in the source code. This looks very promising!

However, as a beginner to this specific workflow, I’m a bit lost on the concrete steps to tie everything together. I’ve searched for tutorials, but haven’t found one that clearly covers this specific combination from start to finish (JUCE + CMake + VS Code on macOS).

Could anyone here share some guidance or point me to a good resource? My main questions are:

  1. Starting a New Project: What is the recommended way to start a new project using the CMake template? Should I just copy the example folder and modify it?
  2. Directory Structure: Is there a best-practice directory structure for a project where the JUCE source code is kept separate (e.g., as a submodule or in a parallel folder)?
  3. VS Code Configuration: Are there any specific settings or “gotchas” when configuring the CMake Tools and C/C++ extensions in VS Code for a JUCE project on macOS? For example, setting up IntelliSense correctly or configuring build targets (Standalone, VST3, AU).
  4. Building and Running: What’s the smoothest way within VS Code to compile all formats and then run/debug the Standalone version?

I’m really excited to dive into JUCE development, and any advice on getting this workflow up and running would be incredibly helpful.

Thanks in advance for your time and help!

1 Like

Hi,

Here are some thoughts on getting started:

Project Setup: Use the Pamplejuce template for audio plugin projects. It’s a modern project template specifically designed for building JUCE audio plugins with CMake that comes with proper directory structure and JUCE as a git submodule. It should get you started quickly with your new project.

VS Code Configuration: Install the CMake Tools and C/C++ extensions. Key settings:

  • Set cmake.configureOnOpen to true
  • Choose “Clang” as your kit when prompted
  • IntelliSense should auto-configure once CMake generates

Building/Running: Create a CMakePresets.json in your project root - they make switching between builds much smoother. VS Code will automatically detect it. This file lets you define build configurations (Debug/Release) and target different plugin formats.

Check these docs for preset examples:

Hope this helps!

1 Like

Or you use simply JuMake. https://youtu.be/CU0WyozBjOk?si=GTykXT5-W7aCnXeI

@bencekovacs set up looks correct to me – just want to point out that if you do not install Xcode (AppleClang), you will have to install clang (or another compiler of your choice), which probably takes just as much space on disk

Xcode Command Line Tools include Apple Clang (essential) while Xcode IDE is completely optional. Not sure about the code-completion in VS code though.

2 Likes

You can also install the clangd plugin for VSCode which does a great job of understanding your project (jump to definiton, show call heirarchy etc). Just need to make sure that you set up CMake to emit a compiler_commands.jsonfile

Currently fighting with VSCode, CMake and clangd

Does clangd find the juce class-members correctly for auto-completion at your side, it doesn’t at all on my side. And according to this thread this is/was a problem `clangd` LSP and JUCE's unity build - #3 by mqtthiqs.

Any tips for better auto-completion with vscode? (Intellisence not working good enough either)

Or should I just forget about it and try Clion? :laughing:

Maybe you’ve done this already, but for me I have to choose a specific build target rather than using all/ALL_BUILD. I guess since different targets can have different compile commands, defintions, etc. the extension doesn’t know which to parse unless you explicitly tell it which target you’re building.

If you’re building a plugin then select the static library named like “MyPlugin” rather than “MyPlugin_VST3”.

>CMake: Set Build Target

thanks, I’m still in the evaluation phase, and use the Box2dDemo included in JUCE

In this case I would expect that it shows me the class members of renderer.

(“C_Cpp.intelliSenseEngine”: “disabled”, was a tip, because it might interference with clangd, but didn’t help)

I don’t know if any of this was mentioned already in this thread but this is what I do:

First, add this to CMakeLists.txt:

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

This creates a “compile_commands.json” file in your_cmake_build_folder that can be read by clangd.

CLion finds this file automatically. For Visual Studio Code / Cursor, add in .vscode/settings.json:

{
    "clangd.arguments": [
        "--compile-commands-dir=${workspaceFolder}/your_cmake_build_folder"
    ]
}

If you also use the legacy #include “JuceHeader.h” then in CMakeLists.txt you will need to call:

juce_generate_juce_header(target_name)

But this won’t be found by clandg so you have to explicitly include it too:

include_directories("${CMAKE_BINARY_DIR}/XXX/XXX_artefacts/JuceLibraryCode")

And this last bit won’t work of course until you have compiled your code at least once!

Hope it helps