Browse Source

CMake: Link necessary libraries for hosting plugins

The CoreAudioKit (and on macOS, AudioUnit) frameworks are required to
host AudioUnit plugins. Hosts (especially those which don't use the
`juce_audio_utils` module) should use the new `PLUGINHOST_AU` parameter
to `juce_add_*` in order to add the correct preprocessor definition and
link the necessary frameworks.
tags/2021-05-28
reuk 5 years ago
parent
commit
5e5ac203b9
No known key found for this signature in database GPG Key ID: 9ADCD339CFC98A11
3 changed files with 27 additions and 2 deletions
  1. +6
    -0
      examples/CMake/readme.md
  2. +2
    -2
      extras/AudioPluginHost/CMakeLists.txt
  3. +19
    -0
      extras/Build/CMake/JUCEUtils.cmake

+ 6
- 0
examples/CMake/readme.md View File

@@ -399,6 +399,12 @@ attributes directly to these creation functions, rather than adding them later.
`AAX_ePlugInCategory_SWGenerators`, `AAX_ePlugInCategory_WrappedPlugin`,
`AAX_ePlugInCategory_Effect`

- `PLUGINHOST_AU`
- May be either TRUE or FALSE (defaults to FALSE). If TRUE, will add the preprocessor definition
`JUCE_PLUGINHOST_AU=1` to the new target, and will link the macOS frameworks necessary for
hosting plugins. Using this parameter should be preferred over using
`target_compile_definitions` to manually set the `JUCE_PLUGINHOST_AU` preprocessor definition.

- `COPY_PLUGIN_AFTER_BUILD`
- Whether or not to install the plugin to the current system after building. False by default.
If you want all of the plugins in a subdirectory to be installed automatically after building,


+ 2
- 2
extras/AudioPluginHost/CMakeLists.txt View File

@@ -17,7 +17,8 @@
juce_add_gui_app(AudioPluginHost
BUNDLE_ID com.juce.pluginhost
ICON_BIG "${CMAKE_CURRENT_SOURCE_DIR}/Source/JUCEAppIcon.png"
MICROPHONE_PERMISSION_ENABLED TRUE)
MICROPHONE_PERMISSION_ENABLED TRUE
PLUGINHOST_AU TRUE)

juce_generate_juce_header(AudioPluginHost)

@@ -33,7 +34,6 @@ target_compile_definitions(AudioPluginHost PRIVATE
PIP_JUCE_EXAMPLES_DIRECTORY_STRING="${JUCE_SOURCE_DIR}/examples"
JUCE_ALSA=1
JUCE_DIRECTSOUND=1
JUCE_PLUGINHOST_AU=1
JUCE_PLUGINHOST_LADSPA=1
JUCE_PLUGINHOST_VST=0
JUCE_PLUGINHOST_VST3=1


+ 19
- 0
extras/Build/CMake/JUCEUtils.cmake View File

@@ -1634,6 +1634,8 @@ function(_juce_set_fallback_properties target)
_juce_set_property_if_not_set(${target} DISABLE_AAX_BYPASS FALSE)
_juce_set_property_if_not_set(${target} DISABLE_AAX_MULTI_MONO FALSE)

_juce_set_property_if_not_set(${target} PLUGINHOST_AU FALSE)

get_target_property(bundle_id ${target} JUCE_BUNDLE_ID)
_juce_set_property_if_not_set(${target} AAX_IDENTIFIER ${bundle_id})

@@ -1824,6 +1826,7 @@ function(_juce_initialise_target target)
AU_EXPORT_PREFIX
AU_SANDBOX_SAFE
AAX_CATEGORY
PLUGINHOST_AU # Set this true if you want to host AU plugins

VST_COPY_DIR
VST3_COPY_DIR
@@ -1894,6 +1897,22 @@ function(_juce_initialise_target target)
$<TARGET_PROPERTY:${target},JUCE_GENERATED_SOURCES_DIRECTORY>)
target_link_libraries(${target} PUBLIC $<$<TARGET_EXISTS:juce_vst2_sdk>:juce_vst2_sdk>)

get_target_property(is_pluginhost_au ${target} JUCE_PLUGINHOST_AU)

if(is_pluginhost_au)
target_compile_definitions(${target} PUBLIC JUCE_PLUGINHOST_AU=1)

if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS")
find_library(AU_CoreAudioKit CoreAudioKit REQUIRED)
target_link_libraries(${target} PRIVATE ${AU_CoreAudioKit})
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
find_library(AU_AudioUnit AudioUnit REQUIRED)
target_link_libraries(${target} PRIVATE ${AU_AudioUnit})
endif()
endif()

_juce_write_generate_time_info(${target})
_juce_link_optional_libraries(${target})
endfunction()


Loading…
Cancel
Save