

find_program(NPM_COMMAND npm)


if(CMAKE_BUILD_TYPE MATCHES Debug)
    set(BUILD_REACT "echo")
    set(BUILD_REACT_ARGS Skipping react debug build)
else()
    set(BUILD_REACT npm)
    set(BUILD_REACT_ARGS run build)
endif()

set(BUILD_DIRECTORY ${PROJECT_SOURCE_DIR}/vite/dist)


add_custom_command(
    OUTPUT ${BUILD_DIRECTORY}/index.html
    COMMAND ${BUILD_REACT}
    ARGS ${BUILD_REACT_ARGS}
    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/vite

    DEPENDS
        # find public src *.json *.ts  -type f >/tmp/tmp.txt                    
    public/css/modGui.css
    public/css/roboto.css
    public/html/t3k_response.html
    public/var/current_pedalboard.json
    public/var/uiplugins.json
    public/var/plugin_classes.json
    public/testTone300Popup.html
    public/licenses/t3k_license.html
    public/favicon.ico
    public/iso_codes.json
    public/serve.json
    public/t3k/handleTone3000download.html
    public/img/fx_oscillator.svg
    public/img/ic_presets_white.svg
    public/img/BlackKnob.png
    public/img/audio-output.png
    public/img/nd.svg
    public/img/delete_outline_black_24dp.svg
    public/img/fx_split_a.svg
    public/img/edit_banks.svg
    public/img/fx_analyzer.svg
    public/img/PiPedal20Thumb.jpg
    public/img/fx_spectral.svg
    public/img/fx_pitch.svg
    public/img/ic_presets.svg
    public/img/cx_stereo.svg
    public/img/fx_mixer.svg
    public/img/sa.svg
    public/img/ic_navigate_next.svg
    public/img/fx_converter.svg
    public/img/fx_phaser.svg
    public/img/fx_chorus.svg
    public/img/fx_modulator.svg
    public/img/audio-input.png
    public/img/fx_constant.svg
    public/img/ic_navigate_before.svg
    public/img/nc.svg
    public/img/fx_simulator.svg
    public/img/missing_thumbnail.jpg
    public/img/fx_gate.svg
    public/img/fx_plugin.svg
    public/img/fx_distortion.svg
    public/img/fx_filter.svg
    public/img/Pi-Logo-3.svg
    public/img/by.svg
    public/img/fx_utility.svg
    public/img/Pi-Logo-3.png
    public/img/fx_compressor.svg
    public/img/old_delete_outline_black_24dp.svg
    public/img/red-light-on.png
    public/img/ic_logo.svg
    public/img/fx_function.svg
    public/img/fx_generator.svg
    public/img/fx_error.svg
    public/img/old_delete_outline_white_24dp.svg
    public/img/cc0.svg
    public/img/footswitch_strip.png
    public/img/fx_flanger.svg
    public/img/fx_filter_hp.svg
    public/img/default_album.jpg
    public/img/cc.svg
    public/img/fx_reverb.svg
    public/img/fx_delay.svg
    public/img/ic_drawer_2.svg
    public/img/edit_banks_white.svg
    public/img/fx_split_b.svg
    public/img/settings_black_24dp.svg
    public/img/fx_instrument.svg
    public/img/fx_terminal.svg
    public/img/settings_white_24dp.svg
    public/img/fx_dial.svg
    public/img/fx_lr.svg
    public/img/fx_parametric_eq.svg
    public/img/cx_mono.svg
    public/img/fx_limiter.svg
    public/img/cc-by.png
    public/img/ic_bank.svg
    public/img/vst.svg
    public/img/fx_flanger2.svg
    public/img/ic_drawer.svg
    public/img/vst.png
    public/img/red-light-off.png
    public/img/fx_eq.svg
    public/img/fx_spatial.svg
    public/img/fx_multiband_eq.svg
    public/img/fx_amplifier.svg
    public/img/fx_empty.svg
    public/img/ic_drawer_2.png
    public/manifest.json
    public/robots.txt
    public/logo512.png
    public/testTone300Select.html
    public/fonts/Roboto-Thin.woff2
    public/fonts/epf/epf_lul-webfont.woff
    public/fonts/epf/stylesheet.css
    public/fonts/Roboto-Black.woff2
    public/fonts/Roboto-Regular.woff2
    public/fonts/cooper/cooperhewitt-light-webfont.woff2
    public/fonts/cooper/cooperhewitt-bookitalic-webfont.woff2
    public/fonts/cooper/cooperhewitt-semibold-webfont.woff2
    public/fonts/cooper/cooperhewitt-lightitalic-webfont.woff2
    public/fonts/cooper/cooperhewitt-book-webfont.woff2
    public/fonts/LICENSE.txt
    public/fonts/Roboto-Italic.woff2
    public/fonts/nexa/Nexa_Free_Bold-webfont.woff
    public/fonts/nexa/stylesheet.css
    public/fonts/comforta/Comfortaa-Bold.ttf
    public/fonts/comforta/Comfortaa-Regular.ttf
    public/fonts/comforta/Comfortaa-Light.ttf
    public/fonts/pirulen/pirulen_rg-webfont.woff
    public/fonts/pirulen/stylesheet.css
    public/fonts/Roboto-BoldItalic.woff2
    public/fonts/Roboto-Bold.woff2
    public/fonts/Roboto-MediumItalic.woff2
    public/fonts/Roboto-BlackItalic.woff2
    public/fonts/Roboto-Medium.woff2
    public/fonts/Roboto-LightItalic.woff2
    public/fonts/Roboto-ThinItalic.woff2
    public/fonts/england-hand/england-webfont.woff
    public/fonts/england-hand/stylesheet.css
    public/fonts/Roboto-Light.woff2
    public/fonts/questrial/questrial-regular-webfont.woff
    public/fonts/questrial/stylesheet.css
    public/logo192.png
    public/sample_lv2_plugins.json
    src/pipedal/Tone3000DownloadType.tsx
    src/pipedal/SplitUiControls.tsx
    src/pipedal/ScreenOrientation.tsx
    src/pipedal/FilePropertyDialog.tsx
    src/pipedal/SplitControlView.tsx
    src/pipedal/WithStyles.tsx
    src/pipedal/react-app-env.d.ts
    src/pipedal/Banks.tsx
    src/pipedal/ToobPlayerControl.tsx
    src/pipedal/LinkEx.tsx
    src/pipedal/ControlTooltip.tsx
    src/pipedal/StringBuilder.tsx
    src/pipedal/LoopDialog.tsx
    src/pipedal/WifiConfigSettings.tsx
    src/pipedal/XxxSnippet.tsx
    src/pipedal/SnapshotPropertiesDialog.tsx
    src/pipedal/WifiChannel.tsx
    src/pipedal/MaterialColors.tsx
    src/pipedal/AutoZoom.tsx
    src/pipedal/SelectMidiChannelsDialog.tsx
    src/pipedal/GovernorSettings.tsx
    src/pipedal/PluginInfoDialog.tsx
    src/pipedal/AndroidHost.tsx
    src/pipedal/JackServerSettings.tsx
    src/pipedal/ChannelBindingsHelpDialog.tsx
    src/pipedal/UploadPresetDialog.tsx
    src/pipedal/GxTunerControl.tsx
    src/pipedal/ButtonEx.tsx
    src/pipedal/ImportPresetFromBankDialog.tsx
    src/pipedal/PluginControlView.tsx
    src/pipedal/AlsaMidiDeviceInfo.tsx
    src/pipedal/ControlSlider.tsx
    src/pipedal/ModFileTypes.tsx
    src/pipedal/MidiBinding.tsx
    src/pipedal/PedalboardView.tsx
    src/pipedal/ChannelRouterSettingsHelpDialog.tsx
    src/pipedal/AlsaDeviceInfo.tsx
    src/pipedal/OkCancelDialog.tsx
    src/pipedal/PerformanceView.tsx
    src/pipedal/PresetDialog.tsx
    src/pipedal/PluginPreset.tsx
    src/pipedal/SavePresetAsDialog.tsx
    src/pipedal/SystemMidiBindingsDialog.tsx
    src/pipedal/SelectChannelsDialog.tsx
    src/pipedal/PluginNameDialog.tsx
    src/pipedal/PluginIcon.tsx
    src/pipedal/FilePropertyDirectoryTree.tsx
    src/pipedal/SnapshotButton.tsx
    src/pipedal/WifiDirectConfigSettings.tsx
    src/pipedal/PluginPresetSelector.tsx
    src/pipedal/Jack.tsx
    src/pipedal/ToobMLView.tsx
    src/pipedal/ModGuiHost.tsx
    src/pipedal/SearchFilter.tsx
    src/pipedal/ToobPowerStage2View.tsx
    src/pipedal/ControlViewFactory.tsx
    src/pipedal/App.tsx
    src/pipedal/Rectangle.tsx
    src/pipedal/Rect.tsx
    src/pipedal/OldDeleteIcon.tsx
    src/pipedal/Tone3000Dialog.tsx
    src/pipedal/SnapshotColors.tsx
    src/pipedal/IControlViewFactory.tsx
    src/pipedal/VirtualKeyboardHandler.tsx
    src/pipedal/TextInfoDialog.css
    src/pipedal/FilePropertyDirectorySelectDialog.tsx
    src/pipedal/SnapshotDialog.tsx
    src/pipedal/Pedal.tsx
    src/pipedal/CopyPresetsToBankDialog.tsx
    src/pipedal/ToolTipEx.tsx
    src/pipedal/ToobSpectrumAnalyzerView.tsx
    src/pipedal/JackStatusView.tsx
    src/pipedal/Utility.tsx
    src/pipedal/WindowScale.tsx
    src/pipedal/NumericInput.tsx
    src/pipedal/UploadFileDialog.tsx
    src/pipedal/GxTunerView.tsx
    src/pipedal/GraphicEqCtl.tsx
    src/pipedal/ToobSpectrumResponseView.tsx
    src/pipedal/OptionsDialog.tsx
    src/pipedal/SelectHoverBackground.tsx
    src/pipedal/PluginControl.tsx
    src/pipedal/MidiBindingView.tsx
    src/pipedal/ToobParametricEqView.tsx
    src/pipedal/RenameDialog.tsx
    src/pipedal/IconTest.tsx
    src/pipedal/PiPedalSocket.tsx
    src/pipedal/WifiDirectConfigDialog.tsx
    src/pipedal/ToobInputStageView.tsx
    src/pipedal/RadioSelectDialog.tsx
    src/pipedal/Tone3000Downloader.tsx.bak
    src/pipedal/ChannelRouterUiControl.tsx
    src/pipedal/SafeFilename.tsx
    src/pipedal/ToobNamView.tsx
    src/pipedal/t3k/config.ts
    src/pipedal/t3k/types.ts
    src/pipedal/t3k/tone3000-client.ts
    src/pipedal/MidiChannelBindingDialog.tsx
    src/pipedal/Tone3000DownloadProgress.tsx
    src/pipedal/ChannelRouterSettingsDialog.tsx
    src/pipedal/DraggableGrid.tsx
    src/pipedal/Tone3000AuthComplete.tsx
    src/pipedal/OkDialog.tsx
    src/pipedal/ChannelRouterSettings.tsx
    src/pipedal/SystemMidiBindingView.tsx
    src/pipedal/ObservableEvent.tsx
    src/pipedal/FilePropertyControl.tsx
    src/pipedal/ZoomedUiControl.tsx
    src/pipedal/IconButtonEx.tsx
    src/pipedal/FullScreenIME.tsx
    src/pipedal/ButtonTooltip.tsx
    src/pipedal/ResizeResponsiveComponent.tsx
    src/pipedal/DialogEx.tsx
    src/pipedal/UseWindowSize.tsx
    src/pipedal/SnapshotPanel.tsx
    src/pipedal/ToobPlayerView.tsx
    src/pipedal/PresetSelector.tsx
    src/pipedal/logo.svg
    src/pipedal/ToobCabSimView.tsx
    src/pipedal/SettingsDialog.tsx
    src/pipedal/MidiChannelBinding.tsx
    src/pipedal/AlsaSequencer.tsx
    src/pipedal/ModGuiErrorBoundary.tsx
    src/pipedal/DarkMode.tsx
    src/pipedal/Tone3000HelpDialog.tsx
    src/pipedal/SearchControl.tsx
    src/pipedal/FileUtils.tsx
    src/pipedal/JackHostStatus.tsx
    src/pipedal/Units.tsx
    src/pipedal/ToobWaveShapeView.tsx
    src/pipedal/PiPedalModel.tsx
    src/pipedal/LoadPluginDialog.tsx
    src/pipedal/FontTest.tsx
    src/pipedal/GuitarMlHelpDialog.tsx
    src/pipedal/SvgPathBuilder.tsx
    src/pipedal/ZoomedDial.tsx
    src/pipedal/NoChangePassword.tsx
    src/pipedal/SideChainSelectControl.tsx
    src/pipedal/Timebase.tsx
    src/pipedal/AboutDialog.tsx
    src/pipedal/AudioFileMetadata.tsx
    src/pipedal/TemporaryDrawer.tsx
    src/pipedal/TimebaseselectorDialog.tsx
    src/pipedal/IconColorDropdownButton.tsx
    src/pipedal/PluginOutputControl.tsx
    src/pipedal/PluginPresetsDialog.tsx
    src/pipedal/AudioDeviceDialog.tsx
    src/pipedal/TextInfo_RewriteT3kUrls.ts
    src/pipedal/MidiBindingsDialog.tsx
    src/pipedal/DialogStack.tsx
    src/pipedal/SnapshotEditor.tsx
    src/pipedal/TextInfoDialog.tsx
    src/pipedal/Draggable.tsx
    src/pipedal/ColorDropdownButton.tsx
    src/pipedal/SelectScreenOrientationDialog.tsx
    src/pipedal/BankDialog.tsx
    src/pipedal/PluginClass.tsx
    src/pipedal/Pedalboard.tsx
    src/pipedal/ToobToneStackView.tsx
    src/pipedal/PiPedalError.tsx
    src/pipedal/Tone3000Downloader.tsx
    src/pipedal/ScratchClass.tsx
    src/pipedal/svg/fx_oscillator.svg
    src/pipedal/svg/snapshot_0.svg
    src/pipedal/svg/ic_help_outline.svg
    src/pipedal/svg/fx_split_a.svg
    src/pipedal/svg/fx_analyzer.svg
    src/pipedal/svg/fx_spectral.svg
    src/pipedal/svg/fx_pitch.svg
    src/pipedal/svg/ic_presets.svg
    src/pipedal/svg/fx_mixer.svg
    src/pipedal/svg/file_download_black_24dp.svg
    src/pipedal/svg/fx_converter.svg
    src/pipedal/svg/fx_phaser.svg
    src/pipedal/svg/fx_chorus.svg
    src/pipedal/svg/snapshot_6.svg
    src/pipedal/svg/fx_modulator.svg
    src/pipedal/svg/pp_ui.svg
    src/pipedal/svg/fx_constant.svg
    src/pipedal/svg/ic_save_bank_as.svg
    src/pipedal/svg/fx_simulator.svg
    src/pipedal/svg/fx_gate.svg
    src/pipedal/svg/fx_plugin.svg
    src/pipedal/svg/fx_distortion.svg
    src/pipedal/svg/fx_filter.svg
    src/pipedal/svg/ic_sidechain_open_48.svg
    src/pipedal/svg/fx_utility.svg
    src/pipedal/svg/fx_nam.svg
    src/pipedal/svg/fx_compressor.svg
    src/pipedal/svg/fx_function.svg
    src/pipedal/svg/fx_generator.svg
    src/pipedal/svg/fx_error.svg
    src/pipedal/svg/file_upload_black_24dp.svg
    src/pipedal/svg/snapshot_5.svg
    src/pipedal/svg/fx_flanger.svg
    src/pipedal/svg/snapshot_1.svg
    src/pipedal/svg/fx_filter_hp.svg
    src/pipedal/svg/fx_reverb.svg
    src/pipedal/svg/fx_delay.svg
    src/pipedal/svg/drive_file_rename_outline_black_24dp.svg
    src/pipedal/svg/fx_split_b.svg
    src/pipedal/svg/old_delete_outline_24dp.svg
    src/pipedal/svg/fx_instrument.svg
    src/pipedal/svg/ic_pluginpreset.svg
    src/pipedal/svg/fx_terminal.svg
    src/pipedal/svg/fx_dial.svg
    src/pipedal/svg/fx_lr.svg
    src/pipedal/svg/fx_parametric_eq.svg
    src/pipedal/svg/ic_midi.svg
    src/pipedal/svg/fx_limiter.svg
    src/pipedal/svg/ic_settings.svg
    src/pipedal/svg/snapshot_2.svg
    src/pipedal/svg/snapshot_3.svg
    src/pipedal/svg/expand_circle_up_24dp.svg
    src/pipedal/svg/ic_pluginpreset2.svg
    src/pipedal/svg/ic_bank.svg
    src/pipedal/svg/fx_flanger2.svg
    src/pipedal/svg/snapshot_4.svg
    src/pipedal/svg/ic_edit_banks.svg
    src/pipedal/svg/fx_eq.svg
    src/pipedal/svg/fx_spatial.svg
    src/pipedal/svg/fx_multiband_eq.svg
    src/pipedal/svg/fx_amplifier.svg
    src/pipedal/svg/mod_ui.svg
    src/pipedal/svg/expand_circle_down_24dp.svg
    src/pipedal/svg/fx_empty.svg
    src/pipedal/JsonAtom.tsx
    src/pipedal/AppThemed.css
    src/pipedal/ToobFrequencyResponseView.tsx
    src/pipedal/AppThemed.tsx
    src/pipedal/MainPage.tsx
    src/pipedal/Lv2Plugin.tsx
    src/pipedal/DraggableButtonBase.tsx
    src/pipedal/WifiConfigDialog.tsx
    src/pipedal/MidiChannelBindingControl.tsx
    src/pipedal/TextFieldEx.tsx
    src/pipedal/SelectThemeDialog.tsx
    src/pipedal/ObservableProperty.tsx
    src/pipedal/UpdateDialog.tsx
    src/pipedal/Updater.tsx
    src/pipedal/VuMeter.tsx
    src/assets/react.svg
    src/t3k_response.tsx
    src/vite-env.d.ts
    src/main.tsx
    src/index.css
    package.json
    package-lock.json
    tsconfig.app.json
    tsconfig.json
    tsconfig.node.json
    vite.config.ts

)

message(STATUS "VITE TARGET: ${BUILD_DIRECTORY}/index.html")

add_custom_target(
    ReactBuild ALL
    DEPENDS ${BUILD_DIRECTORY}/index.html
)
