@@ -166,25 +166,45 @@ set(CPACK_DEBIAN_LABRECORDER_PACKAGE_SECTION "science" CACHE INTERNAL "")
166166LSLGenerateCPackConfig()
167167
168168if (APPLE AND NOT DEFINED ENV{GITHUB_ACTIONS})
169- # Qt6 QtNetwork depends on libbrotidec which depends on libbroticommon but whose search path uses @loader_path.
170- # Unfortunately, macdeployqt does not seem to traverse @loader_path dependencies.
171- # So we are forced to call `fixup_bundle`. For now, we only do this if homebrew is present
172- # because that seems to be where the bad dependency is coming from.
173- # Note that fixup_bundle also destroys the codesigning so we have to redo that.
174- # TODO: Checkout supercollider apple-specific stuff, e.g.: https://github.com/supercollider/supercollider/blob/develop/CMakeLists.txt#L260-L262
175- execute_process (
169+ # Qt6 QtNetwork depends on libbrotidec which depends on libbroticommon but whose search path uses @loader_path.
170+ # Unfortunately, macdeployqt does not seem to traverse @loader_path dependencies.
171+ # So we are forced to call `fixup_bundle`. For now, we only do this if homebrew is present
172+ # because that seems to be where the bad dependency is coming from.
173+ # Note that fixup_bundle also destroys the codesigning so we have to redo that.
174+ # TODO: Checkout supercollider apple-specific stuff, e.g.: https://github.com/supercollider/supercollider/blob/develop/CMakeLists.txt#L260-L262
175+
176+ # Detect Apple Silicon
177+ execute_process (
178+ COMMAND uname -m
179+ OUTPUT_VARIABLE ARCH
180+ OUTPUT_STRIP_TRAILING_WHITESPACE
181+ )
182+
183+ # Check for Homebrew
184+ execute_process (
176185 COMMAND brew --prefix
177186 RESULT_VARIABLE BREW_LIB
178187 OUTPUT_VARIABLE BREW_PREFIX
179188 OUTPUT_STRIP_TRAILING_WHITESPACE
180189 )
181- if (BREW_LIB EQUAL 0 AND EXISTS "${BREW_PREFIX} " )
182- install (CODE
183- "
184- include(BundleUtilities)
185- fixup_bundle(\" ${CMAKE_INSTALL_PREFIX} /${PROJECT_NAME} /${PROJECT_NAME} .app\" \"\" \" ${BREW_PREFIX} /lib\" )
186- execute_process(COMMAND codesign --force --deep --sign - ${CMAKE_INSTALL_PREFIX} /${PROJECT_NAME} /${PROJECT_NAME} .app)
187- "
188- )
189- endif ()
190- endif (APPLE AND NOT DEFINED ENV{GITHUB_ACTIONS})
190+
191+ if (BREW_LIB EQUAL 0 AND EXISTS "${BREW_PREFIX} " )
192+ install (CODE
193+ "
194+ include(BundleUtilities)
195+ fixup_bundle(\" ${CMAKE_INSTALL_PREFIX} /${PROJECT_NAME} /${PROJECT_NAME} .app\" \"\" \" ${BREW_PREFIX} /lib\" )
196+
197+ # Fix Qt plugin references specifically for Apple Silicon
198+ if(\" ${ARCH} \" STREQUAL \" arm64\" )
199+ execute_process(COMMAND install_name_tool -change @rpath/QtGui.framework/Versions/A/QtGui @executable_path/../Frameworks/QtGui
200+ \" ${CMAKE_INSTALL_PREFIX} /${PROJECT_NAME} /${PROJECT_NAME} .app/Contents/PlugIns/platforms/libqcocoa.dylib\" )
201+ endif()
202+
203+ # Re-sign with the same approach the project already uses
204+ execute_process(COMMAND codesign --remove-signature \" ${CMAKE_INSTALL_PREFIX} /${PROJECT_NAME} /${PROJECT_NAME} .app\" )
205+ execute_process(COMMAND find \" ${CMAKE_INSTALL_PREFIX} /${PROJECT_NAME} /${PROJECT_NAME} .app/Contents/Frameworks\" -type f -exec codesign --force --sign - {} \\ ; 2>/dev/null || true)
206+ execute_process(COMMAND find \" ${CMAKE_INSTALL_PREFIX} /${PROJECT_NAME} /${PROJECT_NAME} .app/Contents/PlugIns\" -type f -exec codesign --force --sign - {} \\ ; 2>/dev/null || true)
207+ execute_process(COMMAND codesign --force --deep --sign - \" ${CMAKE_INSTALL_PREFIX} /${PROJECT_NAME} /${PROJECT_NAME} .app\" ) "
208+ )
209+ endif ()
210+ endif (APPLE AND NOT DEFINED ENV{GITHUB_ACTIONS})
0 commit comments