Skip to content

Commit

Permalink
Fix build error
Browse files Browse the repository at this point in the history
  • Loading branch information
xfangfang committed Jun 29, 2024
1 parent 876e9c7 commit 26cddfb
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 48 deletions.
28 changes: 2 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,9 @@ list(APPEND APP_PLATFORM_LIB ${CMAKE_THREAD_LIBS_INIT})

# Find libmpv and libwebp
if (MAC_DOWNLOAD_DYLIB)
if (NOT DISABLE_WEBP)
list(APPEND APP_PLATFORM_OPTION -DUSE_WEBP)
list(APPEND APP_PLATFORM_LIB ${CMAKE_BINARY_DIR}/deps/lib/libwebp.7.1.9.dylib)
endif ()

list(APPEND APP_PLATFORM_LIB
${CMAKE_BINARY_DIR}/deps/lib/libmpv.2.dylib
${CMAKE_BINARY_DIR}/deps/lib/libboost_filesystem-mt.dylib
${CMAKE_BINARY_DIR}/deps/lib/libssl.3.dylib
${CMAKE_BINARY_DIR}/deps/lib/libcrypto.3.dylib)
list(APPEND APP_PLATFORM_INCLUDE
${CMAKE_BINARY_DIR}/deps/include)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos.cmake)
list(APPEND CMAKE_MODULE_PATH
${CMAKE_BINARY_DIR}/deps/cmake)
${CMAKE_BINARY_DIR}/deps/lib/cmake)
elseif (PLATFORM_DESKTOP)
find_package(MPV REQUIRED)
message(STATUS "Found libmpv: ${MPV_VERSION} ${MPV_INCLUDE_DIR} ${MPV_LIBRARY}")
Expand Down Expand Up @@ -233,19 +222,6 @@ if (PLATFORM_DESKTOP)

if (APPLE)
if (MAC_DOWNLOAD_DYLIB)
# download deps
if (MAC_IntelChip)
set(MAC_OS_ARCH x86_64)
elseif (MAC_AppleSilicon)
set(MAC_OS_ARCH arm64)
elseif (MAC_Universal)
set(MAC_OS_ARCH universal)
endif ()
add_custom_target(
${PROJECT_NAME}.macos_${MAC_OS_ARCH}_deps
COMMAND "bash" "${CMAKE_SOURCE_DIR}/scripts/macos_dylib_downloader.sh" "${MAC_OS_ARCH}"
)
add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}.macos_${MAC_OS_ARCH}_deps)
set(bundle_args1 "-nb")
set(bundle_args2 "${CMAKE_BINARY_DIR}/deps/lib")
else ()
Expand Down
44 changes: 44 additions & 0 deletions cmake/macos.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Download precompiled dylib dependencies
# arm64: 11.0
# x86_64: 10.11
# universal: arm64 + x86_64

if (APPLE)

if (MAC_IntelChip)
set(MAC_OS_ARCH x86_64)
elseif (MAC_AppleSilicon)
set(MAC_OS_ARCH arm64)
elseif (MAC_Universal)
set(MAC_OS_ARCH universal)
endif ()

if (NOT DISABLE_WEBP)
list(APPEND APP_PLATFORM_OPTION -DUSE_WEBP)
list(APPEND APP_PLATFORM_LIB ${CMAKE_BINARY_DIR}/deps/lib/libwebp.7.1.9.dylib)
endif ()

list(APPEND APP_PLATFORM_LIB
${CMAKE_BINARY_DIR}/deps/lib/libmpv.2.dylib
${CMAKE_BINARY_DIR}/deps/lib/libboost_filesystem-mt.dylib
${CMAKE_BINARY_DIR}/deps/lib/libssl.3.dylib
${CMAKE_BINARY_DIR}/deps/lib/libcrypto.3.dylib)
list(APPEND APP_PLATFORM_INCLUDE
${CMAKE_BINARY_DIR}/deps/include)

# download deps
include(FetchContent)
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()
FetchContent_Declare(macos_prebuild
URL "https://github.com/xfangfang/wiliwili/releases/download/v0.1.0/macos_dylib_ffmpeg7_mpv38_${MAC_OS_ARCH}.tar.gz"
)
if (NOT macos_prebuild_POPULATED)
FetchContent_POPULATE(macos_prebuild)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/deps)
file(COPY ${macos_prebuild_SOURCE_DIR}/lib DESTINATION ${CMAKE_BINARY_DIR}/deps)
file(COPY ${macos_prebuild_SOURCE_DIR}/include DESTINATION ${CMAKE_BINARY_DIR}/deps)
endif()

endif ()
3 changes: 2 additions & 1 deletion scripts/build_mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ else
bundle_deps="-b"
else
echo "bundle deps: $2"
cp -r "$2" "${APP_PATH}"/Contents/MacOS/lib
mkdir -p "${APP_PATH}"/Contents/MacOS/lib
cp "$2"/*.dylib "${APP_PATH}"/Contents/MacOS/lib
fi
dylibbundler -cd ${bundle_deps} -x "${APP_PATH}"/Contents/MacOS/wiliwili \
-d "${APP_PATH}"/Contents/MacOS/lib/ -p @executable_path/lib/
Expand Down
20 changes: 0 additions & 20 deletions scripts/macos_dylib_downloader.sh

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/macos_dylib_include.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cd "$(dirname "$0")/.." || exit
rm -rf include
mkdir -p include

boost_item=("filesystem" "system" "config" "assert" "type_traits" "mpl" "preprocessor" "static_assert" "core" "detail" "io" "functional" "container_hash" "smart_ptr")
boost_item=("filesystem" "system" "config" "assert" "iterator" "type_traits" "mpl" "preprocessor" "static_assert" "core" "detail" "io" "functional" "container_hash" "smart_ptr")
for item in "${boost_item[@]}"
do
url="https://github.com/boostorg/$item/archive/refs/tags/boost-$boost_version.zip"
Expand Down
2 changes: 2 additions & 0 deletions scripts/macos_dylib_merge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ for file in "${files[@]}"; do
((i++))
done

cp -r ./arm64/cmake ./universal/

output_name="macos_dylib_ffmpeg7_mpv38"
arch_list=("arm64" "x86_64" "universal")
for i in "${arch_list[@]}";
Expand Down

0 comments on commit 26cddfb

Please sign in to comment.