diff --git a/cmake/build_helpers.cmake b/cmake/build_helpers.cmake index 65734f912..ebb8e7130 100644 --- a/cmake/build_helpers.cmake +++ b/cmake/build_helpers.cmake @@ -237,7 +237,7 @@ macro(createPackage) set_property(TARGET main PROPERTY MACOSX_BUNDLE_INFO_PLIST ${MACOSX_BUNDLE_INFO_PLIST}) # Fix rpath - add_custom_command(TARGET imhex_all POST_BUILD COMMAND ${CMAKE_INSTALL_NAME_TOOL} -add_rpath "@executable_path/../Frameworks/" $) + add_custom_command(TARGET imhex_all POST_BUILD COMMAND ${CMAKE_INSTALL_NAME_TOOL} -add_rpath "@executable_path/../Frameworks/" $ || true) add_custom_target(build-time-make-plugins-directory ALL COMMAND ${CMAKE_COMMAND} -E make_directory "${IMHEX_BUNDLE_PATH}/Contents/MacOS/plugins") add_custom_target(build-time-make-resources-directory ALL COMMAND ${CMAKE_COMMAND} -E make_directory "${IMHEX_BUNDLE_PATH}/Contents/Resources") @@ -255,6 +255,8 @@ macro(createPackage) set(CPACK_BUNDLE_ICON "${CMAKE_SOURCE_DIR}/resources/dist/macos/AppIcon.icns") set(CPACK_BUNDLE_PLIST "${CMAKE_BINARY_DIR}/${BUNDLE_NAME}/Contents/Info.plist") + + add_custom_command(TARGET imhex_all POST_BUILD COMMAND "codesign" ARGS "--force" "--deep" "--sign" "-" "${CMAKE_BINARY_DIR}/${BUNDLE_NAME}") endif() else() install(TARGETS main RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/cmake/modules/ImHexPlugin.cmake b/cmake/modules/ImHexPlugin.cmake index 91e80cf82..0f6440d36 100644 --- a/cmake/modules/ImHexPlugin.cmake +++ b/cmake/modules/ImHexPlugin.cmake @@ -58,6 +58,11 @@ macro(add_imhex_plugin) SUFFIX ${IMHEX_PLUGIN_SUFFIX} ) + # Set rpath of plugin libraries to the plugins folder + if (APPLE) + set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES BUILD_RPATH "@executable_path/../Frameworks;@executable_path/plugins") + endif() + # Setup a romfs for the plugin list(APPEND LIBROMFS_RESOURCE_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/romfs) set(LIBROMFS_PROJECT_NAME ${IMHEX_PLUGIN_NAME}) @@ -77,11 +82,11 @@ macro(add_imhex_plugin) if (IMHEX_EXTERNAL_PLUGIN_BUILD) install(TARGETS ${IMHEX_PLUGIN_NAME} DESTINATION ".") + endif() - # Fix rpath - if (APPLE) - set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES INSTALL_RPATH "@executable_path/../Frameworks") - endif() + # Fix rpath + if (APPLE) + set_target_properties(${IMHEX_PLUGIN_NAME} PROPERTIES INSTALL_RPATH "@executable_path/../Frameworks;@executable_path/plugins") endif() endmacro() diff --git a/cmake/modules/PostprocessBundle.cmake b/cmake/modules/PostprocessBundle.cmake index c14c6fba5..e421888ba 100644 --- a/cmake/modules/PostprocessBundle.cmake +++ b/cmake/modules/PostprocessBundle.cmake @@ -55,7 +55,8 @@ message(STATUS "Fixing up application bundle: ${extra_dirs}") include(BundleUtilities) set(BU_CHMOD_BUNDLE_ITEMS ON) -fixup_bundle("${BUNDLE_PATH}" "${plugins};${plugin_libs}" "${extra_dirs}") + +fixup_bundle("${BUNDLE_PATH}" "${plugins}" "${extra_dirs}") if (CODE_SIGN_CERTIFICATE_ID) # Hack around Apple Silicon signing bugs by copying the real app, signing it and moving it back. diff --git a/lib/libimhex/source/api/plugin_manager.cpp b/lib/libimhex/source/api/plugin_manager.cpp index df8f4a2cc..cee3eef6e 100644 --- a/lib/libimhex/source/api/plugin_manager.cpp +++ b/lib/libimhex/source/api/plugin_manager.cpp @@ -268,9 +268,6 @@ namespace hex { return !plugin.isValid(); }); - if (getPlugins().empty()) - return false; - return true; }