sudara / pamplejuce

A JUCE audio plugin template. JUCE 8, Catch2, Pluginval, macOS notarization, Azure Trusted Signing, Github Actions
https://melatonin.dev/manuals/pamplejuce
MIT License
425 stars 43 forks source link

Compiling with clang++ chokes on Objective-C #82

Closed luisldq closed 7 months ago

luisldq commented 7 months ago

Hello, thanks for the great template!

I'm able to compile and run it, but when I drag my Projucer code in and customize the CMakeLists.txt file, I get a compile error from clang++ choking on the Objective-C syntax found in the JUCE library. I'm sure I'm doing something wrong, any help is appreciated!

Error and full CMakeLists.txt file below:

====================[ Build | PluginName_Standalone | Debug ]=======================
/Applications/CMake.app/Contents/bin/cmake --build /Users/ldq/Company/pluginname-pamplejuce2/cmake-build-debug --target PluginName_Standalone -j 8
[0/2] Re-checking globbed directories...
[2/21] Building CXX object CMakeFiles/PluginName.dir/source/JuceLibraryCode/include_juce_events.cpp.o
FAILED: CMakeFiles/PluginName.dir/source/JuceLibraryCode/include_juce_events.cpp.o 
/usr/bin/clang++ -DCMAKE_BUILD_TYPE=\"Debug\" -DDEBUG=1 -DJUCE_DISPLAY_SPLASH_SCREEN=0 -DJUCE_GLOBAL_MODULE_SETTINGS_INCLUDED=1 -DJUCE_MODULE_AVAILABLE_juce_audio_basics=1 -DJUCE_MODULE_AVAILABLE_juce_audio_devices=1 -DJUCE_MODULE_AVAILABLE_juce_audio_formats=1 -DJUCE_MODULE_AVAILABLE_juce_audio_plugin_client=1 -DJUCE_MODULE_AVAILABLE_juce_audio_processors=1 -DJUCE_MODULE_AVAILABLE_juce_audio_utils=1 -DJUCE_MODULE_AVAILABLE_juce_core=1 -DJUCE_MODULE_AVAILABLE_juce_data_structures=1 -DJUCE_MODULE_AVAILABLE_juce_dsp=1 -DJUCE_MODULE_AVAILABLE_juce_events=1 -DJUCE_MODULE_AVAILABLE_juce_graphics=1 -DJUCE_MODULE_AVAILABLE_juce_gui_basics=1 -DJUCE_MODULE_AVAILABLE_juce_gui_extra=1 -DJUCE_MODULE_AVAILABLE_melatonin_inspector=1 -DJUCE_SHARED_CODE=1 -DJUCE_STANDALONE_APPLICATION=JucePlugin_Build_Standalone -DJUCE_TARGET_HAS_BINARY_DATA=1 -DJUCE_USE_CURL=0 -DJUCE_VST3_CAN_REPLACE_VST2=0 -DJUCE_WEB_BROWSER=0 -DJucePlugin_AAXCategory=0 -DJucePlugin_AAXDisableBypass=0 -DJucePlugin_AAXDisableMultiMono=0 -DJucePlugin_AAXIdentifier=com.company.pluginname -DJucePlugin_AAXManufacturerCode=JucePlugin_ManufacturerCode -DJucePlugin_AAXProductId=JucePlugin_PluginCode -DJucePlugin_ARACompatibleArchiveIDs=\"\" -DJucePlugin_ARAContentTypes=0 -DJucePlugin_ARADocumentArchiveID=\"com.company.pluginname.aradocumentarchive.1\" -DJucePlugin_ARAFactoryID=\"com.company.pluginname.arafactory.0.0.1\" -DJucePlugin_ARATransformationFlags=0 -DJucePlugin_AUExportPrefix=PluginNameAU -DJucePlugin_AUExportPrefixQuoted=\"PluginNameAU\" -DJucePlugin_AUMainType="'aufx'" -DJucePlugin_AUManufacturerCode=JucePlugin_ManufacturerCode -DJucePlugin_AUSubType=JucePlugin_PluginCode -DJucePlugin_Build_AAX=0 -DJucePlugin_Build_AU=1 -DJucePlugin_Build_AUv3=0 -DJucePlugin_Build_LV2=0 -DJucePlugin_Build_Standalone=1 -DJucePlugin_Build_Unity=0 -DJucePlugin_Build_VST3=1 -DJucePlugin_Build_VST=0 -DJucePlugin_CFBundleIdentifier=com.company.pluginname -DJucePlugin_Desc=\"PluginName\" -DJucePlugin_EditorRequiresKeyboardFocus=0 -DJucePlugin_Enable_ARA=0 -DJucePlugin_IsMidiEffect=0 -DJucePlugin_IsSynth=0 -DJucePlugin_Manufacturer=\"Company\" -DJucePlugin_ManufacturerCode=0x41646c62 -DJucePlugin_ManufacturerEmail=\"\" -DJucePlugin_ManufacturerWebsite=\"\" -DJucePlugin_Name=\"PluginName\" -DJucePlugin_PluginCode=0x54686963 -DJucePlugin_ProducesMidiOutput=0 -DJucePlugin_VSTCategory=kPlugCategEffect -DJucePlugin_VSTNumMidiInputs=16 -DJucePlugin_VSTNumMidiOutputs=16 -DJucePlugin_VSTUniqueID=JucePlugin_PluginCode -DJucePlugin_Version=0.0.1 -DJucePlugin_VersionCode=0x1 -DJucePlugin_VersionString=\"0.0.1\" -DJucePlugin_Vst3Category=\"Fx\" -DJucePlugin_WantsMidiInput=0 -DPRODUCT_NAME_WITHOUT_VERSION=\"PluginName\" -DVERSION=\"0.0.1\" -D_DEBUG=1 -I/Users/ldq/Company/pluginname-pamplejuce2/source/JuceLibraryCode -I/Users/ldq/Company/pluginname-pamplejuce2/source/API -I/Users/ldq/Company/pluginname-pamplejuce2/source/DSP -I/Users/ldq/Company/pluginname-pamplejuce2/source/GUI -I/Users/ldq/Company/pluginname-pamplejuce2/source/GUI/Components -I/Users/ldq/Company/pluginname-pamplejuce2/source/GUI/Components/Sliders -I/Users/ldq/Company/pluginname-pamplejuce2/source/GUI/Components/SVGButtons -I/Users/ldq/Company/pluginname-pamplejuce2/source/GUI/Components/Unused_Comps -I/Users/ldq/Company/pluginname-pamplejuce2/source/GUI/LookAndFeel -I/Users/ldq/Company/pluginname-pamplejuce2/source/Parameters -I/Users/ldq/Company/pluginname-pamplejuce2/source/Service -I/Users/ldq/Company/pluginname-pamplejuce2/source/Utilities -I/Users/ldq/Company/pluginname-pamplejuce2/source -I/Users/ldq/Company/pluginname-pamplejuce2/cmake-build-debug/PluginName_artefacts/JuceLibraryCode -I/Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules -I/Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_audio_processors/format_types/VST3_SDK -I/Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_audio_processors/format_types/LV2_SDK -I/Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_audio_processors/format_types/LV2_SDK/lv2 -I/Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_audio_processors/format_types/LV2_SDK/serd -I/Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_audio_processors/format_types/LV2_SDK/sord -I/Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_audio_processors/format_types/LV2_SDK/sord/src -I/Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_audio_processors/format_types/LV2_SDK/sratom -I/Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_audio_processors/format_types/LV2_SDK/lilv -I/Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_audio_processors/format_types/LV2_SDK/lilv/src -I/Users/ldq/Company/pluginname-pamplejuce2/cmake-build-debug/juce_binarydata_Assets/JuceLibraryCode -I/Users/ldq/Company/pluginname-pamplejuce2/modules -g -std=gnu++20 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk -mmacosx-version-min=10.13 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -fcolor-diagnostics -g -O0 -Wall -Wshadow-all -Wshorten-64-to-32 -Wstrict-aliasing -Wuninitialized -Wunused-parameter -Wconversion -Wsign-compare -Wint-conversion -Wconditional-uninitialized -Wconstant-conversion -Wsign-conversion -Wbool-conversion -Wextra-semi -Wunreachable-code -Wcast-align -Wshift-sign-overflow -Wmissing-prototypes -Wnullable-to-nonnull-conversion -Wno-ignored-qualifiers -Wswitch-enum -Wpedantic -Wdeprecated -Wfloat-equal -Wmissing-field-initializers -Wzero-as-null-pointer-constant -Wunused-private-field -Woverloaded-virtual -Wreorder -Winconsistent-missing-destructor-override -MD -MT CMakeFiles/PluginName.dir/source/JuceLibraryCode/include_juce_events.cpp.o -MF CMakeFiles/PluginName.dir/source/JuceLibraryCode/include_juce_events.cpp.o.d -o CMakeFiles/PluginName.dir/source/JuceLibraryCode/include_juce_events.cpp.o -c /Users/ldq/Company/pluginname-pamplejuce2/source/JuceLibraryCode/include_juce_events.cpp
In file included from /Users/ldq/Company/pluginname-pamplejuce2/source/JuceLibraryCode/include_juce_events.cpp:8:
In file included from /Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_events/juce_events.cpp:42:
In file included from /Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_events/juce_events.h:52:
In file included from /Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_core/juce_core.h:197:
/Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_core/native/juce_BasicNativeHeaders.h:48:4: warning: #import is a language extension [-Wimport-preprocessor-directive-pedantic]
  #import <Cocoa/Cocoa.h>
   ^
In file included from /Users/ldq/Company/pluginname-pamplejuce2/source/JuceLibraryCode/include_juce_events.cpp:8:
In file included from /Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_events/juce_events.cpp:42:
In file included from /Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_events/juce_events.h:52:
In file included from /Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_core/juce_core.h:197:
In file included from /Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_core/native/juce_BasicNativeHeaders.h:48:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:9:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:601:1: error: expected unqualified-id
@class NSString, Protocol;
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:603:9: error: unknown type name 'NSString'
typedef NSString * NSExceptionName NS_TYPED_EXTENSIBLE_ENUM;
        ^
1 warning and 20 errors generated.
[9/21] Building CXX object CMakeFiles/PluginName.dir/source/JuceLibraryCode/include_juce_audio_plugin_client_VST3.cpp.o
FAILED: CMakeFiles/PluginName.dir/source/JuceLibraryCode/include_juce_audio_plugin_client_VST3.cpp.o 
/usr/bin/clang++ -DCMAKE_BUILD_TYPE=\"Debug\" -DDEBUG=1 -DJUCE_DISPLAY_SPLASH_SCREEN=0 -DJUCE_GLOBAL_MODULE_SETTINGS_INCLUDED=1 -DJUCE_MODULE_AVAILABLE_juce_audio_basics=1 -DJUCE_MODULE_AVAILABLE_juce_audio_devices=1 -DJUCE_MODULE_AVAILABLE_juce_audio_formats=1 -DJUCE_MODULE_AVAILABLE_juce_audio_plugin_client=1 -DJUCE_MODULE_AVAILABLE_juce_audio_processors=1 -DJUCE_MODULE_AVAILABLE_juce_audio_utils=1 -DJUCE_MODULE_AVAILABLE_juce_core=1 -DJUCE_MODULE_AVAILABLE_juce_data_structures=1 -DJUCE_MODULE_AVAILABLE_juce_dsp=1 -DJUCE_MODULE_AVAILABLE_juce_events=1 -DJUCE_MODULE_AVAILABLE_juce_graphics=1 -DJUCE_MODULE_AVAILABLE_juce_gui_basics=1 -DJUCE_MODULE_AVAILABLE_juce_gui_extra=1 -DJUCE_MODULE_AVAILABLE_melatonin_inspector=1 -DJUCE_SHARED_CODE=1 -DJUCE_STANDALONE_APPLICATION=JucePlugin_Build_Standalone -DJUCE_TARGET_HAS_BINARY_DATA=1 -DJUCE_USE_CURL=0 -DJUCE_VST3_CAN_REPLACE_VST2=0 -DJUCE_WEB_BROWSER=0 -DJucePlugin_AAXCategory=0 -DJucePlugin_AAXDisableBypass=0 -DJucePlugin_AAXDisableMultiMono=0 -DJucePlugin_AAXIdentifier=com.company.pluginname -DJucePlugin_AAXManufacturerCode=JucePlugin_ManufacturerCode -DJucePlugin_AAXProductId=JucePlugin_PluginCode -DJucePlugin_ARACompatibleArchiveIDs=\"\" -DJucePlugin_ARAContentTypes=0 -DJucePlugin_ARADocumentArchiveID=\"com.company.pluginname.aradocumentarchive.1\" -DJucePlugin_ARAFactoryID=\"com.company.pluginname.arafactory.0.0.1\" -DJucePlugin_ARATransformationFlags=0 -DJucePlugin_AUExportPrefix=PluginNameAU -DJucePlugin_AUExportPrefixQuoted=\"PluginNameAU\" -DJucePlugin_AUMainType="'aufx'" -DJucePlugin_AUManufacturerCode=JucePlugin_ManufacturerCode -DJucePlugin_AUSubType=JucePlugin_PluginCode -DJucePlugin_Build_AAX=0 -DJucePlugin_Build_AU=1 -DJucePlugin_Build_AUv3=0 -DJucePlugin_Build_LV2=0 -DJucePlugin_Build_Standalone=1 -DJucePlugin_Build_Unity=0 -DJucePlugin_Build_VST3=1 -DJucePlugin_Build_VST=0 -DJucePlugin_CFBundleIdentifier=com.company.pluginname -DJucePlugin_Desc=\"PluginName\" -DJucePlugin_EditorRequiresKeyboardFocus=0 -DJucePlugin_Enable_ARA=0 -DJucePlugin_IsMidiEffect=0 -DJucePlugin_IsSynth=0 -DJucePlugin_Manufacturer=\"Company\" -DJucePlugin_ManufacturerCode=0x41646c62 -DJucePlugin_ManufacturerEmail=\"\" -DJucePlugin_ManufacturerWebsite=\"\" -DJucePlugin_Name=\"PluginName\" -DJucePlugin_PluginCode=0x54686963 -DJucePlugin_ProducesMidiOutput=0 -DJucePlugin_VSTCategory=kPlugCategEffect -DJucePlugin_VSTNumMidiInputs=16 -DJucePlugin_VSTNumMidiOutputs=16 -DJucePlugin_VSTUniqueID=JucePlugin_PluginCode -DJucePlugin_Version=0.0.1 -DJucePlugin_VersionCode=0x1 -DJucePlugin_VersionString=\"0.0.1\" -DJucePlugin_Vst3Category=\"Fx\" -DJucePlugin_WantsMidiInput=0 -DPRODUCT_NAME_WITHOUT_VERSION=\"PluginName\" -DVERSION=\"0.0.1\" -D_DEBUG=1 -I/Users/ldq/Company/pluginname-pamplejuce2/source/JuceLibraryCode -I/Users/ldq/Company/pluginname-pamplejuce2/source/API -I/Users/ldq/Company/pluginname-pamplejuce2/source/DSP -I/Users/ldq/Company/pluginname-pamplejuce2/source/GUI -I/Users/ldq/Company/pluginname-pamplejuce2/source/GUI/Components -I/Users/ldq/Company/pluginname-pamplejuce2/source/GUI/Components/Sliders -I/Users/ldq/Company/pluginname-pamplejuce2/source/GUI/Components/SVGButtons -I/Users/ldq/Company/pluginname-pamplejuce2/source/GUI/Components/Unused_Comps -I/Users/ldq/Company/pluginname-pamplejuce2/source/GUI/LookAndFeel -I/Users/ldq/Company/pluginname-pamplejuce2/source/Parameters -I/Users/ldq/Company/pluginname-pamplejuce2/source/Service -I/Users/ldq/Company/pluginname-pamplejuce2/source/Utilities -I/Users/ldq/Company/pluginname-pamplejuce2/source -I/Users/ldq/Company/pluginname-pamplejuce2/cmake-build-debug/PluginName_artefacts/JuceLibraryCode -I/Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules -I/Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_audio_processors/format_types/VST3_SDK -I/Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_audio_processors/format_types/LV2_SDK -I/Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_audio_processors/format_types/LV2_SDK/lv2 -I/Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_audio_processors/format_types/LV2_SDK/serd -I/Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_audio_processors/format_types/LV2_SDK/sord -I/Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_audio_processors/format_types/LV2_SDK/sord/src -I/Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_audio_processors/format_types/LV2_SDK/sratom -I/Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_audio_processors/format_types/LV2_SDK/lilv -I/Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_audio_processors/format_types/LV2_SDK/lilv/src -I/Users/ldq/Company/pluginname-pamplejuce2/cmake-build-debug/juce_binarydata_Assets/JuceLibraryCode -I/Users/ldq/Company/pluginname-pamplejuce2/modules -g -std=gnu++20 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk -mmacosx-version-min=10.13 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -fcolor-diagnostics -g -O0 -Wall -Wshadow-all -Wshorten-64-to-32 -Wstrict-aliasing -Wuninitialized -Wunused-parameter -Wconversion -Wsign-compare -Wint-conversion -Wconditional-uninitialized -Wconstant-conversion -Wsign-conversion -Wbool-conversion -Wextra-semi -Wunreachable-code -Wcast-align -Wshift-sign-overflow -Wmissing-prototypes -Wnullable-to-nonnull-conversion -Wno-ignored-qualifiers -Wswitch-enum -Wpedantic -Wdeprecated -Wfloat-equal -Wmissing-field-initializers -Wzero-as-null-pointer-constant -Wunused-private-field -Woverloaded-virtual -Wreorder -Winconsistent-missing-destructor-override -MD -MT CMakeFiles/PluginName.dir/source/JuceLibraryCode/include_juce_audio_plugin_client_VST3.cpp.o -MF CMakeFiles/PluginName.dir/source/JuceLibraryCode/include_juce_audio_plugin_client_VST3.cpp.o.d -o CMakeFiles/PluginName.dir/source/JuceLibraryCode/include_juce_audio_plugin_client_VST3.cpp.o -c /Users/ldq/Company/pluginname-pamplejuce2/source/JuceLibraryCode/include_juce_audio_plugin_client_VST3.cpp
In file included from /Users/ldq/Company/pluginname-pamplejuce2/source/JuceLibraryCode/include_juce_audio_plugin_client_VST3.cpp:8:
In file included from /Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_audio_plugin_client/juce_audio_plugin_client_VST3.cpp:51:
/Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_audio_plugin_client/detail/juce_VSTWindowUtilities.h:45:13: error: unknown type name 'NSView'
            NSView* parentView = [(NSView*) parentWindowOrView retain];
            ^
/Users/ldq/Company/pluginname-pamplejuce2/JUCE/modules/juce_audio_plugin_client/detail/juce_VSTWindowUtilities.h:45:35: error: expected variable name or 'this' in lambda capture list
            NSView* parentView = [(NSView*) parentWindowOrView retain];
                                  ^
[.....CLIPPED......]
4 warnings and 16 errors generated.
ninja: build stopped: subcommand failed.
# 3.24.1 is bundled in Visual Studio 2022 v17.4
# 3.24.1 is also bundled in CLion as of 2023
cmake_minimum_required(VERSION 3.24.1)
set(CMAKE_C_COMPILER "/usr/bin/clang")
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")

# This tells cmake we have goodies in the /cmake folder
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include (PamplejuceVersion)

# Configures universal binaries and decides which version of macOS to support
include(PamplejuceMacOS)

# Change me!
# This is the internal name of the project and the name of JUCE's shared code target
# Note: This cannot have spaces (it may be 2024, but you can't have it all!)
# Worry not, JUCE's PRODUCT_NAME can have spaces (and is what DAWs display)
set(PROJECT_NAME "PluginName")

# Worry not, JUCE's PRODUCT_NAME can have spaces (and is what DAWs will display)
# You can also just have it be the same thing as PROJECT_NAME
# You may want to append the major version on the end of this (and PROJECT_NAME) ala:
#   set(PROJECT_NAME "MyPlugin_v${MAJOR_VERSION}")
# Doing so enables major versions to show up in IDEs and DAWs as separate plugins
# allowing you to change parameters and behavior without breaking existing user projects
set(PRODUCT_NAME "PluginName")

# Change me! Used for the MacOS bundle name and Installers
set(COMPANY_NAME "company")

# Change me! Used for the MacOS bundle identifier (and signing)
set(BUNDLE_ID "com.company.pluginname")

# Change me! Set the plugin formats you want built
# Valid choices: AAX Unity VST VST3 AU AUv3 Standalone
set(FORMATS Standalone AU VST3 AUv3)

# For simplicity, the name of the CMake project is also the name of the target
project(${PROJECT_NAME} VERSION ${CURRENT_VERSION})

# Couple tweaks that IMO should be JUCE defaults
include(JUCEDefaults)

# JUCE is setup as a submodule in the /JUCE folder
# Locally, you must run `git submodule update --init --recursive` once
# and later `git submodule update --remote --merge` to keep it up to date
# On Github Actions, this is done as a part of actions/checkout
add_subdirectory(JUCE)

# Add any other modules you want modules here, before the juce_add_plugin call
# juce_add_module(JUCE/modules/juce_audio_basics)
#         juce_add_module(modules/juce_audio_devices)
#         juce_add_module(modules/juce_audio_formats)
#         juce_add_module(modules/juce_audio_plugin_client)
#         juce_add_module(modules/juce_core)
#         juce_add_module(modules/juce_data_structures)
#         juce_add_module(modules/juce_events)
#         juce_add_module(modules/juce_graphics)
#         juce_add_module(modules/juce_audio_utils)
#         juce_add_module(modules/juce_audio_processors)
#         juce_add_module(modules/juce_dsp)
#         juce_add_module(modules/juce_gui_basics)
#         juce_add_module(modules/juce_gui_extra)

# This adds the melatonin inspector module
add_subdirectory (modules/melatonin_inspector)

include_directories(source/JuceLibraryCode)
include_directories(source/API)
include_directories(source/DSP)
include_directories(source/GUI)
include_directories(source/GUI/Components)
include_directories(source/GUI/Components/Sliders)
include_directories(source/GUI/Components/SVGButtons)
include_directories(source/GUI/Components/Unused_Comps)
include_directories(source/GUI/LookAndFeel)
include_directories(source/Parameters)
include_directories(source/Service)
include_directories(source/Utilities)
include_directories(source)

# See `docs/CMake API.md` in the JUCE repo for all config options
juce_add_plugin("${PROJECT_NAME}"
    # Icons for the standalone app
    ICON_BIG "${CMAKE_CURRENT_SOURCE_DIR}/packaging/icon.png"

    # Change me!
    COMPANY_NAME "${COMPANY_NAME}"
    BUNDLE_ID "${BUNDLE_ID}"

    # On MacOS, plugin is copied to ~/Users/yourname/Library/Audio/Plug-Ins/
    COPY_PLUGIN_AFTER_BUILD TRUE

    # Change me!
    # A four-character plugin id
    # First character MUST be uppercase for AU formats
    PLUGIN_MANUFACTURER_CODE Adlb

    # Change me!
    # A unique four-character plugin id
    # Note: this must have at least one upper-case character
    PLUGIN_CODE Thic
    FORMATS "${FORMATS}"

    # The name of your final executable
    # This is how it's listed in the DAW
    # This can be different from PROJECT_NAME and can have spaces!
    # You might want to use v${MAJOR_VERSION} here once you go to v2...
    PRODUCT_NAME "${PRODUCT_NAME}")

# This lets us use our code in both the JUCE targets and our Test target
# Without running into ODR violations
add_library(SharedCode INTERFACE)

# C++20, please
# Use cxx_std_23 for C++23 (as of CMake v 3.20)
target_compile_features(SharedCode INTERFACE cxx_std_20)

# Manually list all .h and .cpp files for the plugin
# If you are like me, you'll use globs for your sanity.
# Just ensure you employ CONFIGURE_DEPENDS so the build system picks up changes
# If you want to appease the CMake gods and avoid globs, manually add files like so:
# set(SourceFiles Source/PluginEditor.h Source/PluginProcessor.h Source/PluginEditor.cpp Source/PluginProcessor.cpp)
set(SourceFiles
        source/PluginEditor.cpp
        source/PluginEditor.h
        source/PluginProcessor.cpp
        source/PluginProcessor.h
        source/GUI/DrumPadShadow.h
        source/GUI/GUIConsts.h
        source/GUI/DrumRack.h
        source/GUI/DrumPad.cpp
        source/GUI/DrumRack.cpp
        source/GUI/GUI.h
        source/GUI/DrumRackPad.h
        source/GUI/Components/UtilityMenu.h
        source/GUI/Components/PlaybackRangeOverlay.h
        source/GUI/Components/PresetManagerComponent.h
        source/GUI/Components/SafeAlertWindow.h
        source/GUI/Components/DropDown.h
        source/GUI/Components/ChokeGroupLabel.h
        source/GUI/Components/WaveformButton.cpp
        source/GUI/Components/UtilityMenu.cpp
        source/GUI/Components/ValueHoverComps.h
        source/GUI/Components/PresetManagerComponent.cpp
        source/GUI/Components/WaveformButton.h
        source/GUI/Components/Unused_Comps/Grid.h
        source/GUI/Components/Unused_Comps/AccountDropDown.h
        source/GUI/Components/Unused_Comps/ReorderButton.h
        source/GUI/Components/SVGPaths.h
        source/GUI/Components/KitDropDown.h
        source/GUI/Components/WaveformTriggerOverlay.h
        source/GUI/Components/MidiMappingLabel.cpp
        source/GUI/Components/MidiMappingLabel.h
        source/GUI/Components/TrialHeader.h
        source/GUI/Components/BorderOverlay.h
        source/GUI/Components/Sliders/RotarySlider.h
        source/GUI/Components/Sliders/VerticalSlider.h
        source/GUI/Components/Sliders/PanningSlider.h
        source/GUI/Components/Sliders/PitchSlider.h
        source/GUI/Components/Sliders/HorizontalSlider.h
        source/GUI/Components/Sliders/TwoValueSlider.h
        source/GUI/Components/ChokeGroupLabel.cpp
        source/GUI/Components/SVGButtons/RepositionIcon.h
        source/GUI/Components/SVGButtons/SVGButtonIncludes.h
        source/GUI/Components/SVGButtons/MuteButton.h
        source/GUI/Components/SVGButtons/UndoRedoButton.h
        source/GUI/Components/SVGButtons/FolderButton.h
        source/GUI/Components/SVGButtons/RefreshButton.h
        source/GUI/Components/SVGButtons/RefreshAllButton.h
        source/GUI/Components/SVGButtons/PlayButton.h
        source/GUI/Components/SVGButtons/DragToDawButton.h
        source/GUI/GUI.cpp
        source/GUI/DrumRackPad.cpp
        source/GUI/DrumPad.h
        source/GUI/FileAndItemAcceptor.h
        source/GUI/GUIIncludes.h
        source/GUI/LookAndFeel/Colors.h
        source/GUI/LookAndFeel/LookAndFeel.cpp
        source/GUI/LookAndFeel/LookAndFeel.h
        source/Parameters/SamplerParameters.h
        source/Parameters/SamplerParameters.cpp
        source/Parameters/Identifiers.h
        source/Parameters/ExternalParameters.cpp
        source/Parameters/ExternalParameters.h
        source/Parameters/DrumParameters.h
        source/Parameters/ParameterIncludes.h
        source/API/DownloadThread.h
        source/API/ServerUtilities.h
        source/API/PluginAuthorization.h
        source/API/SampleDownloadListener.h
        source/Service/DrumPadCopyPasteManager.cpp
        source/Service/PresetManager.h
        source/Service/DrumPadCopyPasteManager.h
        source/Service/PresetManager.cpp
        source/DSP/EmSynthesiser.h
        source/DSP/EmSamplerVoice.cpp
        source/DSP/SVF.cpp
        source/DSP/SamplerProcessor.h
        source/DSP/DSPFunctions.h
        source/DSP/SamplerProcessor.cpp
        source/DSP/SVF.h
        source/DSP/ADSR.cpp
        source/DSP/EmSamplerVoice.h
        source/DSP/RenderFX.h
        source/DSP/ADSR.h
        source/Utilities/AppUtilities.h
        source/JuceLibraryCode/include_juce_core.cpp
        source/JuceLibraryCode/include_juce_audio_formats.cpp
        source/JuceLibraryCode/include_juce_audio_plugin_client_VST3.cpp
        source/JuceLibraryCode/include_juce_audio_plugin_client_VST2.cpp
        source/JuceLibraryCode/include_juce_dsp.cpp
        source/JuceLibraryCode/include_juce_audio_plugin_client_AAX.cpp
        source/JuceLibraryCode/include_juce_audio_basics.cpp
        source/JuceLibraryCode/include_juce_events.cpp
        source/JuceLibraryCode/include_juce_audio_plugin_client_Unity.cpp
        source/JuceLibraryCode/include_juce_data_structures.cpp
        source/JuceLibraryCode/include_juce_audio_devices.cpp
        source/JuceLibraryCode/include_juce_audio_utils.cpp
        source/JuceLibraryCode/include_juce_audio_plugin_client_Standalone.cpp
        source/JuceLibraryCode/include_juce_graphics.cpp
        source/JuceLibraryCode/include_juce_gui_basics.cpp
        source/JuceLibraryCode/include_juce_audio_processors.cpp
        source/JuceLibraryCode/include_juce_audio_processors_ara.cpp
        source/JuceLibraryCode/include_juce_gui_extra.cpp
        source/JuceLibraryCode/include_juce_audio_plugin_client_LV2.cpp
        source/JuceLibraryCode/include_juce_audio_plugin_client_ARA.cpp
        source/JuceLibraryCode/JucePluginDefines.h
        source/JuceLibraryCode/include_juce_audio_processors_lv2_libs.cpp
        source/JuceLibraryCode/include_juce_audio_plugin_client_AAX_utils.cpp
        source/JuceLibraryCode/BinaryData.cpp
        source/JuceLibraryCode/BinaryData.h
        source/JuceLibraryCode/JuceHeader.h
)

target_sources("${PROJECT_NAME}" PRIVATE ${SourceFiles})

# No, we don't want our source buried in extra nested folders
set_target_properties("${PROJECT_NAME}" PROPERTIES FOLDER "")

# The Xcode source tree should uhhh, still look like the source tree, yo
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX "" FILES ${SourceFiles})

# Adds a BinaryData target for embedding assets into the binary
#include(Assets)

set(AssetFiles
        assets/images/pamplejuce.png
        assets/PNGs/drag_wave_icon.png
        assets/PNGs/drag_icon.png
        assets/SVGs/library.svg
        assets/SVGs/drag2Daw.svg
        assets/SVGs/refresh.svg
        assets/SVGs/crunchy.svg
        assets/SVGs/creamy.svg
        assets/SVGs/Logo.svg
        "assets/Samples/White Noise Free ED2.wav"
        "assets/Presets/Utility - Andrew Rose - Hello World.emPreset"
        assets/Fonts/Barlow_Light.ttf
        assets/Fonts/Barlow_Regular.ttf
        assets/Fonts/Barlow_Bold.ttf
        assets/Fonts/Exo2_Light.ttf
        assets/Fonts/Exo2_Bold.ttf
        assets/Fonts/Barlow_Medium.ttf
        assets/Fonts/Exo2_Regular.ttf
)

# Setup our binary data as a target
juce_add_binary_data(Assets SOURCES ${AssetFiles})

# MacOS only: Cleans up folder and target organization on Xcode.
include(XcodePrettify)

# This is where you can set preprocessor definitions for JUCE and your plugin
target_compile_definitions(SharedCode
    INTERFACE

    # JUCE_WEB_BROWSER and JUCE_USE_CURL off by default
    JUCE_WEB_BROWSER=0  # If you set this to 1, add `NEEDS_WEB_BROWSER TRUE` to the `juce_add_plugin` call
    JUCE_USE_CURL=0     # If you set this to 1, add `NEEDS_CURL TRUE` to the `juce_add_plugin` call
    JUCE_VST3_CAN_REPLACE_VST2=0

    # Uncomment if you are paying for a an Indie/Pro license or releasing under GPLv3
    JUCE_DISPLAY_SPLASH_SCREEN=0

    # lets the app known if we're Debug or Release
    CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}"
    VERSION="${CURRENT_VERSION}"

    # JucePlugin_Name is for some reason doesn't use the nicer PRODUCT_NAME
    PRODUCT_NAME_WITHOUT_VERSION="PluginName"
)

# Link to any other modules you added (with juce_add_module) here!
# Usually JUCE modules must have PRIVATE visibility
# See https://github.com/juce-framework/JUCE/blob/master/docs/CMake%20API.md#juce_add_module
# However, with Pamplejuce, you'll link modules to SharedCode with INTERFACE visibility
# This allows the JUCE plugin targets and the Tests target to link against it
target_link_libraries(SharedCode
    INTERFACE
    Assets
    melatonin_inspector
    juce_audio_basics
    juce_audio_devices
    juce_audio_formats
    juce_audio_plugin_client
    juce_core
    juce_data_structures
    juce_events
    juce_graphics
    juce_audio_utils
    juce_audio_processors
    juce_dsp
    juce_gui_basics
    juce_gui_extra
    juce::juce_recommended_config_flags
    juce::juce_recommended_lto_flags
    juce::juce_recommended_warning_flags)

# Link the JUCE plugin targets our SharedCode target
target_link_libraries("${PROJECT_NAME}" PRIVATE SharedCode)

# IPP support, comment out to disable
include(PamplejuceIPP)

# Everything related to the tests target
include(Tests)

# A separate target keeps the Tests target fast!
include(Benchmarks)

# Pass some config to GA (like our PRODUCT_NAME)
include(GitHubENV)
sudara commented 7 months ago

Hi there!

set(CMAKE_C_COMPILER "/usr/bin/clang")
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")

What's the reasoning for doing this? It makes the project non-portable (best to supply these as arguments to cmake on the command line when necessary). On apple platforms, CMake should do the right thing without these arguments.

For example, to generate an Xcode project, you'd could do the following:

# configure into a directory called cmake-build
cmake --build cmake-build 

# build and generate an Xcode project 
cmake . -B cmake-build -GXcode

or if you are using Clion, you can just open the folder up and it'll all just work...

luisldq commented 7 months ago

@sudara thanks for your response :-) I added those to try and see if it would help. Same result without. I am using CLion :-(

luisldq commented 7 months ago

To be clear, I am trying the CLion Build command, for the Standalone target.

/Applications/CMake.app/Contents/bin/cmake --build /Users/ldq/Audialab/thiccc-pamplejuce2/cmake-build-debug --target MyPlugin_Standalone -j 8
sudara commented 7 months ago

It's a bit hard to "diff" what's going on in your version vs. vanilla pamplejuce, as there's a lot of changes.

Stuff like this is going to make things quite unhappy:

include_directories(source/JuceLibraryCode)

as is

source/JuceLibraryCode/include_juce_gui_basics.cpp

You don't need any of that. You shouldn't be pulling in JUCE code manually. You just need add_subdirectory(JUCE) .

This is also wrong, please check the current CMakeLists:

target_sources("${PROJECT_NAME}" PRIVATE ${SourceFiles})

I would recommend starting again with a clean version of Pamplejuce's CMakeLists.txt. Make sure it builds happy and then add things incrementally to figure out when they break.

luisldq commented 7 months ago

Thank you! FYI I added -x objective-c++ to the build command on my command line and it worked.

luisldq commented 7 months ago

I reverted to a stock PampleJUCE CMakeLists.txt and after rearranging some of my code which was generated by Projucer initially, I got it to work. Weird error above where -x objective-c++ was missing :-)

luisldq commented 7 months ago

Closing as nonissue