cmake_minimum_required(VERSION 3.14.0)


set(vst3sdk_SOURCE_DIR <%%vstsdkdir%%>)
if(NOT vst3sdk_SOURCE_DIR)
    message(FATAL_ERROR "Path to VST3 SDK is empty!")
endif()

project(<%%cfxname%%>
    # This is your plug-in version number. Change it here only.
    # Version number symbols usable in C++ can be found in
    # source/version.h and ${PROJECT_BINARY_DIR}/projectversion.h.
    VERSION <%%version.major%%>.<%%version.minor%%>.<%%version.release%%>.<%%version.build%%>
    DESCRIPTION "<%%capfxname%%> VST 3 Plug-in"
)

set(SMTG_VSTGUI_ROOT "${vst3sdk_SOURCE_DIR}/vstgui4/vstgui")
add_subdirectory(${vst3sdk_SOURCE_DIR} ${PROJECT_BINARY_DIR}/vst3sdk)
smtg_enable_vst3_sdk()

smtg_add_vst3plugin(<%%cfxname%%>
    source/<%%cfxname%%>controller.cpp
    source/<%%cfxname%%>controller.h
    source/<%%cfxname%%>ids.h
    source/<%%cfxname%%>processor.cpp
    source/<%%cfxname%%>processor.h
    source/<%%cfxname%%>.h
    source/<%%cfxname%%>.c
    source/liveview.cpp
    source/liveview.h
    source/liveviewcreator.cpp
    source/dsp_common.c
    source/dsp_common.h
    source/dsp_resources_vst.cpp
    source/dsp_resources_vst.h
    source/dsp_resources.h
    source/factory.cpp
    source/version.h
    source/config.h
    source/spekdex.h
    source/presets.h
)

#- VSTGUI Wanted ----
if(SMTG_ADD_VSTGUI)
    target_sources(<%%cfxname%%>
        PRIVATE
		    ${SMTG_VSTGUI_ROOT}/vstgui_uidescription.cpp
		    ${SMTG_VSTGUI_ROOT}/plugin-bindings/vst3editor.cpp
    )
	target_include_directories(<%%cfxname%%> 
			PRIVATE 
			${SMTG_VSTGUI_ROOT})
    target_link_libraries(<%%cfxname%%>
        PRIVATE
            vstgui_support
    )
    smtg_target_add_plugin_resources(<%%cfxname%%> 
    	RESOURCES
    		"resource/<%%cfxname%%>editor.uidesc"
<%%repeat-resources%%>
			"resource/<%%resource%%>"
<%%/repeat%%>    		
    		)
    		
  	smtg_target_add_plugin_resources(<%%cfxname%%> 
    	RESOURCES
		<%%repeat-fonts%%>
					"resource/<%%resource%%>"
		<%%/repeat%%>  
		OUTPUT_SUBDIRECTORY
            "Fonts"
	)
	
    		
endif(SMTG_ADD_VSTGUI)
# -------------------

#smtg_add_vst3_snapshot(<%%cfxname%%> resource/<%%cfxname%%>_snapshot.png)
#smtg_add_vst3_snapshot(<%%cfxname%%> resource/<%%cfxname%%>_snapshot_2.0x.png)

target_link_libraries(<%%cfxname%%>
    PRIVATE
        sdk 
)

smtg_target_configure_version_file(<%%cfxname%%>)

if(SMTG_MAC)
    set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12)
    smtg_target_set_bundle<%%cfxname%%>(
        BUNDLE_IDENTIFIER "<%%bundlepack%%>.<%%cfxname%%>"
        COMPANY_NAME "<%%meta.company%%>"
    )
    smtg_target_set_debug_executable(<%%cfxname%%>
        "/Applications/VST3PluginTestHost.app"
        "--pluginfolder;$(BUILT_PRODUCTS_DIR)"
    )
elseif(SMTG_WIN)
    target_sources(<%%cfxname%%> PRIVATE 
        resource/<%%cfxname%%>.rc
    )
    if(MSVC)
        set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT <%%cfxname%%>)
    
        smtg_set_debug_executable(<%%cfxname%%>
            "$(ProgramW6432)/Steinberg/VST3PluginTestHost/VST3PluginTestHost.exe"
            "--pluginfolder \"$(OutDir)/\""
        )
    endif()
endif()

