Help needed using CMake and importing juce_dsp


As I’m learning mostly anything related to Juce (and enjoying a lot) I feel I have tones of newbie questions.

This time:

I’m using cmake to handle my project (and learning this too).

When I try to use any of the dsp classes, I can’t compile my project, I got this error message:

In file included from /Users/manelibanez/Test/JUCE/modules/juce_dsp/juce_dsp.h:248:
/Users/manelibanez/Test/JUCE/modules/juce_dsp/containers/juce_AudioBlock.h:68:14: error: no template named 'enable_if_t' in namespace 'std'; did you mean 'enable_if'?

I think I’m not including something or missing something, that’s the whole document causing the compilation error:

#include "Testclass.h"

#include <juce_core/juce_core.h>
#include <juce_dsp/juce_dsp.h>
using namespace juce;
float Testclass::Distorsion(int value1, int value2) {
    return value1 + value2;

As I mentioned, I’m using CMake for the project, as I’m using latest JUCE 6 version.

If anyone can lend me a hand in order to understand what dependency am I missing to import, or how to solve this, I woudl appreciate it a lot.

target_compile_features(myProject PRIVATE cxx_std_14)

but juce should have put it in your project when using juce_dsp

1 Like

That fixed it!
I used the CMake sample in the examples directory, and it was not set anywhere there in that cmakelist document. I’m new to c++ so not sure wheter it should be there or not.

juce_dsp module advertise minimumCppStandard to 14 so Juce should force your project to add it.

It sounds like you might be missing juce::juce_dsp in your target_link_libraries call, e.g.

target_link_libraries(AudioPluginExample PRIVATE

If you link juce_dsp in this way, you shouldn’t need to explicitly set the language standard (unless you want to use a standard higher than 14).