Point CMake to JUCE dir outside of project tree

I’m trying to set up a new app project using JUCE and CMake. The CMakeLists.txt template in JUCE/examples/CMake/GuiApp says:

# If you've installed JUCE somehow (via a package manager, or directly using the CMake install
# target), you'll need to tell this project that it depends on the installed copy of JUCE. If you've
# included JUCE directly in your source tree (perhaps as a submodule), you'll need to tell CMake to
# include that subdirectory as part of the build.

# find_package(JUCE CONFIG REQUIRED)        # If you've installed JUCE to your system
# or
# add_subdirectory(JUCE)                    # If you've put JUCE in a subdirectory called JUCE

But what if I have done neither? I have cloned the JUCE repo from github into a folder on disk, but it’s not in a subdirectory of this project and I also didn’t “install JUCE somehow” so find_package doesn’t find it.

In the Projucer, I could just point the project to a JUCE directory anywhere on disk. How do I do the same with CMake?

You can use add_subdirectory in its two-argument form:


1 Like

I have an example repo here, using CPM.

It allows you to configure CMake with:

cmake -G Xcode -B build -D CPM_JUCE_SOURCE="Path_To_JUCE"

That can be anywhere on your drive.

1 Like