Last active
March 16, 2021 14:50
-
-
Save sansumbrella/43e9cde5514af99a15dc700c3a52b9ff to your computer and use it in GitHub Desktop.
Build OpenCV3 for tvos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Place this file adjacent to opencv and you should be able to build for tvos. | |
# The OpenCV CMakeLists.txt file is pretty huge, but it is well organized, | |
# so if you need to make changes, consult what options there are in that file. | |
# A whole bunch of compiler tests fail, but that doesn't seem to matter. | |
# | |
# After this runs CMake, you will want to build the binaries and install the headers. | |
# $ make -j 8 | |
# $ make install | |
# | |
OUTPUT_DIR=build | |
mkdir $OUTPUT_DIR | |
cd $OUTPUT_DIR | |
INSTALL_PREFIX=`pwd`/tvos | |
SDKVERSION=`xcrun -sdk appletvos --show-sdk-version` | |
# DEVELOPER=`xcode-select -print-path` | |
DEVELOPER="/Applications/Xcode.app/Contents/Developer" | |
TVOS_MIN_SDK_VERSION="9.0" | |
ARCH="arm64" | |
PLATFORM="AppleTVOS" | |
DEV_ROOT="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer" | |
TVOS_SDK="${PLATFORM}${SDKVERSION}.sdk" | |
BUILD_TOOLS="${DEVELOPER}" | |
COMPILER_FLAGS="-fembed-bitcode -fPIC -fvisibility-inlines-hidden -stdlib=libc++ -mtvos-version-min=9.0" | |
echo "Compiler flags: " $COMPILER_FLAGS | |
echo "Locations: " ${DEV_ROOT} ${TVOS_SDK} ${BUILD_TOOLS} | |
cmake ../opencv -DCMAKE_OSX_ARCHITECTURES="arm64" \ | |
-DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" \ | |
-DIOS=1 \ | |
-DAPPLE=1 \ | |
-DUNIX=1 \ | |
-DCMAKE_CXX_COMPILER=clang++ \ | |
-DCMAKE_C_COMPILER=clang \ | |
-DENABLE_FAST_MATH=ON \ | |
-DCMAKE_CXX_FLAGS="${COMPILER_FLAGS}" \ | |
-DCMAKE_C_FLAGS="${COMPILER_FLAGS}" \ | |
-DBUILD_SHARED_LIBS=OFF -DBUILD_opencv_java=OFF -DBUILD_opencv_python=OFF \ | |
-DWITH_1394=OFF -DWITH_CARBON=OFF -DWITH_FFMPEG=OFF -DWITH_IMAGEIO=OFF \ | |
-DWITH_IPP=OFF -DWITH_OPENNI=OFF -DWITH_QT=OFF -DWITH_QUICKTIME=OFF -DWITH_AVFOUNDATION=OFF \ | |
-DWITH_V4L=OFF -DWITH_PVAPI=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF \ | |
-DBUILD_opencv_videoio=OFF \ | |
-DBUILD_opencv_highgui=OFF \ | |
-DBUILD_opencv_world=ON \ | |
-DSDKVER="${SDKVERSION}" \ | |
-DCMAKE_IOS_DEVELOPER_ROOT="${DEV_ROOT}" \ | |
-DDEVROOT="${DEV_ROOT}" \ | |
-DSDKROOT="${TVOS_SDK}" \ | |
-DCMAKE_OSX_SYSROOT="${DEV_ROOT}/SDKs/${TVOS_SDK}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for sharing this! How could we make it build an Xcode framework?