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
This commit is contained in:
Joshua Vandaële
2026-11-06 23:35:02 +01:00
parent 4a70679d0a
commit b183f8ea97
3 changed files with 51 additions and 0 deletions

View File

@@ -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",

View File

@@ -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
"$<TARGET_FILE:dolphin-tool>"
"${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

View File

@@ -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}"
"$<TARGET_FILE:dolphin-tool>")
endif()
endif()
set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} dolphin-tool)
if (NOT WIN32)
install(TARGETS dolphin-tool RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})