0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-19 20:32:15 +02:00

cmake: Update buildspec and presets for macOS

This commit is contained in:
PatTheMav 2023-04-28 15:33:22 +02:00 committed by Ryan Foster
parent 1edd997c49
commit 887b537d56
11 changed files with 266 additions and 423 deletions

View File

@ -108,25 +108,6 @@ jobs:
path: 'obs-studio'
fetch-depth: 0
- name: 'Check for GitHub Labels'
id: github-check
run: |
if [[ "${GITHUB_EVENT_NAME}" == 'pull_request' ]]; then
if test -n "$(curl -H "Authorization: Bearer ${{ github.token }}" -s "${{ github.event.pull_request.url }}" | jq -e '.labels[] | select(.name == "Seeking Testers")')"; then
echo "generator=Xcode" >> $GITHUB_OUTPUT
else
echo "generator=Ninja" >> $GITHUB_OUTPUT
fi
elif [[ "${GITHUB_EVENT_NAME}" == 'push' ]]; then
if [[ ${GITHUB_REF_NAME} =~ [0-9]+.[0-9]+.[0-9]+(-(rc|beta).+)? ]]; then
echo "generator=Xcode" >> $GITHUB_OUTPUT
else
echo "generator=Ninja" >> $GITHUB_OUTPUT
fi
else
echo "generator=Ninja" >> $GITHUB_OUTPUT
fi
- name: 'Restore ccache from cache'
id: ccache-cache
uses: actions/cache@v3
@ -236,7 +217,7 @@ jobs:
if [[ "${PACKAGE}" ]]; then
CI/macos/03_package_obs.sh --codesign --architecture "${{ matrix.arch }}"
ARTIFACT_NAME=$(basename $(/usr/bin/find build_${{ matrix.arch }} -type f -name "obs-studio-*.dmg" -depth 1 | head -1))
ARTIFACT_NAME=$(basename $(/usr/bin/find build_macos -type f -name "obs-studio-*.dmg" -depth 1 | head -1))
echo "FILE_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV
fi
@ -245,7 +226,7 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: 'obs-studio-macos-${{ matrix.arch }}-${{ steps.setup.outputs.commitHash }}'
path: '${{ github.workspace }}/obs-studio/build_${{ matrix.arch }}/${{ env.FILE_NAME }}'
path: '${{ github.workspace }}/obs-studio/build_macos/${{ env.FILE_NAME }}'
linux_build:
name: '02 - Linux'

View File

@ -1,5 +1,4 @@
brew "cmake"
brew "ccache"
brew "ninja"
brew "coreutils"
brew "xcbeautify"

View File

@ -79,9 +79,11 @@ check_ccache() {
CMAKE_CCACHE_OPTIONS="-DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache"
if [ "${CI}" ]; then
ccache --set-config=compiler_check=content
ccache --set-config=cache_dir=${GITHUB_WORKSPACE:-${HOME}}/.ccache
ccache --set-config=max_size=${CCACHE_SIZE:-500M}
ccache --set-config=compression=true
ccache --set-config=max_size=${CCACHE_SIZE:-1G}
ccache --set-config=compression=false
ccache --set-config=sloppiness=include_file_mtime,include_file_ctime,file_stat_matches,system_headers
ccache -z
fi
else

View File

@ -15,42 +15,35 @@ build_obs() {
status "Build OBS"
trap "caught_error 'build app'" ERR
if [ -z "${CI}" ]; then
_backup_artifacts
fi
step "Configure OBS..."
_configure_obs
ensure_dir "${CHECKOUT_DIR}/"
step "Build OBS targets..."
if [ "${PRESET}" != "macos-ci-${ARCH}" ]; then
export NSUnbufferedIO=YES
export NSUnbufferedIO=YES
: "${PACKAGE:=}"
case "${GITHUB_EVENT_NAME}" in
push) if [[ ${GITHUB_REF_NAME} =~ [0-9]+.[0-9]+.[0-9]+(-(rc|beta).+)? ]]; then PACKAGE=1; fi ;;
pull_request) PACKAGE=1 ;;
esac
: "${PACKAGE:=}"
case "${GITHUB_EVENT_NAME}" in
push) if [[ ${GITHUB_REF_NAME} =~ [0-9]+.[0-9]+.[0-9]+(-(rc|beta).+)? ]]; then PACKAGE=1; fi ;;
pull_request) PACKAGE=1 ;;
esac
pushd "build_${ARCH}" > /dev/null
pushd "build_macos" > /dev/null
if [[ "${PACKAGE}" && "${CODESIGN_IDENT:--}" != '-' ]]; then
set -o pipefail && xcodebuild -archivePath "obs-studio.xcarchive" -scheme obs-studio -destination "generic/platform=macOS,name=Any Mac'" archive 2>&1 | xcbeautify
set -o pipefail && xcodebuild -exportArchive -archivePath "obs-studio.xcarchive" -exportOptionsPlist "exportOptions.plist" -exportPath "." 2>&1 | xcbeautify
else
set -o pipefail && xcodebuild -scheme obs-studio -destination "generic/platform=macOS,name=Any Mac" -configuration RelWithDebInfo 2>&1 | xcbeautify
mkdir OBS.app
ditto UI/RelWithDebInfo/OBS.app OBS.app
fi
popd > /dev/null
unset NSUnbufferedIO
if [[ "${PACKAGE}" && "${CODESIGN_IDENT:--}" != '-' ]]; then
set -o pipefail && xcodebuild ONLY_ACTIVE_ARCH=NO -archivePath "obs-studio.xcarchive" -scheme obs-studio -destination "generic/platform=macOS,name=Any Mac" -parallelizeTargets -hideShellScriptEnvironment archive 2>&1 | xcbeautify
set -o pipefail && xcodebuild -exportArchive -archivePath "obs-studio.xcarchive" -exportOptionsPlist "exportOptions.plist" -exportPath "." 2>&1 | xcbeautify
else
cmake --build --preset macos-${ARCH}
set -o pipefail && xcodebuild ONLY_ACTIVE_ARCH=NO -project obs-studio.xcodeproj -target obs-studio -destination "generic/platform=macOS,name=Any Mac" -parallelizeTargets -configuration RelWithDebInfo -hideShellScriptEnvironment build 2>&1 | xcbeautify
rm -rf OBS.app && mkdir OBS.app
ditto UI/RelWithDebInfo/OBS.app OBS.app
fi
popd > /dev/null
unset NSUnbufferedIO
}
bundle_obs() {
@ -61,7 +54,7 @@ bundle_obs() {
step "Install OBS application bundle..."
find "build_${ARCH}/UI/${BUILD_CONFIG}" -type d -name "OBS.app" | xargs -I{} cp -r {} "build_${ARCH}"/
find "build_macos/UI/${BUILD_CONFIG}" -type d -name "OBS.app" | xargs -I{} cp -r {} "build_${ARCH}"/
}
# Function to configure OBS build
@ -91,30 +84,21 @@ _configure_obs() {
SPARKLE_OPTIONS="-DSPARKLE_APPCAST_URL=\"${SPARKLE_APPCAST_URL}\" -DSPARKLE_PUBLIC_KEY=\"${SPARKLE_PUBLIC_KEY}\""
fi
PRESET="macos-${ARCH}"
PRESET="macos"
if [ "${CI}" ]; then
case "${GITHUB_EVENT_NAME}" in
schedule) PRESET="macos-${ARCH}" ;;
push)
if [ "${GITHUB_REF_TYPE}" == 'tag' ]; then
PRESET="macos-release-${ARCH}"
else
PRESET="macos-ci-${ARCH}"
if [ "${GITHUB_REF_TYPE}" != 'tag' ]; then
PRESET="macos-ci"
fi
;;
pull_request)
if [ "${SEEKING_TESTERS}" == '1' ]; then
PRESET="macos-${ARCH}"
else
PRESET="macos-ci-${ARCH}"
fi
;;
*) PRESET="macos-ci-${ARCH}" ;;
*) PRESET="macos-ci" ;;
esac
fi
cmake -S . --preset ${PRESET} \
-DCMAKE_OSX_ARCHITECTURES=${ARCH} \
-DCMAKE_INSTALL_PREFIX=${BUILD_DIR}/install \
-DCMAKE_BUILD_TYPE=${BUILD_CONFIG} \
-DOBS_CODESIGN_IDENTITY="${CODESIGN_IDENT:--}" \
@ -127,32 +111,6 @@ _configure_obs() {
${QUIET:+-Wno-deprecated -Wno-dev --log-level=ERROR}
}
# Function to backup previous build artifacts
_backup_artifacts() {
ensure_dir "${CHECKOUT_DIR}"
if [ -d "${BUILD_DIR}" ]; then
status "Backup old OBS build artifacts"
CUR_DATE=$(/bin/date +"%Y-%m-%d@%H%M%S")
NIGHTLY_DIR="${CHECKOUT_DIR}/nightly-${CUR_DATE}"
PACKAGE_NAME=$(/usr/bin/find "${BUILD_DIR}" -name "*.dmg" -depth 1 | sort -rn | head -1)
if [ -d "${BUILD_DIR}/install/OBS.app" ]; then
step "Back up OBS.app..."
ensure_dir "${NIGHTLY_DIR}"
/bin/mv "${CHECKOUT_DIR}/${BUILD_DIR}/install/OBS.app" "${NIGHTLY_DIR}/"
info "You can find OBS.app in ${NIGHTLY_DIR}"
fi
if [ "${PACKAGE_NAME}" ]; then
step "Back up $(basename "${PACKAGE_NAME}")..."
ensure_dir "${NIGHTLY_DIR}"
/bin/mv "../${BUILD_DIR}/$(basename "${PACKAGE_NAME}")" "${NIGHTLY_DIR}/"
info "You can find ${PACKAGE_NAME} in ${NIGHTLY_DIR}"
fi
fi
}
build-obs-standalone() {
CHECKOUT_DIR="$(/usr/bin/git rev-parse --show-toplevel)"
PRODUCT_NAME="OBS-Studio"

View File

@ -22,7 +22,7 @@ package_obs() {
ensure_dir "${CHECKOUT_DIR}"
step "Package OBS..."
BUILD_DIR="build_${ARCH}"
BUILD_DIR="build_macos"
root_dir="$(pwd)"
@ -38,6 +38,8 @@ package_obs() {
hdiutil create -volname "${FILE_NAME//.dmg/}" -srcfolder "${FILE_NAME//.dmg/}" -ov -fs APFS -format UDRW temp.dmg
hdiutil attach -noverify -readwrite temp.dmg
SetFile -c icnC /Volumes/"${FILE_NAME//.dmg/}"/.VolumeIcon.icns
SetFile -a C /Volumes/"${FILE_NAME//.dmg/}"
osascript package.applescript "${FILE_NAME//.dmg/}"
hdiutil detach "/Volumes/${FILE_NAME//.dmg/}"
hdiutil convert -format ULMO -o "${FILE_NAME}" temp.dmg

View File

@ -8,93 +8,37 @@
"configurePresets": [
{
"name": "macos",
"hidden": true,
"displayName": "macOS",
"description": "Default macOS build (single architecture only)",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
},
"generator": "Xcode",
"binaryDir": "${sourceDir}/build_macos",
"cacheVariables": {
"ENABLE_BROWSER": true,
"CMAKE_OSX_DEPLOYMENT_TARGET": {"type": "STRING", "value": "11.0"},
"OBS_CMAKE_VERSION": {"type": "STRING", "value": "3.0.0"},
"OBS_CODESIGN_TEAM": {"type": "STRING", "value": "$penv{CODESIGN_TEAM}"},
"OBS_CODESIGN_IDENTITY": {"type": "STRING", "value": "$penv{CODESIGN_IDENT}"},
"OBS_PROVISIONING_PROFILE": {"type": "STRING", "value": "$penv{PROVISIONING_PROFILE}"},
"VIRTUALCAM_DEVICE_UUID": {"type": "STRING", "value": "7626645E-4425-469E-9D8B-97E0FA59AC75"},
"VIRTUALCAM_SOURCE_UUID": {"type": "STRING", "value": "A8D7B8AA-65AD-4D21-9C42-66480DBFA8E1"},
"VIRTUALCAM_SINK_UUID": {"type": "STRING", "value": "A3F16177-7044-4DD8-B900-72E2419F7A9A"},
"SPARKLE_APPCAST_URL": {"type": "STRING", "value": "https://obsproject.com/osx_update/updates_$(ARCHS)_v2.xml"},
"SPARKLE_PUBLIC_KEY": {"type": "STRING", "value": "HQ5/Ba9VHOuEWaM0jtVjZzgHKFJX9YTl+HNVpgNF0iM="}
}
},
{
"name": "macos-ci",
"displayName": "macOS (CI)",
"description": "CI macOS build (single architecture only)",
"inherits": ["macos"],
"warnings": {"dev": true, "deprecated": true},
"cacheVariables": {
"QT_VERSION": "6",
"ENABLE_BROWSER": true,
"ENABLE_VLC": true,
"CMAKE_OSX_DEPLOYMENT_TARGET": "11.0",
"OBS_CODESIGN_IDENTITY": "-",
"OBS_CMAKE_VERSION": "3.0.0"
}
},
{
"name": "macos-arm64",
"inherits": "macos",
"displayName": "macOS Apple Silicon",
"description": "obs-studio for macOS 11.0+ (Apple Silicon)",
"binaryDir": "${sourceDir}/build_arm64",
"cacheVariables": {
"CMAKE_OSX_ARCHITECTURES": "arm64"
}
},
{
"name": "macos-x86_64",
"inherits": "macos",
"displayName": "macOS Apple Intel",
"description": "obs-studio for macOS 11.0+ (Intel)",
"binaryDir": "${sourceDir}/build_x86_64",
"cacheVariables": {
"CMAKE_OSX_ARCHITECTURES": "x86_64"
}
},
{
"name": "macos-ci-arm64",
"inherits": ["macos-arm64"],
"generator": "Ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "macos-ci-x86_64",
"inherits": ["macos-x86_64"],
"generator": "Ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "macos-release-arm64",
"displayName": "macOS Apple Silicon (Release)",
"description": "obs-studio for macOS (Apple) - Release Configuration",
"inherits": ["macos-arm64"],
"cacheVariables": {
"ENABLE_RELEASE_BUILD": true,
"ENABLE_SPARKLE": true,
"OBS_SPARKLE_KEY": {"type": "STRING", "value": ""},
"OBS_CODESIGN_IDENTITY": "$penv{CODESIGN_IDENT}",
"OBS_CODESIGN_TEAM": "$penv{CODESIGN_TEAM}",
"SPARKLE_APPCAST_URL": {"type": "STRING", "value": "https://obsproject.com/osx_update/updates_arm64_v2.xml"},
"SPARKLE_PUBLIC_KEY": {"type": "STRING", "value": "HQ5/Ba9VHOuEWaM0jtVjZzgHKFJX9YTl+HNVpgNF0iM="},
"VIRTUALCAM_DEVICE_UUID": {"type": "STRING", "value": "7626645E-4425-469E-9D8B-97E0FA59AC75"},
"VIRTUALCAM_SOURCE_UUID": {"type": "STRING", "value": "A8D7B8AA-65AD-4D21-9C42-66480DBFA8E1"},
"VIRTUALCAM_SINK_UUID": {"type": "STRING", "value": "A3F16177-7044-4DD8-B900-72E2419F7A9A"}
}
},
{
"name": "macos-release-x86_64",
"displayName": "macOS Intel (Release)",
"description": "obs-studio for macOS (Intel) - Release Configuration",
"inherits": ["macos-x86_64"],
"cacheVariables": {
"ENABLE_RELEASE_BUILD": true,
"ENABLE_SPARKLE": true,
"OBS_SPARKLE_KEY": {"type": "STRING", "value": ""},
"OBS_CODESIGN_IDENTITY": "$penv{CODESIGN_IDENT}",
"OBS_CODESIGN_TEAM": "$penv{CODESIGN_TEAM}",
"SPARKLE_APPCAST_URL": {"type": "STRING", "value": "https://obsproject.com/osx_update/updates_x86_64_v2.xml"},
"SPARKLE_PUBLIC_KEY": {"type": "STRING", "value": "HQ5/Ba9VHOuEWaM0jtVjZzgHKFJX9YTl+HNVpgNF0iM="},
"VIRTUALCAM_DEVICE_UUID": {"type": "STRING", "value": "7626645E-4425-469E-9D8B-97E0FA59AC75"},
"VIRTUALCAM_SOURCE_UUID": {"type": "STRING", "value": "A8D7B8AA-65AD-4D21-9C42-66480DBFA8E1"},
"VIRTUALCAM_SINK_UUID": {"type": "STRING", "value": "A3F16177-7044-4DD8-B900-72E2419F7A9A"}
"CMAKE_COMPILE_WARNING_AS_ERROR": true
}
},
{
@ -239,20 +183,6 @@
}
],
"buildPresets": [
{
"name": "macos-arm64",
"configurePreset": "macos-arm64",
"displayName": "macOS Apple Silicon",
"description": "macOS build for Apple Silicon",
"configuration": "RelWithDebInfo"
},
{
"name": "macos-x86_64",
"configurePreset": "macos-x86_64",
"displayName": "macOS Intel",
"description": "macOS build for Intel",
"configuration": "RelWithDebInfo"
},
{
"name": "linux-aarch64",
"configurePreset": "linux-aarch64",

View File

@ -5,8 +5,6 @@
"baseUrl": "https://github.com/obsproject/obs-deps/releases/download",
"label": "Pre-Built obs-deps",
"hashes": {
"macos-x86_64": "fdd3f85f597cb8237041673f4cb0b0908d548791126cfd0d12fa7886bea3745f",
"macos-arm64": "17a954636998b07355c66a3d242191bfde75467985cc64ab3c292859b1f54d28",
"macos-universal": "ecbfba9473abced9bd16ef2ac29ed61ce036c10a3135039d464a7611daf27fb8",
"windows-x64": "cacb858777edaa0251b90350192d175b9b977f186f872a16d1e6b67fc5b4f9f0",
"linux-x86_64": "b97ed74fde7a01ba8e90916318733e0d0bf89ed30e84a53d1ccd425f4afe5d7f"
@ -17,8 +15,6 @@
"baseUrl": "https://github.com/obsproject/obs-deps/releases/download",
"label": "Pre-Built Qt6",
"hashes": {
"macos-x86_64": "b874b9aefbb42e586661c8cc652c889413dd68ff683307de54af8074139e69ab",
"macos-arm64": "e95d6461b8cafea6125aa82e3f9888eea5c5101a3911e88543631fadeb5faa9f",
"macos-universal": "5c1880af8fe8e6a0e85924952e8c756410c37e6f13e36667be86cd0979a2ae8b",
"windows-x64": "aa77caa98d34263a97e0bd0435a18e5c981e915636af562557bb4bf09d49be04"
},
@ -52,20 +48,8 @@
}
},
"platformConfig": {
"macos-x86_64": {
"qtVersion": 6,
"deploymentTarget": "11.0",
"buildTarget": "11.0"
},
"macos-arm64": {
"qtVersion": 6,
"deploymentTarget": "11.0",
"buildTarget": "11.0"
},
"macos-universal": {
"qtVersion": 6,
"deploymentTarget": "11.0",
"buildTarget": "11.0"
"qtVersion": 6
},
"windows-x64": {
"qtVersion": 6

View File

@ -0,0 +1,172 @@
# OBS common build dependencies module
# cmake-format: off
# cmake-lint: disable=C0103
# cmake-lint: disable=E1126
# cmake-lint: disable=R0912
# cmake-lint: disable=R0915
# cmake-format: on
include_guard(GLOBAL)
# _check_deps_version: Checks for obs-deps VERSION file in prefix paths
function(_check_deps_version version)
# cmake-format: off
set(found FALSE PARENT_SCOPE)
# cmake-format: on
foreach(path IN LISTS CMAKE_PREFIX_PATH)
if(EXISTS "${path}/share/obs-deps/VERSION")
if(dependency STREQUAL qt6 AND NOT EXISTS "${path}/lib/cmake/Qt6/Qt6Config.cmake")
# cmake-format: off
set(found FALSE PARENT_SCOPE)
# cmake-format: on
continue()
endif()
file(READ "${path}/share/obs-deps/VERSION" _check_version)
string(REPLACE "\n" "" _check_version "${_check_version}")
string(REPLACE "-" "." _check_version "${_check_version}")
string(REPLACE "-" "." version "${version}")
if(_check_version VERSION_EQUAL version)
# cmake-format: off
set(found TRUE PARENT_SCOPE)
# cmake-format: on
break()
elseif(_check_version VERSION_LESS version)
message(AUTHOR_WARNING "Older ${label} version detected in ${path}: \n"
"Found ${_check_version}, require ${version}")
list(REMOVE_ITEM CMAKE_PREFIX_PATH "${path}")
list(APPEND CMAKE_PREFIX_PATH "${path}")
# cmake-format: off
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} PARENT_SCOPE)
# cmake-format: on
continue()
else()
message(AUTHOR_WARNING "Newer ${label} version detected in ${path}: \n"
"Found ${_check_version}, require ${version}")
# cmake-format: off
set(found TRUE PARENT_SCOPE)
# cmake-format: on
break()
endif()
endif()
endforeach()
endfunction()
# _check_dependencies: Fetch and extract pre-built OBS build dependencies
function(_check_dependencies)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/buildspec.json" buildspec)
# cmake-format: off
string(JSON dependency_data GET ${buildspec} dependencies)
# cmake-format: on
foreach(dependency IN LISTS dependencies_list)
if(dependency STREQUAL cef AND arch STREQUAL universal)
if(CMAKE_OSX_ARCHITECTURES MATCHES ".+;.+")
continue()
endif()
set(arch ${CMAKE_OSX_ARCHITECTURES})
set(platform macos-${arch})
endif()
# cmake-format: off
string(JSON data GET ${dependency_data} ${dependency})
string(JSON version GET ${data} version)
string(JSON hash GET ${data} hashes ${platform})
string(JSON url GET ${data} baseUrl)
string(JSON label GET ${data} label)
string(JSON revision ERROR_VARIABLE error GET ${data} revision ${platform})
# cmake-format: on
message(STATUS "Setting up ${label} (${arch})")
set(file "${${dependency}_filename}")
set(destination "${${dependency}_destination}")
string(REPLACE "VERSION" "${version}" file "${file}")
string(REPLACE "VERSION" "${version}" destination "${destination}")
string(REPLACE "ARCH" "${arch}" file "${file}")
string(REPLACE "ARCH" "${arch}" destination "${destination}")
if(revision)
string(REPLACE "_REVISION" "_v${revision}" file "${file}")
string(REPLACE "-REVISION" "-v${revision}" file "${file}")
else()
string(REPLACE "_REVISION" "" file "${file}")
string(REPLACE "-REVISION" "" file "${file}")
endif()
set(skip FALSE)
if(dependency STREQUAL prebuilt OR dependency STREQUAL qt6)
_check_deps_version(${version})
if(found)
set(skip TRUE)
endif()
elseif(dependency STREQUAL cef)
if(NOT ENABLE_BROWSER OR (CEF_ROOT_DIR AND EXISTS "${CEF_ROOT_DIR}"))
set(skip TRUE)
endif()
endif()
if(skip)
message(STATUS "Setting up ${label} (${arch}) - skipped")
continue()
endif()
if(dependency STREQUAL cef)
set(url ${url}/${file})
else()
set(url ${url}/${version}/${file})
endif()
if(NOT EXISTS "${dependencies_dir}/${file}")
message(STATUS "Downloading ${url}")
file(
DOWNLOAD "${url}" "${dependencies_dir}/${file}"
STATUS download_status
EXPECTED_HASH SHA256=${hash})
list(GET download_status 0 error_code)
list(GET download_status 1 error_message)
if(error_code GREATER 0)
message(STATUS "Downloading ${url} - Failure")
message(FATAL_ERROR "Unable to download ${url}, failed with error: ${error_message}")
file(REMOVE "${dependencies_dir}/${file}")
else()
message(STATUS "Downloading ${url} - done")
endif()
endif()
if(NOT EXISTS "${dependencies_dir}/${destination}")
file(MAKE_DIRECTORY "${dependencies_dir}/${destination}")
if(dependency STREQUAL obs-studio)
file(ARCHIVE_EXTRACT INPUT "${dependencies_dir}/${file}" DESTINATION "${dependencies_dir}")
else()
file(ARCHIVE_EXTRACT INPUT "${dependencies_dir}/${file}" DESTINATION "${dependencies_dir}/${destination}")
endif()
endif()
if(dependency STREQUAL prebuilt)
set(VLC_PATH
"${dependencies_dir}/${destination}"
CACHE PATH "VLC source code directory" FORCE)
list(APPEND CMAKE_PREFIX_PATH "${dependencies_dir}/${destination}")
elseif(dependency STREQUAL qt6)
list(APPEND CMAKE_PREFIX_PATH "${dependencies_dir}/${destination}")
elseif(dependency STREQUAL cef)
set(CEF_ROOT_DIR
"${dependencies_dir}/${destination}"
CACHE PATH "CEF root directory" FORCE)
endif()
message(STATUS "Setting up ${label} (${arch}) - done")
endforeach()
list(REMOVE_DUPLICATES CMAKE_PREFIX_PATH)
# cmake-format: off
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} CACHE PATH "CMake prefix search path" FORCE)
# cmake-format: on
endfunction()

View File

@ -1,68 +1,16 @@
# OBS CMake macOS build dependencies module
# cmake-format: off
# cmake-lint: disable=E1126
# cmake-lint: disable=R0912
# cmake-lint: disable=R0915
# cmake-format: on
include_guard(GLOBAL)
# _check_deps_version: Checks for obs-deps VERSION file in prefix paths
macro(_check_deps_version version)
set(found FALSE)
include(buildspec_common)
foreach(path IN LISTS CMAKE_PREFIX_PATH)
if(EXISTS "${path}/share/obs-deps/VERSION")
if(dependency STREQUAL qt6 AND NOT EXISTS "${path}/lib/cmake/Qt6/Qt6Config.cmake")
set(found FALSE)
continue()
endif()
file(READ "${path}/share/obs-deps/VERSION" _check_version)
string(REPLACE "\n" "" _check_version "${_check_version}")
string(REPLACE "-" "." _check_version "${_check_version}")
string(REPLACE "-" "." version "${version}")
if(_check_version VERSION_EQUAL version)
set(found TRUE)
break()
elseif(_check_version VERSION_LESS version)
message(AUTHOR_WARNING "Outdated ${label} version detected in ${path}: \n"
"Found ${_check_version}, require ${version}")
list(REMOVE_ITEM CMAKE_PREFIX_PATH "${path}")
list(APPEND CMAKE_PREFIX_PATH "${path}")
continue()
else()
message(AUTHOR_WARNING "Future ${label} version detected in ${path}: \n"
"Found ${_check_version}, require ${version}")
set(found TRUE)
break()
endif()
endif()
endforeach()
endmacro()
# _check_dependencies: Fetch and extract pre-built OBS build dependencies
function(_check_dependencies)
if(CMAKE_OSX_ARCHITECTURES MATCHES ".+;.+")
set(arch universal)
else()
set(arch ${CMAKE_OSX_ARCHITECTURES})
endif()
# _check_dependencies_macos: Set up macOS slice for _check_dependencies
function(_check_dependencies_macos)
set(arch universal)
set(platform macos-${arch})
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/buildspec.json" buildspec)
# cmake-format: off
string(JSON deployment_target GET ${buildspec} platformConfig macos-${arch} deploymentTarget)
string(JSON dependency_data GET ${buildspec} dependencies)
# cmake-format: on
if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET
${_deployment_target}
CACHE STRING "Minimum macOS version to target for deployment (at runtime). Newer APIs will be weak-linked."
FORCE)
endif()
set(dependencies_dir "${CMAKE_CURRENT_SOURCE_DIR}/.deps")
set(prebuilt_filename "macos-deps-VERSION-ARCH-REVISION.tar.xz")
set(prebuilt_destination "obs-deps-VERSION-ARCH")
@ -70,130 +18,12 @@ function(_check_dependencies)
set(qt6_destination "obs-deps-qt6-VERSION-ARCH")
set(cef_filename "cef_binary_VERSION_macos_ARCH_REVISION.tar.xz")
set(cef_destination "cef_binary_VERSION_macos_ARCH")
set(dependencies_list prebuilt qt6 cef)
foreach(dependency IN ITEMS prebuilt qt6 cef)
if(dependency STREQUAL cef AND arch STREQUAL universal)
continue()
endif()
_check_dependencies()
# cmake-format: off
string(JSON data GET ${dependency_data} ${dependency})
string(JSON version GET ${data} version)
string(JSON hash GET ${data} hashes macos-${arch})
string(JSON url GET ${data} baseUrl)
string(JSON label GET ${data} label)
string(JSON revision ERROR_VARIABLE error GET ${data} revision macos-${arch})
# cmake-format: on
message(STATUS "Setting up ${label}")
set(file "${${dependency}_filename}")
set(destination "${${dependency}_destination}")
string(REPLACE "VERSION" "${version}" file "${file}")
string(REPLACE "VERSION" "${version}" destination "${destination}")
string(REPLACE "ARCH" "${arch}" file "${file}")
string(REPLACE "ARCH" "${arch}" destination "${destination}")
if(revision)
string(REPLACE "_REVISION" "_v${revision}" file "${file}")
string(REPLACE "-REVISION" "-v${revision}" file "${file}")
else()
string(REPLACE "_REVISION" "" file "${file}")
string(REPLACE "-REVISION" "" file "${file}")
endif()
set(skip FALSE)
if(dependency STREQUAL prebuilt OR dependency STREQUAL qt6)
_check_deps_version(${version})
if(found)
set(skip TRUE)
endif()
elseif(_dependency STREQUAL sparkle)
find_library(SPARKLE Sparkle)
if(NOT ENABLE_SPARKLE OR SPARKLE)
set(skip TRUE)
else()
unset(SPARKLE CACHE)
endif()
elseif(dependency STREQUAL vlc)
if(NOT ENABLE_VLC OR (VLC_PATH AND EXISTS "${VLC_PATH}"))
set(skip TRUE)
endif()
elseif(dependency STREQUAL cef)
if(NOT ENABLE_BROWSER OR (CEF_ROOT_DIR AND EXISTS "${CEF_ROOT_DIR}"))
set(skip TRUE)
endif()
endif()
if(skip)
message(STATUS "Setting up ${label} - skipped")
continue()
endif()
if(dependency STREQUAL qt6 AND "$ENV{CI}")
# cmake-format: off
string(JSON hash GET ${buildspec} dependencies qt6 hashes macos-universal)
# cmake-format: on
string(REPLACE "${arch}" "universal" file "${file}")
endif()
if(dependency STREQUAL cef)
set(url ${url}/${file})
else()
set(url ${url}/${version}/${file})
endif()
if(NOT EXISTS "${dependencies_dir}/${file}")
message(STATUS "Downloading ${url}")
file(
DOWNLOAD "${url}" "${dependencies_dir}/${file}"
STATUS download_status
EXPECTED_HASH SHA256=${hash})
list(GET download_status 0 error_code)
list(GET download_status 1 error_message)
if(error_code GREATER 0)
message(STATUS "Downloading ${url} - Failure")
message(FATAL_ERROR "Unable to download ${url}, failed with error: ${error_message}")
file(REMOVE "${dependencies_dir}/${file}")
else()
message(STATUS "Downloading ${url} - done")
endif()
endif()
if(NOT EXISTS "${dependencies_dir}/${destination}")
file(MAKE_DIRECTORY "${dependencies_dir}/${destination}")
if(dependency STREQUAL vlc)
file(ARCHIVE_EXTRACT INPUT "${dependencies_dir}/${file}" DESTINATION "${dependencies_dir}")
else()
file(ARCHIVE_EXTRACT INPUT "${dependencies_dir}/${file}" DESTINATION "${dependencies_dir}/${destination}")
endif()
execute_process(COMMAND "xattr" -r -d com.apple.quarantine "${dependencies_dir}/${destination}"
RESULT_VARIABLE result COMMAND_ERROR_IS_FATAL ANY)
endif()
if(dependency STREQUAL cef)
set(CEF_ROOT_DIR
"${dependencies_dir}/${destination}"
CACHE PATH "CEF Root directory" FORCE)
elseif(dependency STREQUAL prebuilt)
set(VLC_PATH
"${dependencies_dir}/${destination}"
CACHE PATH "VLC source code directory" FORCE)
list(APPEND CMAKE_PREFIX_PATH "${dependencies_dir}/${destination}")
elseif(dependency STREQUAL qt6)
list(APPEND CMAKE_PREFIX_PATH "${dependencies_dir}/${destination}")
endif()
message(STATUS "Setting up ${label} - done")
endforeach()
list(REMOVE_DUPLICATES CMAKE_PREFIX_PATH)
set(CMAKE_PREFIX_PATH
${CMAKE_PREFIX_PATH}
CACHE PATH "CMake prefix search path" FORCE)
execute_process(COMMAND "xattr" -r -d com.apple.quarantine "${dependencies_dir}/${destination}"
RESULT_VARIABLE result COMMAND_ERROR_IS_FATAL ANY)
endfunction()
_check_dependencies()
_check_dependencies_macos()

View File

@ -28,34 +28,6 @@ endif()
include(buildspec)
# Set default deployment target to 11.0 if not set and enable selection in GUI up to 13.0
if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET
11.0
CACHE STRING "Minimum macOS version to target for deployment (at runtime). Newer APIs will be weak-linked." FORCE)
endif()
set_property(CACHE CMAKE_OSX_DEPLOYMENT_TARGET PROPERTY STRINGS 13.0 12.0 11.0)
# Use Applications directory as default install destination
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX
"/Applications"
CACHE STRING "Directory to install OBS after building" FORCE)
endif()
# Show warning about missing CMAKE_PREFIX_PATH, usually required for successful builds
if(NOT DEFINED CMAKE_PREFIX_PATH)
message(
WARNING "No CMAKE_PREFIX_PATH set: OBS supplies pre-built dependencies for building on macOS.\n"
"While OBS can be built using packages installed via Homebrew, pre-built dependencies "
"contain beneficial patches and fixes for use within OBS and is the suggested source "
"of these dependencies.\n"
"You can download the appropriate obs-deps package for your "
"architecture and set CMAKE_PREFIX_PATH to this directory:\n"
"CMAKE_PREFIX_PATH=\"<PATH_TO_OBS_DEPS>\"\n"
"Download pre-built OBS dependencies at https://github.com/obsproject/obs-deps/releases\n")
endif()
# SWIG hard codes the directory to its library directory at compile time. As obs-deps need to be relocatable, we need to
# force SWIG to look for its files in a directory relative to the PREFIX_PATH. The best way to ensure this is to set the
# SWIG_LIB environment variable.

View File

@ -89,9 +89,27 @@ function(set_target_properties_obs target)
if(VIRTUALCAM_DEVICE_UUID
AND VIRTUALCAM_SOURCE_UUID
AND VIRTUALCAM_SINK_UUID)
set(entitlements_file "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/entitlements-extension.plist")
set(has_virtualcam_uuids TRUE)
else()
set(entitlements_file "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/entitlements.plist")
set(has_virtualcam_uuids FALSE)
endif()
if(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_STYLE STREQUAL Automatic)
if(has_virtualcam_uuids)
set(entitlements_file "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/entitlements-extension.plist")
else()
set(entitlements_file "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/entitlements.plist")
endif()
else()
if(has_virtualcam_uuids AND OBS_PROVISIONING_PROFILE)
set(entitlements_file "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/entitlements-extension.plist")
set_target_properties(${target} PROPERTIES XCODE_ATTRIBUTE_PROVISIONING_PROFILE_SPECIFIER
"${OBS_PROVISIONING_PROFILE}")
configure_file(cmake/macos/exportOptions-extension.plist.in ${CMAKE_BINARY_DIR}/exportOptions.plist)
else()
set(entitlements_file "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/entitlements.plist")
configure_file(cmake/macos/exportOptions.plist.in ${CMAKE_BINARY_DIR}/exportOptions.plist)
endif()
endif()
if(NOT EXISTS "${entitlements_file}")
@ -100,14 +118,6 @@ function(set_target_properties_obs target)
set_target_properties(${target} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "${entitlements_file}")
if(NOT CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_STYLE STREQUAL "Automatic")
set_target_properties(${target} PROPERTIES XCODE_ATTRIBUTE_PROVISIONING_PROFILE_SPECIFIER
"${OBS_PROVISIONING_PROFILE}")
configure_file(cmake/macos/exportOptions-extension.plist.in ${CMAKE_BINARY_DIR}/exportOptions.plist)
else()
configure_file(cmake/macos/exportOptions.plist.in ${CMAKE_BINARY_DIR}/exportOptions.plist)
endif()
add_custom_command(
TARGET ${target}
POST_BUILD
@ -152,7 +162,9 @@ function(set_target_properties_obs target)
COMMENT "Add OBS::python import module")
endif()
if(TARGET mac-camera-extension)
if(TARGET mac-camera-extension AND (CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_STYLE STREQUAL Automatic
OR OBS_PROVISIONING_PROFILE))
target_enable_feature(mac-camera-extension "macOS CMIO Camera Extension")
add_custom_command(
TARGET ${target}
POST_BUILD
@ -160,6 +172,8 @@ function(set_target_properties_obs target)
"${CMAKE_COMMAND}" -E copy_directory "$<TARGET_BUNDLE_DIR:mac-camera-extension>"
"$<TARGET_BUNDLE_CONTENT_DIR:${target}>/Library/SystemExtensions/$<TARGET_BUNDLE_DIR_NAME:mac-camera-extension>"
COMMENT "Add Camera Extension to application bundle")
else()
target_disable_feature(mac-camera-extension "macOS CMIO Camera Extension")
endif()
_bundle_dependencies(${target})
@ -395,8 +409,7 @@ function(_bundle_dependencies target)
find_qt_plugins(COMPONENT ${library} TARGET ${target} FOUND_VAR plugins_list)
endif()
list(APPEND library_paths ${library_location})
elseif(NOT imported AND library_type STREQUAL "SHARED_LIBRARY")
message(TRACE "${library} is a project target")
elseif(NOT is_imported AND library_type STREQUAL "SHARED_LIBRARY")
list(APPEND library_paths ${library})
endif()
endforeach()