CLion and JUCE OSX build configuration

Hey! JUCE beginner here, recently converted to using CLion due to several XCode issues.

I’ve exported a basic audio applicaton example, but get CMake errors when atempting to build: No project() command is present.

Please can someone advise on exactly what build configuration is required (and advised) for building JUCE using CLion? I’m unsure how to handle this given the Projucer-exported CMakeLists.txt file ‘shouldn’t’ be edited. I feel I’m missing some tutorial, somewhere?

Thanks!

CLion 2020.2 + Juce 6.0.1 on OSX 10.15

If you are using CLion you may as well just ditch the projucer alltogether and use a non-projucer generated CMakeLists.txt file along with the JUCE CMake API. The CLion exporter was made before JUCE 6 so its a bit out dated now that juce 6 is out. Juce 6 introduced full CMake support (elimnated the need for the projucer) and the API has nice CMake functions that make it easy to import juce and add juce submodules to your project. Your cmake lists file will end up being a lot cleaner than the projucer generated one and much easier to read.

I would first give the CMake API documentation a read, then you can copy one of the CMake examples CmakeLists.txt files into the root of your project directory (remove the old projucer generated one) and build using that. You will have to change some settings depending on how your juce install is set up (Its probably easiest just to clone juce into the root of your project directory as a git submodule, and then uncomment the add_subdirectory(juce) call in the CMakeListsFile). Most of this is covered in the API docs. You will also need to edit the project name and company related settings etc. Then you can add your sources to the target_sources list. Note that the API docs recommend not generating a juce header and instead importing the individual modules you need (i.e if you need gui stuff in some file you would add #import <juce_gui_basics/juce_gui_basics.h> in whatever file needs it and link to the juce_gui_basics module in the target_link_libraries command in your cmake lists)

It may feel weird not using the projucer at first, but CMake is very powerful and most of the projucer settings simply correspond to a variable in the CMake API. I really like the control CMake gives you when it comes to building multiple projects (such as unit tests). The API is also well documented which is nice.

It may seem like a lot at first because there will be a lot of CMake stuff you dont understand, but most of the stuff is very basic CMake. juce does most of the heavy lifting for you. If you want to learn some basic CMake here is a good tutorial that I found helpful when I switched from the projucer

1 Like

Great! I’m familiar with CMake so am quite pleased to hear the advice to just go ahead with a DIY CMakeLists.txt file.

Thanks for the tip, I’ll give this a go :slight_smile:

I’ll let you know how I get on!