Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build a shell AU with cmake #69

Closed
wants to merge 1 commit into from
Closed
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
43 changes: 40 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# CLAP_WRAPPER_BUNDLE_IDENTIFIER the macOS Bundle Identifier. Absent this it is 'org.cleveraudio.wrapper.(name)'
# CLAP_WRAPPER_BUNDLE_VERSION the macOS Bundle Version. Defaults to 1.0
# CLAP_WRAPPER_WINDOWS_SINGLE_FILE if set to TRUE (default) the windows .vst3 is a single file; false a 3.7 spec folder
# CLAP_WRAPPER_BUILD_AUV2 on macOS also build an AUV2
#

cmake_minimum_required(VERSION 3.20)
Expand All @@ -31,6 +32,7 @@ set(CMAKE_COLOR_DIAGNOSTICS ON)
# can just build with this turned on and it will forward all note expressions to your CLAP
option(CLAP_SUPPORTS_ALL_NOTE_EXPRESSIONS "Does the underlying CLAP support note expressions" OFF)
option(CLAP_WRAPPER_WINDOWS_SINGLE_FILE "Build a single fine (rather than folder) on windows" ON)
option(CLAP_WRAPPER_BUILD_AUV2 "Build an AUV2 on macOS" OFF)

project(clap-wrapper
LANGUAGES C CXX
Expand Down Expand Up @@ -64,10 +66,15 @@ else()
set(clapname ${CLAP_WRAPPER_OUTPUT_NAME})
endif()

# Generate a VST3 target name (prepare for AU)
# Generate an AU and VST3
set(pluginname_vst3 ${pluginname}_as_vst3)
message(STATUS "clap-wrapper: VST3 plugin target is '${pluginname_vst3}' generating target '${clapname}.vst3'")

if (${CLAP_WRAPPER_BUILD_AUV2})
set(pluginname_auv2 ${pluginname}_as_auv2)
message(STATUS "clap-wrapper: AUV2 plugin target is '${pluginname_auv2}' generating target '${clapname}.component'")
endif()


# Define the extensions target
add_library(clap-wrapper-extensions INTERFACE)
Expand Down Expand Up @@ -99,7 +106,7 @@ target_compile_options(${pluginname_vst3} PRIVATE $<IF:$<CONFIG:Debug>,-DDEVELOP

if (APPLE)
if ("${CLAP_WRAPPER_BUNDLE_IDENTIFIER}" STREQUAL "")
set(CLAP_WRAPPER_BUNDLE_IDENTIFIER "org.cleveraudio.wrapper.${pluginname}.vst3")
set(CLAP_WRAPPER_BUNDLE_IDENTIFIER "org.cleveraudio.wrapper.${pluginname}")
endif()

if ("${CLAP_WRAPPER_BUNDLE_VERSION}" STREQUAL "")
Expand All @@ -110,7 +117,7 @@ if (APPLE)
set_target_properties(${pluginname_vst3} PROPERTIES
BUNDLE True
BUNDLE_EXTENSION vst3
MACOSX_BUNDLE_GUI_IDENTIFIER ${CLAP_WRAPPER_BUNDLE_IDENTIFIER}
MACOSX_BUNDLE_GUI_IDENTIFIER "${CLAP_WRAPPER_BUNDLE_IDENTIFIER}.vst3"
MACOSX_BUNDLE_BUNDLE_NAME ${clapname}
MACOSX_BUNDLE_BUNDLE_VERSION ${CLAP_WRAPPER_BUNDLE_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${CLAP_WRAPPER_BUNDLE_VERSION}
Expand Down Expand Up @@ -152,4 +159,34 @@ else()
endif()
endif()

if (${CLAP_WRAPPER_BUILD_AUV2})
add_library(${pluginname_auv2} MODULE src/wrapasauv2.cpp)
set_target_properties(${pluginname_auv2} PROPERTIES LIBRARY_OUTPUT_NAME "${CLAP_WRAPPER_OUTPUT_NAME}")

target_link_libraries(${pluginname_auv2} PRIVATE auv2_sdk)

if ("${CLAP_WRAPPER_BUNDLE_IDENTIFIER}" STREQUAL "")
set(CLAP_WRAPPER_BUNDLE_IDENTIFIER "org.cleveraudio.wrapper.${pluginname}")
endif()

if ("${CLAP_WRAPPER_BUNDLE_VERSION}" STREQUAL "")
set(CLAP_WRAPPER_BUNDLE_VERSION "1.0")
endif()

target_link_libraries (${pluginname_auv2} PUBLIC "-framework Foundation" "-framework CoreFoundation" "-framework AudioToolbox")
set_target_properties(${pluginname_auv2} PROPERTIES
BUNDLE True
BUNDLE_EXTENSION component
MACOSX_BUNDLE_GUI_IDENTIFIER "${CLAP_WRAPPER_BUNDLE_IDENTIFIER}.component"
MACOSX_BUNDLE_BUNDLE_NAME ${clapname}
MACOSX_BUNDLE_BUNDLE_VERSION ${CLAP_WRAPPER_BUNDLE_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${CLAP_WRAPPER_BUNDLE_VERSION}
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/cmake/auv2_Info.plist.in
)
if (NOT ${CMAKE_GENERATOR} STREQUAL "Xcode")
add_custom_command(TARGET ${pluginname_auv2} POST_BUILD
WORKING_DIRECTORY $<TARGET_PROPERTY:${pluginname_auv2},LIBRARY_OUTPUT_DIRECTORY>
COMMAND SetFile -a B "$<TARGET_PROPERTY:${pluginname_auv2},MACOSX_BUNDLE_BUNDLE_NAME>.$<TARGET_PROPERTY:${pluginname_auv2},BUNDLE_EXTENSION>")
endif()
endif()

54 changes: 54 additions & 0 deletions cmake/auv2_Info.plist.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//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_INFO_STRING}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
<key>NSPrincipalClass</key>
<string/>
<key>NSHighResolutionCapable</key>
<true/>
<key>AudioComponents</key>
<array>
<dict>
<key>name</key>
<string>Free Audio : ${MACOSX_BUNDLE_BUNDLE_NAME}</string>
<key>description</key>
<string>${MACOSX_BUNDLE_BUNDLE_NAME} Clap to AU Wrapper</string>
<key>factoryFunction</key>
<string>wrapAsAUV2Factory</string>
<key>manufacturer</key>
<string>FrAD</string>
<key>subtype</key>
<string>WRPR</string>
<key>type</key>
<string>aumu</string>
<key>version</key>
<integer>1</integer>
<key>resourceUsage</key>
<dict>
<key>network.client</key>
<true/>
<key>temporary-exception.files.all.read-write</key>
<true/>
</dict>
</dict>
</array>
</dict>
</plist>
58 changes: 57 additions & 1 deletion cmake/enable_sdks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# set(CLAP_WRAPPER_OUTPUT_NAME "" CACHE STRING "The output name of the dynamically wrapped plugin")
set(CLAP_SDK_ROOT "" CACHE STRING "Path to CLAP SDK")
set(VST3_SDK_ROOT "" CACHE STRING "Path to VST3 SDK")
set(AUDIOUNIT_SDK_ROOT "" CACHE STRING "Path to the Apple AUV2 Audio Unit SDK")

function(DetectCLAP)
if(CLAP_SDK_ROOT STREQUAL "")
Expand All @@ -33,7 +34,7 @@ function(DetectCLAP)

cmake_path(CONVERT "${CLAP_SDK_ROOT}" TO_CMAKE_PATH_LIST CLAP_SDK_ROOT)

message(STATUS "clap-wrapper: CLAP SDK at ${CLAP_SDK_ROOT}")
message(STATUS "clap-wrapper: CLAP SDK location: ${CLAP_SDK_ROOT}")
set(CLAP_SDK_ROOT "${CLAP_SDK_ROOT}" PARENT_SCOPE)

endif()
Expand Down Expand Up @@ -181,6 +182,61 @@ DefineCLAPASVST3Sources()

#####################

function(DetectAudioUnitSDK)
if(AUDIOUNIT_SDK_ROOT STREQUAL "")
message(STATUS "clap-wrapper: searching AudioUnit SDK in \"${CMAKE_CURRENT_SOURCE_DIR}\"...")

if ( AUDIOUNIT_SDK_ROOT STREQUAL "" AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libs/AudioUnitSDK")
set(AUDIOUNIT_SDK_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/libs/AudioUnitSDK")
message(STATUS "clap-wrapper: AudioUnit SDK detected in libs subdirectory")
endif()

if ( AUDIOUNIT_SDK_ROOT STREQUAL "" AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/AudioUnitSDK")
set(AUDIOUNIT_SDK_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/AudioUnitSDK")
message(STATUS "clap-wrapper: AudioUnit SDK detected in subdirectory")
endif()

if ( AUDIOUNIT_SDK_ROOT STREQUAL "" AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../AudioUnitSDK")
set(AUDIOUNIT_SDK_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../AudioUnitSDK")
message(STATUS "clap-wrapper: AudioUnit SDK detected in parent subdirectory")
endif()

if(AUDIOUNIT_SDK_ROOT STREQUAL "")
message(FATAL_ERROR "Unable to detect AudioUnitSDK! Have you set -DCLAP_SDK_ROOT=/path/to/sdk?")
endif()

cmake_path(CONVERT "${AUDIOUNIT_SDK_ROOT}" TO_CMAKE_PATH_LIST AUDIOUNIT_SDK_ROOT)

message(STATUS "clap-wrapper: AudioUnit SDK location: ${AUDIOUNIT_SDK_ROOT}")
set(CLAP_SDK_ROOT "${AUDIOUNIT_SDK_ROOT}" PARENT_SCOPE)
else()
cmake_path(CONVERT "${AUDIOUNIT_SDK_ROOT}" TO_CMAKE_PATH_LIST AUDIOUNIT_SDK_ROOT)
message(STATUS "clap-wrapper: AudioUnit SDK location: ${AUDIOUNIT_SDK_ROOT}")
endif()
endfunction(DetectAudioUnitSDK)

if (APPLE)
if (${CLAP_WRAPPER_BUILD_AUV2})
DetectAudioUnitSDK()

set(AUSDK_SRC ${AUDIOUNIT_SDK_ROOT}/src/AudioUnitSDK)
add_library(auv2_sdk 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(auv2_sdk PUBLIC ${AUDIOUNIT_SDK_ROOT}/include)
endif()
endif()

# define platforms

if (APPLE)
Expand Down
24 changes: 24 additions & 0 deletions src/wrapasauv2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// EmptyPlugIns.cpp
// EmptyPlugIns - this is just the empty plugin shell from the SDK for now
//

#include <AudioUnitSDK/MusicDeviceBase.h>

#if !defined(CLAP_AUSDK_BASE_CLASS)
#define CLAP_AUSDK_BASE_CLASS ausdk::MusicDeviceBase
#endif

struct wrapAsAUV2 : public CLAP_AUSDK_BASE_CLASS
{
using Base = CLAP_AUSDK_BASE_CLASS;

wrapAsAUV2(AudioComponentInstance ci) : Base{ci, 1, 1} {}
bool StreamFormatWritable(AudioUnitScope, AudioUnitElement) override { return true; }
bool CanScheduleParameters() const override { return false; }



};

AUSDK_COMPONENT_ENTRY(ausdk::AUMusicDeviceFactory, wrapAsAUV2)
Loading