#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <https://www.gnu.org/licenses/>.

cmake_minimum_required(VERSION 3.15)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12 CACHE STRING "Minimum OS X deployment version" FORCE)

project(CRYPT_SYNTH_PLUGIN VERSION 2.1.0)

add_subdirectory(JUCE)

juce_add_plugin(Crypt2SynthPlugin
        VERSION 2.1.0                               # Set this if the plugin version is different to the project version
        ICON_BIG ${CMAKE_CURRENT_SOURCE_DIR}/resources/crypt-icon.png                              # ICON_* arguments specify a path to an image file to use as an icon for the Standalone
        ICON_SMALL ${CMAKE_CURRENT_SOURCE_DIR}/resources/crypt-icon.png
        COMPANY_NAME Vitling                          # Specify the name of the plugin's author
        IS_SYNTH TRUE                       # Is this a synth or an effect?
        NEEDS_MIDI_INPUT TRUE               # Does the plugin need midi input?
        NEEDS_MIDI_OUTPUT FALSE              # Does the plugin need midi output?
        IS_MIDI_EFFECT FALSE                 # Is this plugin a MIDI effect?
        EDITOR_WANTS_KEYBOARD_FOCUS FALSE    # Does the editor need keyboard focus?
        COPY_PLUGIN_AFTER_BUILD TRUE        # Should the plugin be installed to a default location after building?
        PLUGIN_MANUFACTURER_CODE Vitl               # A four-character manufacturer id with at least one upper-case character
        PLUGIN_CODE Crp2                            # A unique four-character plugin id with at least one upper-case character
        DESCRIPTION "Hyper-Unison Synthesiser from Bow Church/Vitling"
        VST3_CATEGORIES "Instrument Synth Stereo"
        AU_MAIN_TYPE "kAudioUnitType_MusicDevice"
        FORMATS VST3 AU Standalone                 # The formats to build. Other valid formats are: AAX Unity VST AU AUv3
        BUNDLE_ID "xyz.vitling.plugins.crypt2"
        HARDENED_RUNTIME_ENABLED TRUE
        PRODUCT_NAME "Crypt2")        # The name of the final executable, which can differ from the target name


juce_generate_juce_header(Crypt2SynthPlugin)

target_sources(Crypt2SynthPlugin PRIVATE
        src/CryptPlugin.cpp)

target_compile_definitions(Crypt2SynthPlugin
        PUBLIC
        JUCE_WEB_BROWSER=0
        JUCE_USE_CURL=0
        JUCE_VST3_CAN_REPLACE_VST2=0

        # We don't have to display the splash screen since we're using JUCE
        # under the GPL
        JUCE_DISPLAY_SPLASH_SCREEN=0)

juce_add_binary_data(Crypt2SynthPluginData SOURCES resources/Gothica-Book.ttf resources/bg.jpg resources/presets.xml resources/keyboard-icon.png)
set_target_properties(Crypt2SynthPluginData PROPERTIES POSITION_INDEPENDENT_CODE ON)

target_link_libraries(Crypt2SynthPlugin PRIVATE
        Crypt2SynthPluginData
        juce::juce_audio_utils
        juce::juce_dsp)
        