Total Noob needs help cross compiling on M1 Mac

Hey Guys,

I hope all is well! I am really close to getting this to cross compile correctly. I have done all the steps listed in this post: Cross compiling JUCE 6.1.6 results in juceaide being compiled with target toolchain - #4 by valentinlageard

I am using an M1 Macbook Pro running OS 12.2. I am using the the toolchain in docker. I have setup the docker environment correctly. My plugin files are in my work directory.

Everytime I try to build the plugin it fails at Configuring juceaide. It gives a very long error in terminal. The last bit is "JUCE requires support for std::atomic, but this system cannot succesfuly compile a program which uses std::atomic.

I feel like maybe my CMake file is wrong? I have it pasted below. I really hope its not my environment. I tried to compile on a VM with Ubuntu installed but the toolchain is x86 and I would need to emulate this arch and it really slow. So low its no usable on my computer. Can someone please share a Cmake file or a git with a succesful build?

CMAKE File:

cmake_minimum_required(VERSION 3.23.1)

General setup

set(PROJECT_NAME “SYNAMP”)
set(CURRENT_VERSION “0.0.1”)
set(PRODUCT_NAME “SYNAMP”)
set(COMPANY_NAME “Synesthia”)
set(BUNDLE_ID “com.syndsp.synamp”)
set(FORMATS Standalone AU VST3)

project(SYNAMP VERSION 0.0.1)

add_subdirectory(JUCE)

Project configuration

set(CMAKE_CXX_STANDARD 23)

if (UNIX AND CMAKE_SYSTEM_NAME STREQUAL “Linux”)
find_package(PkgConfig REQUIRED)
pkg_check_modules(WEBKIT2 REQUIRED webkit2gtk-4.0)

include_directories(${WEBKIT2_INCLUDE_DIRS})
link_directories(${WEBKIT2_LIBRARY_DIRS})
add_definitions(${WEBKIT2_CFLAGS_OTHER})
endif()

Disable all warnings

add_definitions(-w)

if(CMAKE_SYSTEM_NAME STREQUAL “Windows”)
set(CMAKE_MSVC_RUNTIME_LIBRARY “MultiThreaded$<$CONFIG:Debug:Debug>” CACHE INTERNAL “”)
endif()

Define the plugin

juce_add_plugin(“${PROJECT_NAME}”
COMPANY_NAME “${COMPANY_NAME}”
BUNDLE_ID “${BUNDLE_ID}”
COPY_PLUGIN_AFTER_BUILD TRUE
PLUGIN_MANUFACTURER_CODE SYND
PLUGIN_CODE SYNA
FORMATS ${FORMATS}
PRODUCT_NAME “${PRODUCT_NAME}”
NEEDS_MIDI_INPUT FALSE
NEEDS_MIDI_OUTPUT FALSE
IS_MIDI_EFFECT FALSE
IS_SYNTH FALSE
)

juce_generate_juce_header(${PROJECT_NAME})

add_compile_definitions(JUCE_PROJECT_NAME=“${PROJECT_NAME}”)

Define SharedCode as an INTERFACE library

add_library(SharedCode INTERFACE)

Set compile features for SharedCode

target_compile_features(SharedCode INTERFACE cxx_std_20)

Include directories and compile definitions for SharedCode

target_include_directories(SharedCode INTERFACE
“${CMAKE_CURRENT_SOURCE_DIR}/source”
“${CMAKE_CURRENT_SOURCE_DIR}/modules/JUCE/modules”
“${CMAKE_BINARY_DIR}/AudioPluginData” # Include directory for AudioPluginData
)

Set JUCE flags for SharedCode

target_compile_definitions(SharedCode INTERFACE
JUCE_GLOBAL_MODULE_SETTINGS_INCLUDED=1
JUCE_WEB_BROWSER=1
JUCE_USE_CURL=0
JUCE_VST3_CAN_REPLACE_VST2=0
CMAKE_BUILD_TYPE=“${CMAKE_BUILD_TYPE}”
VERSION=“${CURRENT_VERSION}”
JUCE_DISPLAY_SPLASH_SCREEN=0
PRODUCT_NAME_WITHOUT_VERSION=“SYNAMP”
JUCE_ENABLE_REPAINT_DEBUGGING=0
)

Add sources to the main project

file(GLOB_RECURSE SourceFiles CONFIGURE_DEPENDS
“${CMAKE_CURRENT_SOURCE_DIR}/source/.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/source/
.h”
)

Sources to main project

target_sources(“${PROJECT_NAME}” PRIVATE ${SourceFiles})

Assets setup

file(GLOB_RECURSE Assets “${CMAKE_CURRENT_SOURCE_DIR}/assets/.”)

Add the Assets binary data as a target

juce_add_binary_data(AudioPluginData SOURCES ${Assets})

Link AudioPluginData to SharedCode

target_link_libraries(SharedCode INTERFACE AudioPluginData)

Ensure AudioPluginData is built before the main project

add_dependencies(${PROJECT_NAME} AudioPluginData)

Link libraries to main project

target_link_libraries(“${PROJECT_NAME}” PRIVATE
SharedCode
AudioPluginData
juce::juce_audio_basics
juce::juce_audio_devices
juce::juce_audio_formats
juce::juce_audio_plugin_client
juce::juce_audio_processors
juce::juce_audio_utils
juce::juce_core
juce::juce_data_structures
juce::juce_dsp
juce::juce_events
juce::juce_graphics
juce::juce_gui_basics
juce::juce_gui_extra
juce::juce_product_unlocking
PUBLIC
juce::juce_recommended_config_flags
juce::juce_recommended_lto_flags
juce::juce_recommended_warning_flags
)

Ensure the main project knows where its sources are

target_include_directories(“${PROJECT_NAME}” PRIVATE
“${CMAKE_CURRENT_SOURCE_DIR}/source”
)

------------------------

Automatic VST3 copy (optional for custom path)

------------------------

On macOS, COPY_PLUGIN_AFTER_BUILD TRUE already copies to:

~/Library/Audio/Plug-Ins/VST3/${PRODUCT_NAME}.vst3

Thanks!
-Mike

Hi mcproductions and welcome to the forums. It’s a known issue that Juce tries to cross-compile both the plugin and juceaide, which is a tool used in the build process and should be compiled for the build env architecture, not for the target architecture. To solve this you need to use the system Juce in the SDK. See Build Plugins for Elk — Elk DevKit documentation

Basically you need to replace

add_subdirectory(JUCE)

with

find_package(JUCE CONFIG REQUIRED) 

To use the system JUCE and avoid having to compile juceaide.

I also copied parts of your CMake code and tested it in a docker container with our SDK and noticed that

Does not work as intended, it returns false in the docker image. Not sure why, but it would be worth investigating.

Hope that gets you further!

/Gustav