# Guard keeps the repository configuring if this folder is ever emptied.
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Source/PluginProcessor.cpp)
juce_add_plugin(Strip
    VERSION                     1.0.1
    PRODUCT_NAME                "Strip"
    COMPANY_NAME                "e-thomsen"
    BUNDLE_ID                   "dk.e-thomsen.strip"
    PLUGIN_MANUFACTURER_CODE    Etho
    PLUGIN_CODE                 Strp
    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(Strip PRIVATE Source/PluginProcessor.cpp Source/PluginEditor.cpp Source/Views.cpp Source/MixView.cpp)
et_configure_plugin(Strip)
endif()

if(ET_BUILD_TESTS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_strip.cpp)
    # offline DSP checks; the vocal starting chain is checked on Vocal Chain's synthetic singer (read only)
    add_executable(test_strip tests/test_strip.cpp)
    target_include_directories(test_strip PRIVATE Source/DSP tests ${CMAKE_SOURCE_DIR}/Common/DSP ${CMAKE_SOURCE_DIR}/VocalChain/tests)
endif()

if(ET_BUILD_TESTS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/tests/render_view.cpp)
    # the real processor and editor fed a mix; renders the window for screenshot.png and checks the freeze
    juce_add_console_app(test_strip_view PRODUCT_NAME "test_strip_view")
    target_sources(test_strip_view PRIVATE tests/render_view.cpp Source/PluginProcessor.cpp Source/PluginEditor.cpp Source/Views.cpp Source/MixView.cpp)
    target_include_directories(test_strip_view PRIVATE Source tests ${CMAKE_SOURCE_DIR}/Common ${CMAKE_SOURCE_DIR}/Common/DSP ${CMAKE_SOURCE_DIR}/VocalChain/tests)
    target_compile_definitions(test_strip_view PRIVATE JUCE_WEB_BROWSER=0 JUCE_USE_CURL=0 JUCE_MODAL_LOOPS_PERMITTED=1
                               "JucePlugin_Name=\"Strip\"")
    target_link_libraries(test_strip_view PRIVATE juce::juce_audio_utils et_common_assets juce::juce_dsp juce::juce_recommended_config_flags juce::juce_recommended_warning_flags)

    # golden-style renders of the processor itself (a later version against an earlier one)
    juce_add_console_app(test_strip_golden PRODUCT_NAME "test_strip_golden")
    target_sources(test_strip_golden PRIVATE tests/strip_golden.cpp Source/PluginProcessor.cpp Source/PluginEditor.cpp Source/Views.cpp Source/MixView.cpp)
    target_include_directories(test_strip_golden PRIVATE Source tests ${CMAKE_SOURCE_DIR}/Common ${CMAKE_SOURCE_DIR}/Common/DSP ${CMAKE_SOURCE_DIR}/VocalChain/tests)
    target_compile_definitions(test_strip_golden PRIVATE JUCE_WEB_BROWSER=0 JUCE_USE_CURL=0 JUCE_MODAL_LOOPS_PERMITTED=1 "JucePlugin_Name=\"Strip\"")
    target_link_libraries(test_strip_golden PRIVATE juce::juce_audio_utils et_common_assets juce::juce_dsp juce::juce_recommended_config_flags juce::juce_recommended_warning_flags)
endif()

if(ET_BUILD_TESTS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_strip_session.cpp)
    # the session layer (0.2.0) with real processors in one process: registry, UNMASK, kick ducking,
    # BALANCE, steps, CPU
    juce_add_console_app(test_strip_session PRODUCT_NAME "test_strip_session")
    target_sources(test_strip_session PRIVATE tests/test_strip_session.cpp Source/PluginProcessor.cpp Source/PluginEditor.cpp Source/Views.cpp Source/MixView.cpp)
    target_include_directories(test_strip_session PRIVATE Source tests ${CMAKE_SOURCE_DIR}/Common ${CMAKE_SOURCE_DIR}/Common/DSP ${CMAKE_SOURCE_DIR}/VocalChain/tests)
    target_compile_definitions(test_strip_session PRIVATE JUCE_WEB_BROWSER=0 JUCE_USE_CURL=0 JUCE_MODAL_LOOPS_PERMITTED=1 "JucePlugin_Name=\"Strip\"" "JucePlugin_VersionString=\"0.2.0\"")
    target_link_libraries(test_strip_session PRIVATE juce::juce_audio_utils et_common_assets juce::juce_dsp juce::juce_recommended_config_flags juce::juce_recommended_warning_flags)
endif()

if(ET_BUILD_TESTS AND NOT APPLE AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_strip_crossbinary.cpp)
    # the registry across binaries: the built Strip VST3 hosted twice from one module and once from a copy
    juce_add_console_app(test_strip_crossbinary PRODUCT_NAME "test_strip_crossbinary")
    target_sources(test_strip_crossbinary PRIVATE tests/test_strip_crossbinary.cpp)
    target_include_directories(test_strip_crossbinary PRIVATE ${CMAKE_SOURCE_DIR}/Common/DSP)
    target_compile_definitions(test_strip_crossbinary PRIVATE JUCE_PLUGINHOST_VST3=1 JUCE_WEB_BROWSER=0 JUCE_USE_CURL=0 JUCE_MODAL_LOOPS_PERMITTED=1)
    target_link_libraries(test_strip_crossbinary PRIVATE juce::juce_audio_utils juce::juce_recommended_config_flags juce::juce_recommended_warning_flags ${CMAKE_DL_LIBS})
endif()

if(ET_BUILD_TESTS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/tests/render_session.cpp)
    # eight instances playing a song; the MIX view and the UNMASK panel rendered for the README
    juce_add_console_app(test_strip_session_view PRODUCT_NAME "test_strip_session_view")
    target_sources(test_strip_session_view PRIVATE tests/render_session.cpp Source/PluginProcessor.cpp Source/PluginEditor.cpp Source/Views.cpp Source/MixView.cpp)
    target_include_directories(test_strip_session_view PRIVATE Source tests ${CMAKE_SOURCE_DIR}/Common ${CMAKE_SOURCE_DIR}/Common/DSP ${CMAKE_SOURCE_DIR}/VocalChain/tests)
    target_compile_definitions(test_strip_session_view PRIVATE JUCE_WEB_BROWSER=0 JUCE_USE_CURL=0 JUCE_MODAL_LOOPS_PERMITTED=1 "JucePlugin_Name=\"Strip\"")
    target_link_libraries(test_strip_session_view PRIVATE juce::juce_audio_utils et_common_assets juce::juce_dsp juce::juce_recommended_config_flags juce::juce_recommended_warning_flags)
endif()
