Why is loading a VST3 from it's filepath not working?

Based on this forum post, I have the following code, to try to load a plugin description, to load an instance of it.

auto typesFound = juce::OwnedArray<juce::PluginDescription>();
const juce::String plugin = "/Library/Audio/Plug-Ins/VST3/<plugin>.vst3";
const juce::StringArray filenames = {plugin};
auto knownPlugins = juce::KnownPluginList();
auto formatManager = juce::AudioPluginFormatManager();
formatManager.addDefaultFormats();

knownPlugins.scanAndAddDragAndDroppedFiles(formatManager, {plugin}, typesFound);

However, the code is not able to find the plugin:

auto numTypes = typesFound.size(); // = 0
auto description = knownPlugins.getTypeForFile(plugin); // = nullptr

What is wrong with this code? I tried it on Linux as well as Mac, and it had the same result.

Answered my own question: in CMakeLists.txt, I added JUCE_PLUGINHOST_VST3=1 (and other formats) to target_compile_definitions, and that did the trick.