cmake: Export Loadable Bundles on MacOS

With OBS Studio 28.0.0 a new requirement was added to MacOS plugin: Loadable Bundles. These bundles are similar to Application Bundles, and have many of the same features, but are designed to be loaded by Applications instead of being the Application. This allows for almost all of the advantages to persist, with some minimal drawbacks.
This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2022-09-03 20:06:33 +02:00
parent e3d0cabb09
commit d4ef043043
3 changed files with 180 additions and 44 deletions

View file

@ -213,6 +213,7 @@ project(
DESCRIPTION "Additional sources, filters, transitions and encoders for OBS Studio."
HOMEPAGE_URL "https://streamfx.xaymar.com/"
)
set(PROJECT_IDENTIFER "com.xaymar.${PROJECT_NAME}.obs")
set(PROJECT_TITLE "StreamFX (for OBS Studio)")
set(PROJECT_AUTHORS "Michael Fabian 'Xaymar' Dirks <info@xaymar.com>")
set(PROJECT_COPYRIGHT "2017 - 2022, Michael Fabian Dirks. All Rights Reserved")
@ -370,6 +371,8 @@ if(STANDALONE)
set(STRUCTURE_UNIFIED CACHE BOOL "Install for use in a Plugin Manager")
if(D_PLATFORM_LINUX)
set(STRUCTURE_PACKAGEMANAGER CACHE BOOL "Install for use in a Package Manager (system-wide installation)")
elseif(D_PLATFORM_MAC)
set(STRUCTURE_BUNDLE ON CACHE BOOL "Install as a Loadable Bundle (.plugin)")
endif()
set(PACKAGE_PREFIX "${CMAKE_BINARY_DIR}" CACHE PATH "Where to place the packages?")
@ -2015,6 +2018,41 @@ if(D_PLATFORM_MAC)
BUILD_WITH_INSTALL_RPATH ON
)
endif()
# Bundle exporting
if(STRUCTURE_BUNDLE)
# Proper location for resources in Bundles
foreach(FILE IN LISTS PROJECT_DATA)
cmake_path(ABSOLUTE_PATH FILE OUTPUT_VARIABLE FILE_PATH)
cmake_path(RELATIVE_PATH FILE_PATH BASE_DIRECTORY "${PROJECT_SOURCE_DIR}/data/")
cmake_path(GET FILE_PATH PARENT_PATH FILE_PATH)
set_source_files_properties("${FILE}" PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources/${FILE_PATH}"
)
endforeach()
# Bundle Icon
set_source_files_properties("media/icon.png" PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources"
)
# Bundle Information
set(MACOSX_BUNDLE_BUNDLE_NAME "${PROJECT_NAME}")
set(MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_VERSION}")
set(MACOSX_BUNDLE_COPYRIGHT "${PROJECT_COPYRIGHT}")
set(MACOSX_BUNDLE_GUI_IDENTIFIER "${PROJECT_IDENTIFER}")
set(MACOSX_BUNDLE_ICON_FILE "icon.png")
set(MACOSX_BUNDLE_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
set(MACOSX_BUNDLE_LONG_VERSION_STRING "${_VERSION}")
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}")
set_target_properties(${PROJECT_NAME} PROPERTIES
BUNDLE ON
BUNDLE_EXTENSION "plugin"
OUTPUT_NAME ${PROJECT_NAME}
MACOSX_BUNDLE_INFO_PLIST "${PROJECT_SOURCE_DIR}/templates/macos/Info.plist.in"
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${MACOSX_BUNDLE_GUI_IDENTIFIER}"
)
endif()
endif()
################################################################################
@ -2171,19 +2209,29 @@ if(STANDALONE)
)
endif()
elseif(D_PLATFORM_MAC)
install(
TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION "${PROJECT_NAME}/bin/" COMPONENT StreamFX
LIBRARY DESTINATION "${PROJECT_NAME}/bin/" COMPONENT StreamFX
PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE
)
install(
DIRECTORY "data/"
DESTINATION "${PROJECT_NAME}/data/"
COMPONENT StreamFX
FILE_PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE
DIRECTORY_PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE
)
if(STRUCTURE_BUNDLE)
install(
TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION "." COMPONENT StreamFX
LIBRARY DESTINATION "." COMPONENT StreamFX
BUNDLE DESTINATION "." COMPONENT StreamFX
PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE
)
else()
install(
TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION "${PROJECT_NAME}/bin/" COMPONENT StreamFX
LIBRARY DESTINATION "${PROJECT_NAME}/bin/" COMPONENT StreamFX
PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE
)
install(
DIRECTORY "data/"
DESTINATION "${PROJECT_NAME}/data/"
COMPONENT StreamFX
FILE_PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE
DIRECTORY_PERMISSIONS WORLD_EXECUTE;WORLD_READ;OWNER_EXECUTE;OWNER_READ;OWNER_WRITE;GROUP_EXECUTE;GROUP_READ;GROUP_WRITE
)
endif()
endif()
else()
if(COMMAND setup_plugin_target)
@ -2296,6 +2344,10 @@ if(STANDALONE)
# Apple MacOS
if(D_PLATFORM_MAC)
# .pkg Installer
set(PACKAGES_PATH_NAME "${PROJECT_NAME}")
if(STRUCTURE_BUNDLE)
set(PACKAGES_PATH_NAME "${PACKAGES_PATH_NAME}.plugin")
endif()
configure_file(
"templates/macos/installer.pkgproj.in"
"installer.pkgproj"

View file

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
<key>CFBundleName</key>
<string>${MACOSX_PLUGIN_BUNDLE_NAME}</string>
<key>CFBundleDisplayName</key>
<string>${MACOSX_PLUGIN_BUNDLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>${MACOSX_BUNDLE_ICON_FILE}</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_PLUGIN_EXECUTABLE_NAME}</string>
<key>CFBundleVersion</key>
<string>${MACOSX_BUNDLE_VERSION_STRING}</string>
<key>CFBundleShortVersionString</key>
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
<key>CFBundleLongVersionString</key>
<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>CFBundleGetInfoString</key>
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
<key>NSHumanReadableCopyright</key>
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
<key>LSMinimumSystemVersion</key>
<string>${CMAKE_OSX_DEPLOYMENT_TARGET}</string>
</dict>
</plist>

View file

@ -37,14 +37,63 @@
<key>CHILDREN</key>
<array>
<dict>
<key>BUNDLE_CAN_DOWNGRADE</key>
<true/>
<key>BUNDLE_POSTINSTALL_PATH</key>
<dict>
<key>PATH_TYPE</key>
<integer>0</integer>
</dict>
<key>BUNDLE_PREINSTALL_PATH</key>
<dict>
<key>PATH_TYPE</key>
<integer>0</integer>
</dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>LOCATORS</key>
<array>
<dict>
<key>DICTIONARY</key>
<dict>
<key>BUNDLE_IDENTIFIER</key>
<string>com.xaymar.StreamFX.obs</string>
<key>DEFAULT_PATH</key>
<string>/Library/Application Support/obs-studio/plugins</string>
<key>PREFER_DEFAULT_PATH</key>
<integer>0</integer>
</dict>
<key>IDENTIFIER</key>
<string>fr.whitebox.Packages.locator.standard</string>
<key>NAME</key>
<string>com.xaymar.StreamFX.obs</string>
<key>STATE</key>
<true/>
</dict>
<dict>
<key>DICTIONARY</key>
<dict>
<key>BUNDLE_IDENTIFIER</key>
<string>com.xaymar.StreamFX</string>
<key>DEFAULT_PATH</key>
<string>/Library/Application Support/obs-studio/plugins</string>
<key>PREFER_DEFAULT_PATH</key>
<integer>0</integer>
</dict>
<key>IDENTIFIER</key>
<string>fr.whitebox.Packages.locator.standard</string>
<key>NAME</key>
<string>com.xaymar.StreamFX</string>
<key>STATE</key>
<true/>
</dict>
</array>
<key>PATH</key>
<string>@CMAKE_INSTALL_PREFIX@/StreamFX</string>
<string>@CMAKE_INSTALL_PREFIX@/@PACKAGES_PATH_NAME@</string>
<key>PATH_TYPE</key>
<integer>3</integer>
<integer>1</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<key>TYPE</key>
@ -58,9 +107,9 @@
<key>PATH</key>
<string>plugins</string>
<key>PATH_TYPE</key>
<integer>0</integer>
<integer>2</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<integer>509</integer>
<key>TYPE</key>
<integer>2</integer>
<key>UID</key>
@ -72,9 +121,9 @@
<key>PATH</key>
<string>obs-studio</string>
<key>PATH_TYPE</key>
<integer>0</integer>
<integer>2</integer>
<key>PERMISSIONS</key>
<integer>493</integer>
<integer>509</integer>
<key>TYPE</key>
<integer>2</integer>
<key>UID</key>
@ -445,22 +494,6 @@
<key>UID</key>
<integer>0</integer>
</dict>
<dict>
<key>CHILDREN</key>
<array/>
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>Applications</string>
<key>PATH_TYPE</key>
<integer>0</integer>
<key>PERMISSIONS</key>
<integer>509</integer>
<key>TYPE</key>
<integer>1</integer>
<key>UID</key>
<integer>0</integer>
</dict>
</array>
<key>GID</key>
<integer>0</integer>
@ -506,19 +539,19 @@
<key>PACKAGE_SETTINGS</key>
<dict>
<key>AUTHENTICATION</key>
<integer>1</integer>
<integer>0</integer>
<key>CONCLUSION_ACTION</key>
<integer>0</integer>
<key>FOLLOW_SYMBOLIC_LINKS</key>
<false/>
<key>IDENTIFIER</key>
<string>com.xaymar.@PROJECT_NAME@</string>
<string>${PROJECT_IDENTIFER}</string>
<key>LOCATION</key>
<integer>0</integer>
<key>NAME</key>
<string>@PROJECT_NAME@</string>
<key>OVERWRITE_PERMISSIONS</key>
<true/>
<false/>
<key>PAYLOAD_SIZE</key>
<integer>-1</integer>
<key>REFERENCE_PATH</key>
@ -526,7 +559,7 @@
<key>RELOCATABLE</key>
<false/>
<key>USE_HFS+_COMPRESSION</key>
<false/>
<true/>
<key>VERSION</key>
<string>@PROJECT_VERSION@</string>
</dict>
@ -574,7 +607,7 @@
<key>OPTIONS</key>
<dict>
<key>HIDDEN</key>
<true/>
<false/>
<key>STATE</key>
<integer>1</integer>
</dict>
@ -593,7 +626,7 @@
</dict>
</dict>
<key>MODE</key>
<integer>1</integer>
<integer>0</integer>
</dict>
<key>INSTALLATION_STEPS</key>
<array>
@ -669,7 +702,7 @@
<key>VALUE</key>
<dict>
<key>PATH</key>
<string>@PROJECT_SOURCE_DIR@/license</string>
<string>@PROJECT_SOURCE_DIR@/LICENSE</string>
<key>PATH_TYPE</key>
<integer>0</integer>
</dict>
@ -706,14 +739,14 @@
<key>DICTIONARY</key>
<dict>
<key>IC_REQUIREMENT_OS_DISK_TYPE</key>
<integer>0</integer>
<integer>1</integer>
<key>IC_REQUIREMENT_OS_DISTRIBUTION_TYPE</key>
<integer>0</integer>
<key>IC_REQUIREMENT_OS_MINIMUM_VERSION</key>
<integer>101500</integer>
</dict>
<key>IC_REQUIREMENT_CHECK_TYPE</key>
<integer>1</integer>
<integer>0</integer>
<key>IDENTIFIER</key>
<string>fr.whitebox.Packages.requirement.os</string>
<key>MESSAGE</key>