From b183f8ea97c29eef5bd5b3832fb7f72697b3dd12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Vanda=C3=ABle?= Date: Fri, 6 Nov 2026 23:35:02 +0100 Subject: [PATCH] CMake: Bundle dolphin-tool on macOS I do not own an Apple device and as such this is completely untested by myself. A user requesting this feature on Discord has confirmed this makes dolphin-tool show up. Most of these changes come from looking at what already exists for DolphinQt and the Mac Updater. Related issue: https://bugs.dolphin-emu.org/issues/13259 --- BuildMacOSUniversalBinary.py | 19 +++++++++++++++++++ Source/Core/CMakeLists.txt | 22 ++++++++++++++++++++++ Source/Core/DolphinTool/CMakeLists.txt | 10 ++++++++++ 3 files changed, 51 insertions(+) diff --git a/BuildMacOSUniversalBinary.py b/BuildMacOSUniversalBinary.py index 879b80ae09..630c48c3dc 100755 --- a/BuildMacOSUniversalBinary.py +++ b/BuildMacOSUniversalBinary.py @@ -69,6 +69,9 @@ DEFAULT_CONFIG = { # Whether our autoupdate functionality is enabled or not. "autoupdate": True, + # Whether dolphin-tool is built and bundled with the application. + "enable_cli_tool": True, + # Whether CCache is used for the build or not. "ccache": False, @@ -122,6 +125,12 @@ def parse_args(conf=DEFAULT_CONFIG): action=argparse.BooleanOptionalAction, default=conf["autoupdate"]) + parser.add_argument( + "--enable_cli_tool", + help="Enables building and bundling dolphin-tool", + action=argparse.BooleanOptionalAction, + default=conf["enable_cli_tool"]) + parser.add_argument( "--ccache", help="Enables CCache", @@ -303,6 +312,8 @@ def build(config): '-DMACOS_CODE_SIGNING="ON"', "-DENABLE_AUTOUPDATE=" + python_to_cmake_bool(config["autoupdate"]), + "-DENABLE_CLI_TOOL=" + + python_to_cmake_bool(config["enable_cli_tool"]), '-DDISTRIBUTOR=' + config['distributor'], # Distributable bundles need to be postprocessed to embed dependencies "-DPOSTPROCESS_BUNDLE=ON", @@ -346,6 +357,14 @@ def build(config): config["codesign_identity"], dst_app+"/Dolphin.app/Contents/Helpers/Dolphin Updater.app"]) + if config["enable_cli_tool"]: + subprocess.check_call([ + "../Tools/mac-codesign.sh", + "-t", + "-e", "preserve", + config["codesign_identity"], + dst_app+"/Dolphin.app/Contents/Helpers/dolphin-tool"]) + subprocess.check_call([ "../Tools/mac-codesign.sh", "-t", diff --git a/Source/Core/CMakeLists.txt b/Source/Core/CMakeLists.txt index b1c5a3ab17..2bc7e3e481 100644 --- a/Source/Core/CMakeLists.txt +++ b/Source/Core/CMakeLists.txt @@ -76,6 +76,28 @@ if (APPLE AND ENABLE_QT) endif() endif() + if (ENABLE_CLI_TOOL) + add_dependencies(build_final_bundle dolphin-tool) + + add_custom_command(TARGET build_final_bundle + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory + "${DOLPHIN_MAC_BUNDLE}/Contents/Helpers" + + COMMAND ${CMAKE_COMMAND} -E copy + "$" + "${DOLPHIN_MAC_BUNDLE}/Contents/Helpers/dolphin-tool") + + if (MACOS_CODE_SIGNING) + add_custom_command(TARGET build_final_bundle + POST_BUILD + COMMAND "${CMAKE_SOURCE_DIR}/Tools/mac-codesign.sh" + "-t" + "${MACOS_CODE_SIGNING_IDENTITY}" + "${DOLPHIN_MAC_BUNDLE}/Contents/Helpers/dolphin-tool") + endif() + endif() + if (MACOS_CODE_SIGNING) add_custom_command(TARGET build_final_bundle POST_BUILD diff --git a/Source/Core/DolphinTool/CMakeLists.txt b/Source/Core/DolphinTool/CMakeLists.txt index cbc15fe85f..fad24ad655 100644 --- a/Source/Core/DolphinTool/CMakeLists.txt +++ b/Source/Core/DolphinTool/CMakeLists.txt @@ -33,6 +33,16 @@ if(MSVC) target_link_libraries(dolphin-tool PRIVATE use_pch) endif() +if(APPLE) + if(MACOS_CODE_SIGNING) + add_custom_command(TARGET dolphin-tool + POST_BUILD + COMMAND "${CMAKE_SOURCE_DIR}/Tools/mac-codesign.sh" + "${MACOS_CODE_SIGNING_IDENTITY}" + "$") + endif() +endif() + set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} dolphin-tool) if (NOT WIN32) install(TARGETS dolphin-tool RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})