juce_add_plugin(KickTune
    VERSION                     1.0.1
    PRODUCT_NAME                "Kick Tune"
    COMPANY_NAME                "e-thomsen"
    BUNDLE_ID                   "dk.e-thomsen.kicktune"
    PLUGIN_MANUFACTURER_CODE    Etho
    PLUGIN_CODE                 Ktun
    FORMATS                     ${ET_FORMATS}
    AU_MAIN_TYPE                kAudioUnitType_Effect
    IS_SYNTH FALSE NEEDS_MIDI_INPUT FALSE NEEDS_MIDI_OUTPUT FALSE IS_MIDI_EFFECT FALSE
    EDITOR_WANTS_KEYBOARD_FOCUS FALSE
    COPY_PLUGIN_AFTER_BUILD     TRUE)
target_sources(KickTune PRIVATE Source/PluginProcessor.cpp Source/PluginEditor.cpp)
et_configure_plugin(KickTune)

if(ET_BUILD_TESTS)
    add_executable(test_kicktune tests/test_kick.cpp)
    target_include_directories(test_kicktune PRIVATE Source/DSP ${CMAKE_SOURCE_DIR}/Common/DSP)
endif()

if(ET_BUILD_TESTS AND NOT APPLE)
    # audio-to-editor handoff under real threads, built with ThreadSanitizer: any data race fails it
    juce_add_console_app(test_kicktune_handoff PRODUCT_NAME "test_kicktune_handoff")
    target_sources(test_kicktune_handoff PRIVATE tests/test_handoff.cpp Source/PluginProcessor.cpp Source/PluginEditor.cpp)
    target_include_directories(test_kicktune_handoff PRIVATE Source ${CMAKE_SOURCE_DIR}/Common ${CMAKE_SOURCE_DIR}/Common/DSP)
    target_compile_definitions(test_kicktune_handoff PRIVATE JUCE_WEB_BROWSER=0 JUCE_USE_CURL=0 "JucePlugin_Name=\"Kick Tune\"")
    target_compile_options(test_kicktune_handoff PRIVATE -fsanitize=thread -g)
    target_link_options(test_kicktune_handoff PRIVATE -fsanitize=thread)
    target_link_libraries(test_kicktune_handoff PRIVATE juce::juce_audio_utils et_common_assets juce::juce_dsp juce::juce_recommended_config_flags)
endif()

# the real processor and editor fed synthetic signals with the transport playing; renders the window for screenshot.png
et_add_view_harness(KickTune test_kicktune_view tests/render_view.cpp)
