Include sdk in empty project cmake

quite new here, i’m trying to follow the creating a plugin from scratch tutorial provided on the steinbergmedia github io (can’t share link) in order to just generally include the SDK in my own blank projects, whether that be for creating a host application or a vst.

however this tutorial seems to be more specifically for vst rather than host(?)

when building the project i get the error: Bundle does not export the required ‘GetPluginFactory’ function. from my understanding this is more to do with building vsts rather than hosts?

this is my current cmakelists.txt:

add_subdirectory(${vst3sdk_SOURCE_DIR} ${PROJECT_BINARY_DIR}/vst3sdk)

smtg_enable_vst3_sdk()

smtg_add_vst3plugin(${BUILD}
  source/main.cpp)

# add_executable(${BUILD}
#   source/main.cpp)

target_link_libraries(${BUILD}
  PRIVATE sdk)

the cmake version and vst directory stuff is there but haven’t included it in this.

if i switch to add_executable i get some strange cmake related warnings…

[cmake] CMake Warning (dev) at CMakeLists.txt:14 (add_executable):
[cmake]   Policy CMP0063 is not set: Honor visibility properties for all target
[cmake]   types.  Run "cmake --help-policy CMP0063" for policy details.  Use the
[cmake]   cmake_policy command to set the policy and suppress this warning.
[cmake] 
[cmake]   Target "VST" of type "EXECUTABLE" has the following visibility properties
[cmake]   set for CXX:
[cmake] 
[cmake]     CXX_VISIBILITY_PRESET
[cmake]     VISIBILITY_INLINES_HIDDEN
[cmake] 
[cmake]   For compatibility CMake is not honoring them for this target.
[cmake] This warning is for project developers.  Use -Wno-dev to suppress it.

although i can still build a standard executable from the project?

UPDATE: just looked into the strange cmake error and realised i was using an older version, this seemed to resolve itself when changing the minimum required version to 3.15.

still would love some clarification on the other stuff above if anyone knows!

Do you want to build a plug-in or a host application?
for plug-in you could use the VST 3 Project Generator - VST 3 Developer Portal (steinbergmedia.github.io).
For hosting you could have a look at the example like audiohost or EditorHost Application - VST 3 Developer Portal (steinbergmedia.github.io).

thanks, i have inspected the audio and editor host cmake files but unfortunately can’t quite make sense of it when trying to combine it with the above cmakelists.text

edit: i’d like to be able to make both but creating projects from scratch and just including the sdk in my projects via cmake

Did you check this tutorial?
Creating a cmake plug-in project from scratch - VST 3 Developer Portal (steinbergmedia.github.io)

yes i did, so when i tried following the tutorial i would get some errors:

[build] Bundle does not export the required 'GetPluginFactory' function

i believe this is probably to do with the smtg_add_vst3plugin() cmake function? as thats for making vst3 plugins rather than hosts?

i’d like to be able to build plugins which can act as either standalone or vst3 so with that in mind i guess i’m trying to build both vst3 and a standard executable/application bundle(?)

my cmake:

cmake_minimum_required(VERSION 3.15.0)

project( MyPluginHostPlugin
  VERSION 1.0.0
  DESCRIPTION "A plugin host which can be run either as standalone or as a plugin")

set(vst3sdk_SOURCE_DIR
  "/Users/jaketyler/Documents/CXX Development/Frameworks/VSTSDK/vst3sdk")

add_subdirectory(
  ${vst3sdk_SOURCE_DIR} ${PROJECT_BINARY_DIR}/vst3sdk)

smtg_enable_vst3_sdk()

smtg_add_vst3plugin( MyPluginHostPlugin
  source/main.cpp)

smtg_target_set_bundle( MyPluginHostPlugin
  BUNDLE_IDENTIFIER "org.mycompany.MyPluginHostPlugin"
  COMPANY_NAME "MyCompany")

smtg_target_set_debug_executable( MyPluginHostPlugin
  "/Applications/VST3PluginTestHost.app"
  "--pluginfolder;$(BUILT_PRODUCTS_DIR)")

target_link_libraries( MyPluginHostPlugin
  PRIVATE
    sdk)

smtg_target_configure_version_file( MyPluginHostPlugin)

also for reference, my main.cpp doesn’t even include any public.sdk headers yet and is just a simple iostream hello world test:

#include <iostream>
int main()
{
  std::cout << "Hello PluginHostPlugin Example" << std::endl;
  return 0;
}

not sure if its worth sharing this either but heres the console output when i get the build error:

[build] Starting build
[proc] Executing command: /usr/local/bin/cmake --build "/Users/jaketyler/Documents/CXX Development/VST3 projects/cmakeFromScratch/build" --config Debug --target all --
[build] [1/2  50% :: 0.918] Building CXX object CMakeFiles/MyPluginHostPlugin.dir/source/main.cpp.o
[build] [2/2 100% :: 1.024] Linking CXX CFBundle shared module VST3/Debug/MyPluginHostPlugin.vst3/Contents/MacOS/MyPluginHostPlugin
[build] FAILED: VST3/Debug/MyPluginHostPlugin.vst3/Contents/MacOS/MyPluginHostPlugin 
[build] : && /usr/bin/clang++ -stdlib=libc++ -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -mmacosx-version-min=10.15 -bundle -Wl,-headerpad_max_install_names  -o VST3/Debug/MyPluginHostPlugin.vst3/Contents/MacOS/MyPluginHostPlugin CMakeFiles/MyPluginHostPlugin.dir/source/main.cpp.o CMakeFiles/MyPluginHostPlugin.dir/Users/jaketyler/Documents/CXX_Development/Frameworks/VSTSDK/vst3sdk/public.sdk/source/main/macmain.cpp.o  -lc++  -framework CoreFoundation  lib/Debug/libsdk.a  lib/Debug/libsdk_common.a  lib/Debug/libbase.a  lib/Debug/libpluginterfaces.a  -lc++ && cd "/Users/jaketyler/Documents/CXX Development/VST3 projects/cmakeFromScratch/build/bin/Debug" && "/Users/jaketyler/Documents/CXX Development/VST3 projects/cmakeFromScratch/build/bin/Debug/moduleinfotool" -create -version 1.0.0 -path /Users/jaketyler/Documents/CXX\ Development/VST3\ projects/cmakeFromScratch/build/VST3/Debug/MyPluginHostPlugin.vst3 -output /Users/jaketyler/Documents/CXX\ Development/VST3\ projects/cmakeFromScratch/build/VST3/Debug/MyPluginHostPlugin.vst3/Contents/moduleinfo.json && cd "/Users/jaketyler/Documents/CXX Development/VST3 projects/cmakeFromScratch/build/bin/Debug" && codesign -f -s - -v /Users/jaketyler/Documents/CXX\ Development/VST3\ projects/cmakeFromScratch/build/VST3/Debug/MyPluginHostPlugin.vst3/Contents/moduleinfo.json && cd "/Users/jaketyler/Documents/CXX Development/VST3 projects/cmakeFromScratch/build/bin/Debug" && "/Users/jaketyler/Documents/CXX Development/VST3 projects/cmakeFromScratch/build/bin/Debug/validator" /Users/jaketyler/Documents/CXX\ Development/VST3\ projects/cmakeFromScratch/build/VST3/Debug/MyPluginHostPlugin.vst3  && cd "/Users/jaketyler/Documents/CXX Development/VST3 projects/cmakeFromScratch/build" && mkdir -p /Users/jaketyler/Library/Audio/Plug-Ins/VST3 && ln -svfF /Users/jaketyler/Documents/CXX\ Development/VST3\ projects/cmakeFromScratch/build/VST3/Debug/MyPluginHostPlugin.vst3 /Users/jaketyler/Library/Audio/Plug-Ins/VST3
[build] Bundle does not export the required 'GetPluginFactory' function
[build] ninja: build stopped: subcommand failed.
[proc] The command: /usr/local/bin/cmake --build "/Users/jaketyler/Documents/CXX Development/VST3 projects/cmakeFromScratch/build" --config Debug --target all -- exited with code: 1 and signal: null
[build] Build finished with exit code 1

Ok, I understand. The best is to build 2 different artifacts (if you want to be cross-platform):

  • one for the VST3 plug-in.
  • one for an application (with your main.cpp), which will load your plug-in.

On macOS it is possible to build an AUv3 version of your plug-in which includes directly a AudioEngine (Standalone): check example AudioUnit v3 Wrapper - VST 3 Developer Portal (steinbergmedia.github.io)

i removed my previous posts as i didn’t want to get myself too off track on what i’m trying to achieve. so right now i’ve been able to modify the editor host example and its cmake to for my own use:

cmake_minimum_required(VERSION 3.15.0)

project(MyHost VERSION 1.0.0)

set(vst3sdk_SOURCE_DIR "/Users/jaketyler/Documents/CXX Development/Frameworks/VSTSDK/vst3sdk")
add_subdirectory(${vst3sdk_SOURCE_DIR} "${PROJECT_BINARY_DIR}/vst3sdk")
smtg_enable_vst3_sdk()

if(SMTG_MAC)
  set(platform_source
    ${vst3sdk_SOURCE_DIR}/public.sdk/source/vst/hosting/module_mac.mm)
  set_source_files_properties(
    ${vst3sdk_SOURCE_DIR}/public.sdk/source/vst/hosting/module_mac.mm PROPERTIES
    COMPILE_FLAGS "-fobjc-arc")
  set(platform_libs "-framework Cocoa")
  get_filename_component(InfoPlistFile "mac/Info.plist" ABSOLUTE)
  set(MAC_BUNDLE_PROPERTIES
    MACOSX_BUNDLE TRUE
    MACOSX_BUNDLE_INFO_PLIST ${InfoPlistFile})
endif(SMTG_MAC)

set(sdk_host_source
  ${vst3sdk_SOURCE_DIR}/public.sdk/source/vst/hosting/plugprovider.cpp
  ${vst3sdk_SOURCE_DIR}/public.sdk/source/vst/hosting/plugprovider.h)

set(vst3sdk_libs
  sdk
  sdk_hosting)

set(target ${PROJECT_NAME})

set(project_source
  source/main.cpp)

add_executable( ${target}
  ${project_source}
  ${sdk_host_source}
  ${platform_source})

target_link_libraries (${target}
  PRIVATE
    ${vst3sdk_libs}
    ${platform_libs})

smtg_target_setup_universal_binary( ${target})

if(MAC_BUNDLE_PROPERTIES)
  set_target_properties( ${target}
    PROPERTIES ${MAC_BUNDLE_PROPERTIES})
endif(MAC_BUNDLE_PROPERTIES)

with this i am able to run some simple code in my main.cpp which loads an instance of a vst, prints out some info to the console such as factory stuff and params with their IDs and then closes.

i’ve also stripped it back to just a main, and gotten rid of the platform subfolder in my source as i’d like to explore my own windowing functionality and platform stuff myself (not sure if this will be an issue long term? usediids.cpp?)

currently my issue is when i build this, i am unable to open the application bundle as it says You can’t open the application “MyHost” because it may be damaged or incomplete. i haven’t modified the info.plist that comes with the example and am wondering if its to do with this? also a little unsure on how application bundles work in general?

to be fair, i’m looking at the investigator host sample now and think this might be more what i’m looking for? or at least a combination between the editor and inspector hosts

UPDATE: after looking at the inspector host example it seems like its not that much different from the editor host - the difference being is it uses more of the vst gui stuff and the ui descriptions(?)

i’ve noticed a common trait among the examples and am hoping for some clarification, in the inspector cmake example:

    set(${target}_sources
        "source/app.cpp"
        "source/window.cpp"
        "source/window.h"
        "${SDK_ROOT}/pluginterfaces/base/coreiids.cpp"
        "${SDK_ROOT}/public.sdk/source/vst/hosting/module.h"
        "${SDK_ROOT}/public.sdk/source/vst/hosting/module.cpp"
        "${SDK_ROOT}/public.sdk/source/vst/utility/stringconvert.h"
        "${SDK_ROOT}/public.sdk/source/vst/utility/stringconvert.cpp"
        "${SDK_ROOT}/public.sdk/source/vst/moduleinfo/moduleinfoparser.cpp"
        "${SDK_ROOT}/public.sdk/source/vst/moduleinfo/moduleinfocreator.cpp"
    )

i’m a bit confused why we have to include public.sdk source files (both headers and cpp) in our build target? whether it be for this example or the editor host example?

if i understand correctly, i thought these would end up being object files and included in stuff like the sdk and sdk_hosting libraries which we include in our project via:

target_link_libraries(${target}
PRIVATE sdk sdk_hosting) 

and then just include the headers in our actual source files?