Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions cmake/platforms/mac/AUInfo.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>@PLUGIN_AU_NAME@</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>@PLUGIN_AU_VERSION@</string>
<key>CFBundleVersion</key>
<string>@PLUGIN_AU_VERSION@</string>
<key>CFBundleSignature</key>
<string>@PLUGIN_AU_MANUFACTURER@</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright (c) 2026 - kunitoki@gmail.com</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>AudioComponents</key>
<array>
<dict>
<key>type</key>
<string>@PLUGIN_AU_TYPE@</string>
<key>subtype</key>
<string>@PLUGIN_AU_SUBTYPE@</string>
<key>manufacturer</key>
<string>@PLUGIN_AU_MANUFACTURER@</string>
<key>name</key>
<string>@PLUGIN_AU_NAME@</string>
<key>version</key>
<integer>1</integer>
<key>factoryFunction</key>
<string>AudioPluginProcessorAUFactory</string>
<key>sandboxSafe</key>
<true/>
</dict>
</array>
</dict>
</plist>
182 changes: 167 additions & 15 deletions cmake/yup_audio_plugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function (yup_audio_plugin)
# Globals
TARGET_NAME TARGET_VERSION TARGET_IDE_GROUP TARGET_APP_ID TARGET_APP_NAMESPACE TARGET_CXX_STANDARD
# Plugin types
PLUGIN_CREATE_CLAP PLUGIN_CREATE_VST3 PLUGIN_CREATE_STANDALONE)
PLUGIN_CREATE_CLAP PLUGIN_CREATE_VST3 PLUGIN_CREATE_STANDALONE PLUGIN_CREATE_AU)

set (multi_value_args
DEFINITIONS
Expand All @@ -44,6 +44,11 @@ function (yup_audio_plugin)
set (target_app_id "${YUP_ARG_TARGET_APP_ID}")
set (target_app_namespace "${YUP_ARG_TARGET_APP_NAMESPACE}")
set (target_cxx_standard "${YUP_ARG_TARGET_CXX_STANDARD}")
set (target_bundle_id "${target_app_id}")
if (NOT target_bundle_id)
set (target_bundle_id "org.kunitoki.yup.${target_name}")
endif()
string (REGEX REPLACE "[^A-Za-z0-9.-]" "-" target_bundle_id "${target_bundle_id}")
set (additional_definitions "")
set (additional_options "")
set (additional_libraries "")
Expand All @@ -55,8 +60,8 @@ function (yup_audio_plugin)
return()
endif()

if (NOT YUP_ARG_PLUGIN_CREATE_CLAP AND NOT YUP_ARG_PLUGIN_CREATE_VST3 AND NOT YUP_ARG_PLUGIN_CREATE_STANDALONE)
_yup_message (FATAL_ERROR "At least one plugin type must be enabled (CLAP, VST3, or Standalone).")
if (NOT YUP_ARG_PLUGIN_CREATE_CLAP AND NOT YUP_ARG_PLUGIN_CREATE_VST3 AND NOT YUP_ARG_PLUGIN_CREATE_STANDALONE AND NOT YUP_ARG_PLUGIN_CREATE_AU)
_yup_message (FATAL_ERROR "At least one plugin type must be enabled (CLAP, VST3, AU, or Standalone).")
return()
endif()

Expand Down Expand Up @@ -140,19 +145,26 @@ function (yup_audio_plugin)
${YUP_ARG_MODULES})

set_target_properties (${target_name}_clap_plugin PROPERTIES
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
OBJC_VISIBILITY_PRESET hidden
OBJCXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
SUFFIX ".clap"
FOLDER "${YUP_ARG_TARGET_IDE_GROUP}"
XCODE_GENERATE_SCHEME ON)

#yup_audio_plugin_copy_bundle (${target_name} clap)
yup_audio_plugin_copy_bundle (${target_name} clap)
endif()

# ==== Fetch vst3 SDK and build vst3 target
if (YUP_ARG_PLUGIN_CREATE_VST3)
_yup_fetch_vst3sdk()

_yup_message (STATUS "Setting up VST3 plugin client")
get_directory_property (_yup_vst3_saved_compile_options COMPILE_OPTIONS)
smtg_enable_vst3_sdk()
set_directory_properties (PROPERTIES COMPILE_OPTIONS "${_yup_vst3_saved_compile_options}")

_yup_module_setup_plugin_client (
${target_name}
Expand Down Expand Up @@ -191,7 +203,7 @@ function (yup_audio_plugin)

if (YUP_PLATFORM_MAC)
smtg_target_set_bundle (${target_name}_vst3_plugin
BUNDLE_IDENTIFIER org.kunitoki.yup.${target_name}
BUNDLE_IDENTIFIER "${target_bundle_id}"
COMPANY_NAME "kunitoki")

#smtg_target_set_debug_executable(MyPlugin
Expand All @@ -211,6 +223,11 @@ function (yup_audio_plugin)
endif()

set_target_properties (${target_name}_vst3_plugin PROPERTIES
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
OBJC_VISIBILITY_PRESET hidden
OBJCXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
SUFFIX ".vst3"
FOLDER "${YUP_ARG_TARGET_IDE_GROUP}"
XCODE_GENERATE_SCHEME ON)
Expand All @@ -233,7 +250,7 @@ function (yup_audio_plugin)
TARGET_NAME ${target_name}_standalone_plugin
TARGET_VERSION ${target_version}
TARGET_IDE_GROUP ${target_ide_group}
TARGET_APP_ID ${target_app_id}
TARGET_APP_ID ${target_bundle_id}
TARGET_APP_NAMESPACE ${target_app_namespace}
TARGET_CXX_STANDARD ${target_cxx_standard}
DEFINITIONS
Expand All @@ -247,6 +264,121 @@ function (yup_audio_plugin)
${YUP_ARG_MODULES})
endif()

# ==== Build AUv2 plugin target (macOS only)
if (YUP_ARG_PLUGIN_CREATE_AU)
if (NOT YUP_PLATFORM_MAC)
_yup_message (WARNING "AUv2 plugins are only supported on macOS. Skipping AU target.")
else()
_yup_fetch_apple_ausdk()

_yup_message (STATUS "Setting up AUv2 plugin client")
_yup_module_setup_plugin_client (
${target_name}
yup_audio_plugin_client
${YUP_ARG_TARGET_IDE_GROUP}
au
${YUP_ARG_UNPARSED_ARGUMENTS})

# Determine AU type (aumu for instruments, aufx for effects)
cmake_parse_arguments (AU_ARGS ""
"PLUGIN_IS_SYNTH;PLUGIN_AU_SUBTYPE;PLUGIN_AU_MANUFACTURER;PLUGIN_NAME;PLUGIN_VERSION;PLUGIN_ID;PLUGIN_VENDOR;PLUGIN_DESCRIPTION;PLUGIN_URL;PLUGIN_EMAIL;PLUGIN_IS_MONO"
"" ${YUP_ARG_UNPARSED_ARGUMENTS})
if (AU_ARGS_PLUGIN_IS_SYNTH)
set (au_bundle_type "aumu")
else()
set (au_bundle_type "aufx")
endif()

if (NOT AU_ARGS_PLUGIN_AU_SUBTYPE)
set (AU_ARGS_PLUGIN_AU_SUBTYPE "Dflt")
endif()
if (NOT AU_ARGS_PLUGIN_AU_MANUFACTURER)
set (AU_ARGS_PLUGIN_AU_MANUFACTURER "Yup!")
endif()
if (NOT AU_ARGS_PLUGIN_NAME)
set (AU_ARGS_PLUGIN_NAME "${target_name}")
endif()
if (NOT AU_ARGS_PLUGIN_VERSION)
set (AU_ARGS_PLUGIN_VERSION "1")
endif()

_yup_message (STATUS "Creating AUv2 plugin target")
add_library (${target_name}_au_plugin MODULE)

target_compile_features (${target_name}_au_plugin PRIVATE cxx_std_${target_cxx_standard})

target_compile_definitions (${target_name}_au_plugin PRIVATE
YUP_AUDIO_PLUGIN_ENABLE_AU=1
YUP_STANDALONE_APPLICATION=0)

target_link_libraries (${target_name}_au_plugin PRIVATE
${target_name}_shared
yup_audio_plugin_client
base-sdk-auv2
${target_name}_au
${additional_libraries}
${YUP_ARG_MODULES}
"-framework AudioUnit"
"-framework AudioToolbox"
"-framework CoreAudio"
"-framework CoreFoundation"
"-framework AppKit")

_yup_module_apply_arc_to_target_sources (${target_name}_au_plugin
${target_name}_shared
yup_audio_plugin_client
base-sdk-auv2
${target_name}_au
${additional_libraries}
${YUP_ARG_MODULES})

# Generate the AU Info.plist from our template
set (au_plist_template "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/platforms/mac/AUInfo.plist")
set (au_plist_output "${CMAKE_CURRENT_BINARY_DIR}/${target_name}_au_plugin.plist")

set (PLUGIN_AU_TYPE "${au_bundle_type}")
set (PLUGIN_AU_SUBTYPE "${AU_ARGS_PLUGIN_AU_SUBTYPE}")
set (PLUGIN_AU_MANUFACTURER "${AU_ARGS_PLUGIN_AU_MANUFACTURER}")
set (PLUGIN_AU_NAME "${AU_ARGS_PLUGIN_NAME}")
set (PLUGIN_AU_VERSION "${AU_ARGS_PLUGIN_VERSION}")

set (au_bundle_identifier "${target_bundle_id}.au")
string (REGEX REPLACE "[^A-Za-z0-9.-]" "-" au_bundle_identifier "${au_bundle_identifier}")

set (au_pkginfo_file "${CMAKE_CURRENT_BINARY_DIR}/${target_name}_au_plugin.PkgInfo")
file (WRITE "${au_pkginfo_file}" "BNDL${AU_ARGS_PLUGIN_AU_MANUFACTURER}")

configure_file ("${au_plist_template}" "${au_plist_output}" @ONLY)

set_target_properties (${target_name}_au_plugin PROPERTIES
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
OBJC_VISIBILITY_PRESET hidden
OBJCXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
BUNDLE TRUE
BUNDLE_EXTENSION "component"
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST "${au_plist_output}"
MACOSX_BUNDLE_BUNDLE_NAME "${AU_ARGS_PLUGIN_NAME}"
MACOSX_BUNDLE_BUNDLE_VERSION "${AU_ARGS_PLUGIN_VERSION}"
MACOSX_BUNDLE_SHORT_VERSION_STRING "${AU_ARGS_PLUGIN_VERSION}"
MACOSX_BUNDLE_GUI_IDENTIFIER "${au_bundle_identifier}"
FOLDER "${YUP_ARG_TARGET_IDE_GROUP}"
XCODE_ATTRIBUTE_GENERATE_PKGINFO_FILE YES
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_PACKAGE_TYPE BNDL
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${au_bundle_identifier}"
XCODE_GENERATE_SCHEME ON)

add_custom_command (TARGET ${target_name}_au_plugin POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${au_pkginfo_file}" "$<TARGET_BUNDLE_CONTENT_DIR:${target_name}_au_plugin>/PkgInfo"
COMMENT "Generating AU PkgInfo"
VERBATIM)

yup_audio_plugin_copy_bundle (${target_name} au)
endif()
endif()

endfunction()

#==============================================================================
Expand All @@ -258,11 +390,18 @@ function (yup_audio_plugin_copy_bundle target_name plugin_type)

string (TOUPPER "${plugin_type}" plugin_type_upper)
set (dependency_target ${target_name}_${plugin_type}_plugin)
set (target_file_name "${target_name}_${plugin_type}_plugin.${plugin_type}")
set (plugin_target_path "$ENV{HOME}/Library/Audio/Plug-Ins/${plugin_type_upper}")

if ("${plugin_type}" STREQUAL "au")
set (target_file_name "${target_name}_${plugin_type}_plugin.component")
set (plugin_target_path "$ENV{HOME}/Library/Audio/Plug-Ins/Components")
else()
set (target_file_name "${target_name}_${plugin_type}_plugin.${plugin_type}")
set (plugin_target_path "$ENV{HOME}/Library/Audio/Plug-Ins/${plugin_type_upper}")
endif()

set (plugin_path "${plugin_target_path}/${target_file_name}")

if (NOT EXISTS ${plugin_target_path})
if (NOT EXISTS ${plugin_target_path} AND NOT "${plugin_type}" STREQUAL "clap")
_yup_message (STATUS "Plugin path ${plugin_target_path} does not exist, skipping copy")
return()
endif()
Expand All @@ -271,15 +410,28 @@ function (yup_audio_plugin_copy_bundle target_name plugin_type)

if ("${plugin_type}" STREQUAL "clap")
add_custom_command(TARGET ${dependency_target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E rm -f ${plugin_path}
COMMAND ${CMAKE_COMMAND} -E create_symlink "$<TARGET_FILE:${dependency_target}>" ${plugin_path}
COMMENT "Copying ${plugin_type_upper} plugin to ${plugin_path}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${plugin_target_path}"
COMMAND ${CMAKE_COMMAND} -E rm -f "${plugin_path}"
COMMAND ${CMAKE_COMMAND} -E create_symlink "$<TARGET_FILE:${dependency_target}>" "${plugin_path}"
COMMENT "Symlinking CLAP plugin ${plugin_type_upper} plugin to ${plugin_path}"
VERBATIM)
elseif ("${plugin_type}" STREQUAL "vst3")
get_target_property (source_plugin_path ${dependency_target} SMTG_PLUGIN_PACKAGE_PATH)
if (NOT source_plugin_path)
set (source_plugin_path "$<TARGET_BUNDLE_DIR:${dependency_target}>")
endif()

add_custom_command(TARGET ${dependency_target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E rm -rf "${plugin_path}"
COMMAND ${CMAKE_COMMAND} -E create_symlink "${source_plugin_path}" "${plugin_path}"
COMMENT "Symlinking VST3 plugin ${plugin_type_upper} plugin to ${plugin_path}"
VERBATIM)
elseif ("${plugin_type}" STREQUAL "au")
add_custom_command(TARGET ${dependency_target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E rm -f ${plugin_path}
COMMAND ${CMAKE_COMMAND} -E create_symlink "$<TARGET_FILE_DIR:${dependency_target}>/../../../${target_file_name}" ${plugin_path}
COMMENT "Copying ${plugin_type_upper} plugin to ${plugin_path}"
COMMAND ${CMAKE_COMMAND} -E rm -rf "${plugin_path}"
COMMAND ${CMAKE_COMMAND} -E create_symlink "$<TARGET_BUNDLE_DIR:${dependency_target}>" "${plugin_path}"
COMMAND codesign --force --sign - "${plugin_path}"
COMMENT "Symlinking AU plugin ${plugin_type_upper} to ${plugin_path}"
VERBATIM)
else()
_yup_message (FATAL_ERROR "Unsupported plugin type ${plugin_type} for copying bundle")
Expand Down
39 changes: 39 additions & 0 deletions cmake/yup_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,45 @@ endfunction()

#==============================================================================

function (_yup_fetch_apple_ausdk)
if (NOT TARGET base-sdk-auv2)
if (NOT AUDIOUNIT_SDK_ROOT)
_yup_message (STATUS "Fetching Apple AudioUnitSDK")
_yup_fetchcontent_declare (AudioUnitSDK
GIT_REPOSITORY https://github.com/apple/AudioUnitSDK.git
GIT_TAG AudioUnitSDK-1.1.0)
FetchContent_MakeAvailable (AudioUnitSDK)
set (AUDIOUNIT_SDK_ROOT "${audiounitsdk_SOURCE_DIR}")
endif()

set (AUSDK_SRC "${AUDIOUNIT_SDK_ROOT}/src/AudioUnitSDK")

add_library (base-sdk-auv2 STATIC
"${AUSDK_SRC}/AUBase.cpp"
"${AUSDK_SRC}/AUBuffer.cpp"
"${AUSDK_SRC}/AUBufferAllocator.cpp"
"${AUSDK_SRC}/AUEffectBase.cpp"
"${AUSDK_SRC}/AUInputElement.cpp"
"${AUSDK_SRC}/AUMIDIBase.cpp"
"${AUSDK_SRC}/AUMIDIEffectBase.cpp"
"${AUSDK_SRC}/AUOutputElement.cpp"
"${AUSDK_SRC}/AUPlugInDispatch.cpp"
"${AUSDK_SRC}/AUScopeElement.cpp"
"${AUSDK_SRC}/ComponentBase.cpp"
"${AUSDK_SRC}/MusicDeviceBase.cpp")

target_include_directories (base-sdk-auv2 PUBLIC "${AUDIOUNIT_SDK_ROOT}/include")
target_compile_features (base-sdk-auv2 PUBLIC cxx_std_17)
target_compile_options (base-sdk-auv2 PRIVATE -Wno-deprecated-declarations)

set_target_properties (base-sdk-auv2 PROPERTIES
POSITION_INDEPENDENT_CODE ON
FOLDER "Thirdparty")
endif()
endfunction()

#==============================================================================

function (_yup_fetch_clap)
if (NOT TARGET clap)
_yup_message (STATUS "Fetching CLAP SDK")
Expand Down
15 changes: 13 additions & 2 deletions cmake/yup_modules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ function (_yup_module_setup_plugin_client target_name plugin_client_target folde
endif()

set (options "")
set (one_value_args PLUGIN_ID PLUGIN_NAME PLUGIN_VENDOR PLUGIN_VERSION PLUGIN_DESCRIPTION PLUGIN_URL PLUGIN_EMAIL PLUGIN_IS_SYNTH PLUGIN_IS_MONO)
set (one_value_args PLUGIN_ID PLUGIN_NAME PLUGIN_VENDOR PLUGIN_VERSION PLUGIN_DESCRIPTION PLUGIN_URL PLUGIN_EMAIL PLUGIN_IS_SYNTH PLUGIN_IS_MONO PLUGIN_AU_SUBTYPE PLUGIN_AU_MANUFACTURER)
set (multi_value_args "")

cmake_parse_arguments (YUP_ARG "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN})
Expand All @@ -523,8 +523,11 @@ function (_yup_module_setup_plugin_client target_name plugin_client_target folde
elseif (plugin_type STREQUAL "standalone")
set (custom_target_name "${target_name}_standalone")
set (plugin_define "YUP_AUDIO_PLUGIN_ENABLE_STANDALONE=1")
elseif (plugin_type STREQUAL "au")
set (custom_target_name "${target_name}_au")
set (plugin_define "YUP_AUDIO_PLUGIN_ENABLE_AU=1")
else()
_yup_message (FATAL_ERROR "Invalid plugin type: ${plugin_type}. Must be either 'vst3', 'clap' or 'standalone'")
_yup_message (FATAL_ERROR "Invalid plugin type: ${plugin_type}. Must be either 'vst3', 'clap', 'au' or 'standalone'")
endif()

add_library (${custom_target_name} INTERFACE)
Expand Down Expand Up @@ -562,6 +565,14 @@ function (_yup_module_setup_plugin_client target_name plugin_client_target folde
list (APPEND module_defines YupPlugin_IsMono=0)
endif()

if (YUP_ARG_PLUGIN_AU_SUBTYPE)
list (APPEND module_defines "YupPlugin_AUSubType=\"${YUP_ARG_PLUGIN_AU_SUBTYPE}\"")
endif()

if (YUP_ARG_PLUGIN_AU_MANUFACTURER)
list (APPEND module_defines "YupPlugin_AUManufacturer=\"${YUP_ARG_PLUGIN_AU_MANUFACTURER}\"")
endif()

if (YUP_PLATFORM_APPLE)
_yup_glob_recurse ("${module_path}/${plugin_type}/*.mm" module_sources)
else()
Expand Down
Loading
Loading