Im using a mac mini M1 (apple silicon) using CMake to compile VSTs
works for native compile on mac, my same compile also works on a Linux machine.
however, Im trying to use make to cross compile on the M1 to armhf.
my cross compilation environment is working fine for my other cmake projects.
but not for juce cmake
what appears to be happening is when we build the cmake file juce cmake is bringing in dependanies from the local environment rather than sysroot
e.g
bash-3.2$ cmake -DCMAKE_TOOLCHAIN_FILE=../xc.cmake ..
using xc-ssp-toolchain
defaulting XC_ROOT to ~/xc/xcSSP
using envvar XC_ROOT - /Users/markh/xc/xcSSP
using xc-ssp-toolchain
defaulting XC_ROOT to ~/xc/xcSSP
using envvar XC_ROOT - /Users/markh/xc/xcSSP
-- The C compiler identification is Clang 11.0.0
-- The CXX compiler identification is Clang 11.0.0
-- Detecting C compiler ABI info
using xc-ssp-toolchain
defaulting XC_ROOT to ~/xc/xcSSP
using envvar XC_ROOT - /Users/markh/xc/xcSSP
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/homebrew/opt/llvm/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
using xc-ssp-toolchain
defaulting XC_ROOT to ~/xc/xcSSP
using envvar XC_ROOT - /Users/markh/xc/xcSSP
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/homebrew/opt/llvm/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
using xc-ssp-toolchain
defaulting XC_ROOT to ~/xc/xcSSP
using envvar XC_ROOT - /Users/markh/xc/xcSSP
-- Found PkgConfig: /opt/homebrew/bin/pkg-config (found version "0.29.2")
-- Checking for module 'libcurl'
-- No package 'libcurl' found
-- Checking for modules 'webkit2gtk-4.0;gtk+-x11-3.0'
-- No package 'webkit2gtk-4.0' found
-- No package 'gtk+-x11-3.0' found
using xc-ssp-toolchain
defaulting XC_ROOT to ~/xc/xcSSP
using envvar XC_ROOT - /Users/markh/xc/xcSSP
-- Checking for module 'alsa'
-- No package 'alsa' found
-- Checking for module 'freetype2'
-- Found freetype2, version 23.4.17
-- Configuring juceaide
-- Building juceaide
-- Exporting juceaide
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/markh/projects/SSP.private/build.xc
here we can see its not finding a bunch of libraries (webkit2gtk-4.0) since they are not in the local environment (only the sysroot) , and similar freetype is the wrong verison 23.4.17 is the local env, where sysroot has 18.3.12
we can see this materialise when we try to link
cd /Users/markh/projects/SSP.private/build.xc/technobear/clds && /opt/homebrew/Cellar/cmake/3.19.1/bin/cmake -E cmake_link_script CMakeFiles/CLDS_VST.dir/link.txt --verbose=1
/opt/homebrew/opt/llvm/bin/clang++ --target=arm-linux-gnueabihf --sysroot=/Users/markh/xc/xcSSP/sysroot -fPIC -mcpu=cortex-a17 -mfloat-abi=hard -mfpu=neon-vfpv4 -mcpu=cortex-a17 -mfloat-abi=hard -mfpu=neon-vfpv4 -L/Users/markh/xc/xcSSP/sysroot/usr/local/lib -L/Users/markh/xc/xcSSP/sysroot/lib/arm-linux-gnueabihf -L/Users/markh/xc/xcSSP/sysroot/usr/lib/arm-linux-gnueabihf -L/Users/markh/xc/xcSSP/sysroot/usr/lib/gcc/arm-linux-gnueabihf -B/Users/markh/xc/xcSSP/sysroot/usr/lib/gcc/arm-linux-gnueabihf -Wl,-rpath-link,/Users/markh/xc/xcSSP/sysroot/lib/arm-linux-gnueabihf -L/Users/markh/xc/xcSSP/sysroot/usr/local/lib -L/Users/markh/xc/xcSSP/sysroot/lib/arm-linux-gnueabihf -L/Users/markh/xc/xcSSP/sysroot/usr/lib/arm-linux-gnueabihf -L/Users/markh/xc/xcSSP/sysroot/usr/lib/gcc/arm-linux-gnueabihf -B/Users/markh/xc/xcSSP/sysroot/usr/lib/gcc/arm-linux-gnueabihf -Wl,-rpath-link,/Users/markh/xc/xcSSP/sysroot/lib/arm-linux-gnueabihf -L/Users/markh/xc/xcSSP/sysroot/usr/local/lib -L/Users/markh/xc/xcSSP/sysroot/lib/arm-linux-gnueabihf -L/Users/markh/xc/xcSSP/sysroot/usr/lib/arm-linux-gnueabihf -L/Users/markh/xc/xcSSP/sysroot/usr/lib/gcc/arm-linux-gnueabihf -B/Users/markh/xc/xcSSP/sysroot/usr/lib/gcc/arm-linux-gnueabihf -Wl,-rpath-link,/Users/markh/xc/xcSSP/sysroot/lib/arm-linux-gnueabihf -shared -o CLDS_artefacts/VST/clds.so CMakeFiles/CLDS_VST.dir/__/__/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_AAX.cpp.o CMakeFiles/CLDS_VST.dir/__/__/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_RTAS_1.cpp.o CMakeFiles/CLDS_VST.dir/__/__/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_RTAS_2.cpp.o CMakeFiles/CLDS_VST.dir/__/__/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_RTAS_3.cpp.o CMakeFiles/CLDS_VST.dir/__/__/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_RTAS_4.cpp.o CMakeFiles/CLDS_VST.dir/__/__/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_RTAS_utils.cpp.o CMakeFiles/CLDS_VST.dir/__/__/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp.o CMakeFiles/CLDS_VST.dir/__/__/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_Unity.cpp.o CMakeFiles/CLDS_VST.dir/__/__/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_VST2.cpp.o CMakeFiles/CLDS_VST.dir/__/__/juce/modules/juce_audio_plugin_client/juce_audio_plugin_client_VST3.cpp.o -Wl,--no-undefined CLDS_artefacts/libclds_SharedCode.a /opt/homebrew/opt/freetype/lib/libfreetype.a -lrt -ldl -lpthread
/opt/homebrew/bin/arm-linux-gnueabihf-ld: CLDS_artefacts/libclds_SharedCode.a(juce_gui_basics.cpp.o): in function `juce::XWindowSystem::setScreenSaverEnabled(bool) const':
note: how its used /opt/homebrew/opt/freetype/lib/libfreetype.a
whereas it should be using /Users/markh/xc/xcSSP/sysroot/lib/arm-linux-gnueabihf/libfreetype.a
( sysroot = /Users/markh/xc/xcSSP/sysroot)
obviously these leads to a whole bunch of link errors since the compilation has correctly been using sysroot.
any thoughts where to check in the juce cmake configuration?
to reiterateā¦ this cross compile environment and cmake toolchain file works fine for other cmake projects I have.
for clarity, Im using cmake toolchains, as discussed here:
Im then using arm-linux-gnueabihf for the cross compilation using clang