From d9fe2f0e777554c0066a859385f0ebd9b705a305 Mon Sep 17 00:00:00 2001 From: reuk Date: Thu, 24 Oct 2024 15:15:11 +0100 Subject: [PATCH] CMake: Automatically set AAX_EPluginCategory_MIDIEffect when JUCE_MIDI_EFFECT is enabled --- docs/CMake API.md | 10 +-- extras/Build/CMake/JUCEUtils.cmake | 103 +++++++++++++++++------------ 2 files changed, 62 insertions(+), 51 deletions(-) diff --git a/docs/CMake API.md b/docs/CMake API.md index 36146ef81f..689357acf6 100644 --- a/docs/CMake API.md +++ b/docs/CMake API.md @@ -577,13 +577,9 @@ attributes directly to these creation functions, rather than adding them later. in GarageBand. `AAX_CATEGORY` -- Should be one or more of: `AAX_ePlugInCategory_None`, `AAX_ePlugInCategory_EQ`, - `AAX_ePlugInCategory_Dynamics`, `AAX_ePlugInCategory_PitchShift`, `AAX_ePlugInCategory_Reverb`, - `AAX_ePlugInCategory_Delay`, `AAX_ePlugInCategory_Modulation`, `AAX_ePlugInCategory_Harmonic`, - `AAX_ePlugInCategory_NoiseReduction`, `AAX_ePlugInCategory_Dither`, - `AAX_ePlugInCategory_SoundField`, `AAX_ePlugInCategory_HWGenerators`, - `AAX_ePlugInCategory_SWGenerators`, `AAX_ePlugInCategory_WrappedPlugin`, - `AAX_EPlugInCategory_Effect` +- Should be one or more of: `None`, `EQ`, `Dynamics`, `PitchShift`, `Reverb`, `Delay`, `Modulation`, + `Harmonic`, `NoiseReduction`, `Dither`, `SoundField`, `HWGenerators`, `SWGenerators`, + `WrappedPlugin`, `Effect`, and `MIDIEffect`. You may also add the prefix `AAX_ePlugInCategory_`. `PLUGINHOST_AU` - May be either TRUE or FALSE (defaults to FALSE). If TRUE, will add the preprocessor definition diff --git a/extras/Build/CMake/JUCEUtils.cmake b/extras/Build/CMake/JUCEUtils.cmake index c429bf6e29..6317df1418 100644 --- a/extras/Build/CMake/JUCEUtils.cmake +++ b/extras/Build/CMake/JUCEUtils.cmake @@ -1624,6 +1624,58 @@ endfunction() # ================================================================================================== +# Only sets result if the categories list contains valid entries +function(_juce_aax_categories_to_int categories_list result) + set(aax_category_strings + None + EQ + Dynamics + PitchShift + Reverb + Delay + Modulation + Harmonic + NoiseReduction + Dither + SoundField + HWGenerators + SWGenerators + WrappedPlugin + Effect + placeholder # These placeholders are because there's a gap between Effect + placeholder # and MIDIEffect in the definition of AAX_EPlugInCategory. + MIDIEffect) + + unset(aax_category_int) + + foreach(category_string IN LISTS categories_list) + string(REGEX REPLACE "^AAX_[eE]PlugInCategory_" "" category_string "${category_string}") + list(FIND aax_category_strings ${category_string} aax_index) + + if(aax_index GREATER_EQUAL 0) + if(aax_index EQUAL 0) + set(aax_category_bit 0) + else() + set(aax_category_bit "1 << (${aax_index} - 1)") + endif() + + if(NOT DEFINED aax_category_int) + set(aax_category_int 0) + endif() + + math(EXPR aax_category_int "${aax_category_int} | (${aax_category_bit})") + else() + message(WARNING "Unrecognised AAX category: '${category_string}'. See the `CMake API.md` entry for `AAX_CATEGORY` for valid values.") + endif() + endforeach() + + if(DEFINED aax_category_int) + set(${result} "${aax_category_int}" PARENT_SCOPE) + endif() +endfunction() + +# ================================================================================================== + function(_juce_set_generic_property_if_not_set target property) list(LENGTH ARGN num_extra_args) @@ -1803,57 +1855,20 @@ function(_juce_set_fallback_properties target) # AAX category - # The order of these strings is important, as the index of each string - # will be used to set an appropriate bit in the category bitfield. - set(aax_category_strings - ePlugInCategory_None - ePlugInCategory_EQ - ePlugInCategory_Dynamics - ePlugInCategory_PitchShift - ePlugInCategory_Reverb - ePlugInCategory_Delay - ePlugInCategory_Modulation - ePlugInCategory_Harmonic - ePlugInCategory_NoiseReduction - ePlugInCategory_Dither - ePlugInCategory_SoundField - ePlugInCategory_HWGenerators - ePlugInCategory_SWGenerators - ePlugInCategory_WrappedPlugin - ePlugInCategory_Effect) - - if(is_synth) - set(default_aax_category ePlugInCategory_SWGenerators) + if(is_midi_effect) + set(default_aax_category AAX_ePlugInCategory_MIDIEffect) + elseif(is_synth) + set(default_aax_category AAX_ePlugInCategory_SWGenerators) else() - set(default_aax_category ePlugInCategory_None) + set(default_aax_category AAX_ePlugInCategory_None) endif() _juce_set_property_if_not_set(${target} AAX_CATEGORY ${default_aax_category}) - # Replace AAX category string with its integral representation get_target_property(actual_aax_category ${target} JUCE_AAX_CATEGORY) + _juce_aax_categories_to_int("${actual_aax_category}" aax_category_int) - set(aax_category_int "") - - foreach(category_string IN LISTS actual_aax_category) - list(FIND aax_category_strings ${category_string} aax_index) - - if(aax_index GREATER_EQUAL 0) - if(aax_index EQUAL 0) - set(aax_category_bit 0) - else() - set(aax_category_bit "1 << (${aax_index} - 1)") - endif() - - if(aax_category_int STREQUAL "") - set(aax_category_int 0) - endif() - - math(EXPR aax_category_int "${aax_category_int} | (${aax_category_bit})") - endif() - endforeach() - - if(NOT aax_category_int STREQUAL "") + if(DEFINED aax_category_int) set_target_properties(${target} PROPERTIES JUCE_AAX_CATEGORY ${aax_category_int}) endif()