fix(build): ensure libopus is statically linked (#4819)
This commit is contained in:
3
.github/workflows/ci-macos.yml
vendored
3
.github/workflows/ci-macos.yml
vendored
@@ -130,7 +130,8 @@ jobs:
|
|||||||
--apple-id "${APPLE_ID}" \
|
--apple-id "${APPLE_ID}" \
|
||||||
--team-id "${APPLE_TEAM_ID}" \
|
--team-id "${APPLE_TEAM_ID}" \
|
||||||
--password "${APPLE_NOTARYTOOL_PASSWORD}" \
|
--password "${APPLE_NOTARYTOOL_PASSWORD}" \
|
||||||
--wait
|
--wait \
|
||||||
|
--timeout 15m
|
||||||
xcrun stapler staple -v build/cpack_artifacts/Sunshine.dmg
|
xcrun stapler staple -v build/cpack_artifacts/Sunshine.dmg
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ set(Opus_ROOT_DIR # cmake-lint: disable=C0103
|
|||||||
"${Opus_ROOT_DIR}"
|
"${Opus_ROOT_DIR}"
|
||||||
CACHE PATH "Root to search for opus")
|
CACHE PATH "Root to search for opus")
|
||||||
|
|
||||||
|
option(OPUS_USE_STATIC "Prefer linking against a static Opus library" OFF)
|
||||||
|
|
||||||
# Todo: handle in-tree/fetch-content builds?
|
# Todo: handle in-tree/fetch-content builds?
|
||||||
|
|
||||||
if(NOT OPUS_FOUND)
|
if(NOT OPUS_FOUND)
|
||||||
@@ -62,6 +64,17 @@ if(NOT ANDROID)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(_opus_library_names opus)
|
||||||
|
if(OPUS_USE_STATIC)
|
||||||
|
set(_opus_library_names libopus opus)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Temporarily prefer static suffixes when requested.
|
||||||
|
set(_old_find_suffixes "${CMAKE_FIND_LIBRARY_SUFFIXES}")
|
||||||
|
if(OPUS_USE_STATIC)
|
||||||
|
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" ".lib" ${_old_find_suffixes})
|
||||||
|
endif()
|
||||||
|
|
||||||
find_path(
|
find_path(
|
||||||
Opus_INCLUDE_DIR
|
Opus_INCLUDE_DIR
|
||||||
NAMES opus/opus.h
|
NAMES opus/opus.h
|
||||||
@@ -70,11 +83,13 @@ find_path(
|
|||||||
PATH_SUFFIXES include)
|
PATH_SUFFIXES include)
|
||||||
find_library(
|
find_library(
|
||||||
Opus_LIBRARY
|
Opus_LIBRARY
|
||||||
NAMES opus
|
NAMES ${_opus_library_names}
|
||||||
PATHS ${Opus_ROOT_DIR}
|
PATHS ${Opus_ROOT_DIR}
|
||||||
HINTS ${PC_opus_LIBRARY_DIRS}
|
HINTS ${PC_opus_LIBRARY_DIRS}
|
||||||
PATH_SUFFIXES lib)
|
PATH_SUFFIXES lib)
|
||||||
|
|
||||||
|
set(CMAKE_FIND_LIBRARY_SUFFIXES "${_old_find_suffixes}")
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(Opus REQUIRED_VARS Opus_LIBRARY
|
find_package_handle_standard_args(Opus REQUIRED_VARS Opus_LIBRARY
|
||||||
Opus_INCLUDE_DIR)
|
Opus_INCLUDE_DIR)
|
||||||
@@ -85,7 +100,11 @@ if(Opus_FOUND)
|
|||||||
add_library(Opus::opus ALIAS ${Opus_LIBRARY})
|
add_library(Opus::opus ALIAS ${Opus_LIBRARY})
|
||||||
else()
|
else()
|
||||||
# we want an imported target
|
# we want an imported target
|
||||||
add_library(Opus::opus UNKNOWN IMPORTED)
|
if(OPUS_USE_STATIC)
|
||||||
|
add_library(Opus::opus STATIC IMPORTED)
|
||||||
|
else()
|
||||||
|
add_library(Opus::opus UNKNOWN IMPORTED)
|
||||||
|
endif()
|
||||||
|
|
||||||
set_target_properties(
|
set_target_properties(
|
||||||
Opus::opus
|
Opus::opus
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ include_directories(SYSTEM ${MINIUPNP_INCLUDE_DIRS})
|
|||||||
include("${CMAKE_MODULE_PATH}/dependencies/ffmpeg.cmake")
|
include("${CMAKE_MODULE_PATH}/dependencies/ffmpeg.cmake")
|
||||||
|
|
||||||
# Opus
|
# Opus
|
||||||
|
set(OPUS_USE_STATIC ON CACHE BOOL "Static linking for libopus")
|
||||||
include("${CMAKE_MODULE_PATH}/dependencies/FindOpus.cmake")
|
include("${CMAKE_MODULE_PATH}/dependencies/FindOpus.cmake")
|
||||||
|
|
||||||
# platform specific dependencies
|
# platform specific dependencies
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ build_docs="OFF"
|
|||||||
build_tests="ON"
|
build_tests="ON"
|
||||||
build_type="Release"
|
build_type="Release"
|
||||||
sign_app="true"
|
sign_app="true"
|
||||||
|
notarize="true"
|
||||||
|
|
||||||
# environment variables
|
# environment variables
|
||||||
# BUILD_VERSION should be empty or cmake will assume a CI build
|
# BUILD_VERSION should be empty or cmake will assume a CI build
|
||||||
@@ -66,6 +67,7 @@ Options:
|
|||||||
--build-docs Build docs.
|
--build-docs Build docs.
|
||||||
--skip-tests Don't build the test suite.
|
--skip-tests Don't build the test suite.
|
||||||
--skip-codesign Don't sign/notarize the bundle.
|
--skip-codesign Don't sign/notarize the bundle.
|
||||||
|
--skip-notarize Don't notarize the dmg.
|
||||||
|
|
||||||
Steps:
|
Steps:
|
||||||
deps Install dependencies only
|
deps Install dependencies only
|
||||||
@@ -147,8 +149,11 @@ function run_step_dmg() {
|
|||||||
|
|
||||||
cpack -G DragNDrop --config "${build_dir}/CPackConfig.cmake" --verbose
|
cpack -G DragNDrop --config "${build_dir}/CPackConfig.cmake" --verbose
|
||||||
|
|
||||||
if [[ -n "${sign_app}" ]]; then
|
if [[ -n "${sign_app}" && -n "${notarize}" ]]; then
|
||||||
xcrun notarytool submit "${build_dir}/cpack_artifacts/Sunshine.dmg" --keychain-profile "notarytool-password" --wait
|
time xcrun notarytool submit "${build_dir}/cpack_artifacts/Sunshine.dmg" \
|
||||||
|
--keychain-profile "notarytool-password" \
|
||||||
|
--wait \
|
||||||
|
--timeout 15m
|
||||||
xcrun stapler staple -v "${build_dir}/cpack_artifacts/Sunshine.dmg"
|
xcrun stapler staple -v "${build_dir}/cpack_artifacts/Sunshine.dmg"
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
@@ -216,6 +221,9 @@ while getopts ":h-:" opt; do
|
|||||||
skip-codesign)
|
skip-codesign)
|
||||||
sign_app=""
|
sign_app=""
|
||||||
;;
|
;;
|
||||||
|
skip-notarize)
|
||||||
|
notarize=""
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Invalid option: --${OPTARG}" 1>&2
|
echo "Invalid option: --${OPTARG}" 1>&2
|
||||||
_usage 1
|
_usage 1
|
||||||
|
|||||||
Reference in New Issue
Block a user