From d6633e6b3740da63d6d6106fdfadd4a3fc232667 Mon Sep 17 00:00:00 2001 From: reuk Date: Thu, 16 Sep 2021 18:34:31 +0100 Subject: [PATCH] CMake: Ensure that plugins can be loaded on M1 macs when using automatic copying --- extras/Build/CMake/JUCEUtils.cmake | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/extras/Build/CMake/JUCEUtils.cmake b/extras/Build/CMake/JUCEUtils.cmake index d8ac3bc8d2..0c5e4672f2 100644 --- a/extras/Build/CMake/JUCEUtils.cmake +++ b/extras/Build/CMake/JUCEUtils.cmake @@ -1048,6 +1048,15 @@ function(_juce_link_plugin_wrapper shared_code_target kind) C_VISIBILITY_PRESET hidden CXX_VISIBILITY_PRESET hidden JUCE_TARGET_KIND_STRING "${juce_kind_string}") + + # Under the Xcode generator, POST_BUILD commands (including the plugin copy step) run before + # signing, but M1 macs will only load signed binaries. Setting "adhoc_codesign" forces the + # linker to sign bundles, so that they can be loaded even if they are copied before the "real" + # signing step. See issue 21854 on the CMake Gitlab repo. + if("${CMAKE_GENERATOR};${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Xcode;Darwin;arm64") + target_link_options(${target_name} PRIVATE LINKER:-adhoc_codesign) + endif() + add_dependencies(${shared_code_target}_All ${target_name}) _juce_configure_bundle(${shared_code_target} ${target_name})