-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathmacos.cmake
More file actions
131 lines (113 loc) · 5.09 KB
/
Copy pathmacos.cmake
File metadata and controls
131 lines (113 loc) · 5.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# macos specific packaging
if (SUNSHINE_BUILD_HOMEBREW)
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/macos/assets/"
DESTINATION "${SUNSHINE_ASSETS_DIR}")
# copy assets to build directory, for running without install
file(COPY "${SUNSHINE_SOURCE_ASSETS_DIR}/macos/assets/"
DESTINATION "${CMAKE_BINARY_DIR}/assets")
else()
# .app build
set(APPLE_CODESIGN_IDENTITY "" CACHE STRING "Codesign identity, e.g. 'Developer ID Application: Name (TEAMID)'")
# Build an .app
set(CMAKE_MACOSX_BUNDLE YES)
set(MAC_BUNDLE_NAME "${CMAKE_PROJECT_NAME}.app")
set(MAC_BUNDLE_CONTENTS "${MAC_BUNDLE_NAME}/Contents")
set(MAC_BUNDLE_RESOURCES "${MAC_BUNDLE_CONTENTS}/Resources")
install(TARGETS sunshine
BUNDLE DESTINATION .
COMPONENT Runtime)
install(FILES "${APPLE_PLIST_FILE}"
DESTINATION "${MAC_BUNDLE_CONTENTS}"
COMPONENT Runtime)
install(FILES "${PROJECT_SOURCE_DIR}/src_assets/macos/build/sunshine.icns"
DESTINATION "${MAC_BUNDLE_RESOURCES}"
COMPONENT Runtime)
# macOS-specific assets (apps.json, etc.)
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/macos/assets/"
DESTINATION "${MAC_BUNDLE_RESOURCES}/assets"
COMPONENT Runtime
PATTERN ".DS_Store" EXCLUDE
PATTERN "._*" EXCLUDE)
set(SUNSHINE_BUNDLE_FIXUP_DIRS "")
set(SUNSHINE_MACDEPLOYQT_CODE "")
if(SUNSHINE_ENABLE_TRAY)
include("${CMAKE_MODULE_PATH}/packaging/qt.cmake")
sunshine_require_qt_tool(macdeployqt SUNSHINE_MACDEPLOYQT_EXECUTABLE)
sunshine_collect_qt_library_dirs(SUNSHINE_BUNDLE_FIXUP_DIRS)
set(SUNSHINE_MACDEPLOYQT_CODE "
message(STATUS \"Running macdeployqt for: \${_app}\")
execute_process(
COMMAND \"${SUNSHINE_MACDEPLOYQT_EXECUTABLE}\" \"\${_app}\" -no-strip
RESULT_VARIABLE _macdeployqt_result
)
if(NOT _macdeployqt_result EQUAL 0)
message(FATAL_ERROR \"macdeployqt failed: \${_macdeployqt_result}\")
endif()
")
endif()
# Pull in non-system dylibs for a self-contained .app
install(CODE "
set(_app \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_PROJECT_NAME}.app\")
set(_bundle_fixup_dirs \"${SUNSHINE_BUNDLE_FIXUP_DIRS}\")
${SUNSHINE_MACDEPLOYQT_CODE}
message(STATUS \"Running fixup_bundle for: \${_app}\")
include(BundleUtilities)
set(BU_CHMOD_BUNDLE_ITEMS TRUE)
fixup_bundle(\"\${_app}\" \"\" \"\${_bundle_fixup_dirs}\")
# Remove Finder/resource-fork metadata that breaks codesign.
execute_process(COMMAND /usr/bin/xattr -rc \"\${_app}\")
message(STATUS \"removing any existing signatures\")
execute_process(COMMAND /usr/bin/codesign
--remove-signature --force --deep
\"\${_app}\"
RESULT_VARIABLE rc
)
if(NOT rc EQUAL 0)
message(FATAL_ERROR \"codesign failed to remove existing signatures\")
endif()
# SHOULD_SIGN is set only when publish_release is true or when manually building
if(\"\$ENV{SHOULD_SIGN}\" STREQUAL \"true\")
# Sign anything inside Contents/Frameworks
set(_fw_dir \"\${_app}/Contents/Frameworks\")
if(EXISTS \"\${_fw_dir}\")
file(GLOB_RECURSE _sign_items
\"\${_fw_dir}/*.framework\"
\"\${_fw_dir}/*.dylib\"
)
foreach(item IN LISTS _sign_items)
execute_process(COMMAND /usr/bin/codesign --verbose=2
--sign \"${APPLE_CODESIGN_IDENTITY}\" \"\${item}\"
--force --timestamp --options=runtime
RESULT_VARIABLE rc2
)
if(NOT rc2 EQUAL 0)
message(FATAL_ERROR \"codesign failed while signing library: \${item}\")
endif()
endforeach()
endif()
# Sign the app last
execute_process(COMMAND /usr/bin/codesign --verbose=2
--sign \"${APPLE_CODESIGN_IDENTITY}\" \"\${_app}\"
--force --timestamp --options=runtime
RESULT_VARIABLE rc3
)
if(NOT rc3 EQUAL 0)
message(FATAL_ERROR \"codesign failed while signing .app\")
endif()
# Verify
execute_process(COMMAND /usr/bin/codesign --verify --deep --strict --verbose=2 \"\${_app}\"
RESULT_VARIABLE rc4
)
if(NOT rc4 EQUAL 0)
message(FATAL_ERROR \"codesign --verify failed\")
endif()
endif()
" COMPONENT Runtime)
# DragNDrop
set(CPACK_BUNDLE_NAME "${CMAKE_PROJECT_NAME}")
set(CPACK_BUNDLE_PLIST "${APPLE_PLIST_FILE}")
set(CPACK_BUNDLE_ICON "${PROJECT_SOURCE_DIR}/src_assets/macos/build/sunshine.icns")
set(CPACK_PACKAGING_INSTALL_PREFIX "/")
set(CPACK_DMG_BACKGROUND_IMAGE "${PROJECT_SOURCE_DIR}/src_assets/macos/build/sunshine-background-72dpi.jpg")
set(CPACK_DMG_DS_STORE_SETUP_SCRIPT "${PROJECT_SOURCE_DIR}/src_assets/macos/build/dmg-finder-layout.applescript")
endif()