From 12465388590e4e6eca404a5aad417c59379ed442 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Mon, 26 Aug 2024 15:36:13 +0800 Subject: [PATCH 01/41] add arm support for linux and win --- .github/workflows/build_test_release.yaml | 4 +- .github/workflows/release.yml | 932 ++++++++++++++ .gitignore | 2 +- options.txt | 138 ++ test/CMakeLists.txt | 17 + test/main.cpp | 14 + toolchains/aarch64-linux-gnu.toolchain.cmake | 16 + toolchains/arm-linux-gnueabi.toolchain.cmake | 16 + .../arm-linux-gnueabihf.toolchain.cmake | 16 + toolchains/ios.toolchain.cmake | 1135 +++++++++++++++++ ...riscv64-unknown-linux-musl.toolchain.cmake | 34 + 11 files changed, 2321 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 options.txt create mode 100644 test/CMakeLists.txt create mode 100644 test/main.cpp create mode 100644 toolchains/aarch64-linux-gnu.toolchain.cmake create mode 100644 toolchains/arm-linux-gnueabi.toolchain.cmake create mode 100644 toolchains/arm-linux-gnueabihf.toolchain.cmake create mode 100644 toolchains/ios.toolchain.cmake create mode 100644 toolchains/riscv64-unknown-linux-musl.toolchain.cmake diff --git a/.github/workflows/build_test_release.yaml b/.github/workflows/build_test_release.yaml index 4a3c22a..8fbe25d 100644 --- a/.github/workflows/build_test_release.yaml +++ b/.github/workflows/build_test_release.yaml @@ -6,8 +6,8 @@ on: - "*.*.*" # branches: # - main - pull_request: - branches: ["main"] + # pull_request: + # branches: ["main"] env: ANDROID_NDK_VERSION: r26c diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3b7c10c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,932 @@ +name: release +# on: pull_request +on: + push: + tags: + - '*' + pull_request: + branches: ["main"] + +env: + DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer + IOS_DEPLOYMENT_TARGET: '13.0' + MAC_DEPLOYMENT_TARGET: '11.0' + MAC_CATALYST_DEPLOYMENT_TARGET: '13.1' + WATCHOS_DEPLOYMENT_TARGET: '6.0' + TVOS_DEPLOYMENT_TARGET: '11.0' + VISIONOS_DEPLOYMENT_TARGET: '1.0' + ENABLE_BITCODE: OFF + ENABLE_ARC: OFF + ENABLE_VISIBILITY: OFF + EMSCRIPTEN_VERSION: 3.1.28 + +permissions: + contents: read + +jobs: + android: + runs-on: ubuntu-latest + strategy: + matrix: + opencv-version: [4.10.0] + env: + COMMON_CMAKE_OPTIONS: | + -DCMAKE_POLICY_DEFAULT_CMP0057=NEW \ + -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_LATEST_HOME/build/cmake/android.toolchain.cmake \ + -DANDROID_USE_LEGACY_TOOLCHAIN_FILE=False \ + -DANDROID_PLATFORM=android-24 \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + steps: + - uses: actions/checkout@v4 + - name: ndk-fix-debug + run: sed -i -e '/^ -g$/d' $ANDROID_NDK_LATEST_HOME/build/cmake/android-legacy.toolchain.cmake + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} + echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-android" >> $GITHUB_ENV + - name: build-armeabi-v7a + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-armeabi-v7a && cd build-armeabi-v7a + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="armeabi-v7a" -DANDROID_ARM_NEON=ON \ + `cat ../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: build-arm64-v8a + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-arm64-v8a && cd build-arm64-v8a + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="arm64-v8a" \ + `cat ../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON -DOPENCV_EXTRA_FLAGS="-mno-outline-atomics" .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: build-x86 + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-x86 && cd build-x86 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="x86" \ + `cat ../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: build-x86_64 + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-x86_64 && cd build-x86_64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="x86_64" \ + `cat ../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: package + run: | + mkdir ${{ env.PACKAGE_NAME }} + cp -rf ${{ env.SOURCE_DIR }}/build-x86/install/* ${{ env.PACKAGE_NAME }}/ + cp -rf ${{ env.SOURCE_DIR }}/build-x86_64/install/* ${{ env.PACKAGE_NAME }}/ + cp -rf ${{ env.SOURCE_DIR }}/build-armeabi-v7a/install/* ${{ env.PACKAGE_NAME }}/ + cp -rf ${{ env.SOURCE_DIR }}/build-arm64-v8a/install/* ${{ env.PACKAGE_NAME }}/ + zip -9 -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} + - name: test-armeabi-v7a + run: | + cd test + mkdir build-armeabi-v7a && cd build-armeabi-v7a + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="armeabi-v7a" -DANDROID_ARM_NEON=ON \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/sdk/native/jni .. + cmake --build . -j $(nproc) + - name: test-arm64-v8a + run: | + cd test + mkdir build-arm64-v8a && cd build-arm64-v8a + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="arm64-v8a" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/sdk/native/jni .. + cmake --build . -j $(nproc) + - name: test-x86 + run: | + cd test + mkdir build-x86 && cd build-x86 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="x86" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/sdk/native/jni .. + cmake --build . -j $(nproc) + - name: test-x86_64 + run: | + cd test + mkdir build-x86_64 && cd build-x86_64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="x86_64" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/sdk/native/jni .. + cmake --build . -j $(nproc) + - name: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.zip + + ios: + runs-on: macos-13 + strategy: + matrix: + opencv-version: [4.10.0] + env: + COMMON_CMAKE_OPTIONS: | + -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ + -DPLATFORM=OS \ + -DDEPLOYMENT_TARGET=$IOS_DEPLOYMENT_TARGET \ + -DENABLE_BITCODE=$ENABLE_BITCODE \ + -DENABLE_ARC=$ENABLE_ARC \ + -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ + -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions" \ + -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions" \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + steps: + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} + echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-ios" >> $GITHUB_ENV + - name: workaround-opencv2-list + if: matrix.opencv-version == '2.4.13.7' + run: | + # workaround ar @list issue on macos + sed -i -e 's!\\"${objpath4}\\"!${objpath4}!g' ${{ env.SOURCE_DIR }}/modules/world/CMakeLists.txt + - name: build-arm64 + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-arm64 && cd build-arm64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="arm64" \ + `cat ../options.txt` -DBUILD_opencv_world=ON -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + # workaround ar @list issue on macos + cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } + cmake --build . --target install + - name: package + run: | + rm -rf opencv2.framework + mkdir -p opencv2.framework/Versions/A/Headers + mkdir -p opencv2.framework/Versions/A/Resources + ln -s A opencv2.framework/Versions/Current + ln -s Versions/Current/Headers opencv2.framework/Headers + ln -s Versions/Current/Resources opencv2.framework/Resources + ln -s Versions/Current/opencv2 opencv2.framework/opencv2 + lipo -create \ + ${{ env.SOURCE_DIR }}/build-arm64/install/lib/libopencv_world.a \ + -o opencv2.framework/Versions/A/opencv2 + cp -r ${{ env.SOURCE_DIR }}/build-arm64/install/include/opencv4/opencv2/* opencv2.framework/Versions/A/Headers/ || : + cp -r ${{ env.SOURCE_DIR }}/build-arm64/install/include/opencv2/* opencv2.framework/Versions/A/Headers/ || : + cp ${{ env.SOURCE_DIR }}/Info.plist opencv2.framework/Versions/A/Resources/ + rm -f ${{ env.PACKAGE_NAME }}.zip + zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip opencv2.framework + - name: test + run: | + cd test + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="arm64" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE .. + cmake --build . -j 4 + - name: upload-zip + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.zip + + ios-simulator: + runs-on: macos-13 + strategy: + matrix: + opencv-version: [4.10.0] + env: + COMMON_CMAKE_OPTIONS: | + -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ + -DPLATFORM=SIMULATOR \ + -DDEPLOYMENT_TARGET=$IOS_DEPLOYMENT_TARGET \ + -DENABLE_BITCODE=$ENABLE_BITCODE \ + -DENABLE_ARC=$ENABLE_ARC \ + -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ + -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions" \ + -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions" \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + steps: + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} + echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-ios-simulator" >> $GITHUB_ENV + - name: workaround-opencv2-list + if: matrix.opencv-version == '2.4.13.7' + run: | + # workaround ar @list issue on macos + sed -i -e 's!\\"${objpath4}\\"!${objpath4}!g' ${{ env.SOURCE_DIR }}/modules/world/CMakeLists.txt + - name: build-x86_64 + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-x86_64 && cd build-x86_64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="x86_64" \ + `cat ../options.txt` -DBUILD_opencv_world=ON -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + # workaround ar @list issue on macos + cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } + cmake --build . --target install + - name: build-arm64 + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-arm64 && cd build-arm64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="arm64" \ + `cat ../options.txt` -DBUILD_opencv_world=ON -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + # workaround ar @list issue on macos + cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } + cmake --build . --target install + - name: package + run: | + rm -rf opencv2.framework + mkdir -p opencv2.framework/Versions/A/Headers + mkdir -p opencv2.framework/Versions/A/Resources + ln -s A opencv2.framework/Versions/Current + ln -s Versions/Current/Headers opencv2.framework/Headers + ln -s Versions/Current/Resources opencv2.framework/Resources + ln -s Versions/Current/opencv2 opencv2.framework/opencv2 + lipo -create \ + ${{ env.SOURCE_DIR }}/build-x86_64/install/lib/libopencv_world.a \ + ${{ env.SOURCE_DIR }}/build-arm64/install/lib/libopencv_world.a \ + -o opencv2.framework/Versions/A/opencv2 + cp -r ${{ env.SOURCE_DIR }}/build-x86_64/install/include/opencv4/opencv2/* opencv2.framework/Versions/A/Headers/ || : + cp -r ${{ env.SOURCE_DIR }}/build-x86_64/install/include/opencv2/* opencv2.framework/Versions/A/Headers/ || : + cp ${{ env.SOURCE_DIR }}/Info.plist opencv2.framework/Versions/A/Resources/ + rm -f ${{ env.PACKAGE_NAME }}.zip + zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip opencv2.framework + - name: test + run: | + cd test + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="x86_64;arm64" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE .. + cmake --build . -j 4 + - name: upload-zip + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.zip + + armlinux: + runs-on: ubuntu-latest + strategy: + matrix: + opencv-version: [4.10.0] + env: + COMMON_CMAKE_OPTIONS: | + -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions" \ + -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions" \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + steps: + - name: arm-gnu-toolchain + run: | + sudo apt-get update + sudo apt-get install g++-arm-linux-gnueabi g++-arm-linux-gnueabihf g++-aarch64-linux-gnu + + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} + echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-armlinux" >> $GITHUB_ENV + - name: build-arm-linux-gnueabi + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-arm-linux-gnueabi && cd build-arm-linux-gnueabi + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/arm-linux-gnueabi.toolchain.cmake \ + `cat ../options.txt` -DBUILD_opencv_world=OFF .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: build-arm-linux-gnueabihf + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-arm-linux-gnueabihf && cd build-arm-linux-gnueabihf + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/arm-linux-gnueabihf.toolchain.cmake \ + `cat ../options.txt` -DBUILD_opencv_world=OFF .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: build-aarch64-linux-gnu + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-aarch64-linux-gnu && cd build-aarch64-linux-gnu + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/aarch64-linux-gnu.toolchain.cmake \ + `cat ../options.txt` -DBUILD_opencv_world=OFF .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: package + run: | + mkdir ${{ env.PACKAGE_NAME }} + mkdir ${{ env.PACKAGE_NAME }}/arm-linux-gnueabi + mkdir ${{ env.PACKAGE_NAME }}/arm-linux-gnueabihf + mkdir ${{ env.PACKAGE_NAME }}/aarch64-linux-gnu + cp -rf ${{ env.SOURCE_DIR }}/build-arm-linux-gnueabi/install/* ${{ env.PACKAGE_NAME }}/arm-linux-gnueabi/ + cp -rf ${{ env.SOURCE_DIR }}/build-arm-linux-gnueabihf/install/* ${{ env.PACKAGE_NAME }}/arm-linux-gnueabihf/ + cp -rf ${{ env.SOURCE_DIR }}/build-aarch64-linux-gnu/install/* ${{ env.PACKAGE_NAME }}/aarch64-linux-gnu/ + zip -9 -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} + - name: set-opencv-dir + if: matrix.opencv-version == '2.4.13.7' || matrix.opencv-version == '3.4.20' + run: echo "OPENCV_SUBDIR=share/OpenCV" >> $GITHUB_ENV + - name: set-opencv-dir + if: matrix.opencv-version == '4.10.0' + run: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV + - name: test-arm-linux-gnueabi + run: | + cd test + mkdir build-arm-linux-gnueabi && cd build-arm-linux-gnueabi + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/arm-linux-gnueabi.toolchain.cmake \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/arm-linux-gnueabi/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j $(nproc) + - name: test-arm-linux-gnueabihf + run: | + cd test + mkdir build-arm-linux-gnueabihf && cd build-arm-linux-gnueabihf + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/arm-linux-gnueabihf.toolchain.cmake \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/arm-linux-gnueabihf/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j $(nproc) + - name: test-aarch64-linux-gnu + run: | + cd test + mkdir build-aarch64-linux-gnu && cd build-aarch64-linux-gnu + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/aarch64-linux-gnu.toolchain.cmake \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/aarch64-linux-gnu/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j $(nproc) + - name: upload-zip + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.zip + + macos: + runs-on: macos-13 + strategy: + matrix: + opencv-version: [4.10.0] + env: + COMMON_CMAKE_OPTIONS: | + -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ + -DDEPLOYMENT_TARGET=$MAC_DEPLOYMENT_TARGET \ + -DENABLE_BITCODE=OFF \ + -DENABLE_ARC=$ENABLE_ARC \ + -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + steps: + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} + echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-macos" >> $GITHUB_ENV + - name: workaround-opencv2-list + if: matrix.opencv-version == '2.4.13.7' + run: | + # workaround ar @list issue on macos + sed -i -e 's!\\"${objpath4}\\"!${objpath4}!g' ${{ env.SOURCE_DIR }}/modules/world/CMakeLists.txt + - name: build-x86_64 + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-x86_64 && cd build-x86_64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=MAC -DARCHS="x86_64" \ + `cat ../options.txt` -DBUILD_opencv_world=ON .. + # workaround ar @list issue on macos + cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } + cmake --build . --target install + - name: build-arm64 + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-arm64 && cd build-arm64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=MAC_ARM64 -DARCHS="arm64" \ + `cat ../options.txt` -DBUILD_opencv_world=ON .. + # workaround ar @list issue on macos + cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } + cmake --build . --target install + - name: package + run: | + rm -rf opencv2.framework + mkdir -p opencv2.framework/Versions/A/Headers + mkdir -p opencv2.framework/Versions/A/Resources + ln -s A opencv2.framework/Versions/Current + ln -s Versions/Current/Headers opencv2.framework/Headers + ln -s Versions/Current/Resources opencv2.framework/Resources + ln -s Versions/Current/opencv2 opencv2.framework/opencv2 + lipo -create \ + ${{ env.SOURCE_DIR }}/build-x86_64/install/lib/libopencv_world.a \ + ${{ env.SOURCE_DIR }}/build-arm64/install/lib/libopencv_world.a \ + -o opencv2.framework/Versions/A/opencv2 + cp -r ${{ env.SOURCE_DIR }}/build-x86_64/install/include/opencv4/opencv2/* opencv2.framework/Versions/A/Headers/ || : + cp -r ${{ env.SOURCE_DIR }}/build-x86_64/install/include/opencv2/* opencv2.framework/Versions/A/Headers/ || : + cp ${{ env.SOURCE_DIR }}/Info.plist opencv2.framework/Versions/A/Resources/ + rm -f ${{ env.PACKAGE_NAME }}.zip + zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip opencv2.framework + - name: test-x86_64 + run: | + cd test + mkdir build-x86_64 && cd build-x86_64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=MAC -DARCHS="x86_64" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE .. + cmake --build . -j 4 + - name: test-arm64 + run: | + cd test + mkdir build-arm64 && cd build-arm64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=MAC_ARM64 -DARCHS="arm64" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE .. + cmake --build . -j 4 + - name: upload-zip + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.zip + + mac-catalyst: + runs-on: macos-13 + strategy: + matrix: + opencv-version: [4.10.0] + env: + COMMON_CMAKE_OPTIONS: | + -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ + -DPLATFORM=MAC_CATALYST \ + -DDEPLOYMENT_TARGET=$MAC_CATALYST_DEPLOYMENT_TARGET \ + -DENABLE_BITCODE=$ENABLE_BITCODE \ + -DENABLE_ARC=$ENABLE_ARC \ + -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ + -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions" \ + -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions" \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + steps: + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} + echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-mac-catalyst" >> $GITHUB_ENV + - name: workaround-opencv2-list + if: matrix.opencv-version == '2.4.13.7' + run: | + # workaround ar @list issue on macos + sed -i -e 's!\\"${objpath4}\\"!${objpath4}!g' ${{ env.SOURCE_DIR }}/modules/world/CMakeLists.txt + - name: build-x86_64 + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-x86_64 && cd build-x86_64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="x86_64" \ + `cat ../options.txt` -DBUILD_opencv_world=ON .. + # workaround ar @list issue on macos + cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } + cmake --build . --target install + - name: build-arm64 + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-arm64 && cd build-arm64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="arm64" \ + `cat ../options.txt` -DBUILD_opencv_world=ON .. + # workaround ar @list issue on macos + cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } + cmake --build . --target install + - name: package + run: | + rm -rf opencv2.framework + mkdir -p opencv2.framework/Versions/A/Headers + mkdir -p opencv2.framework/Versions/A/Resources + ln -s A opencv2.framework/Versions/Current + ln -s Versions/Current/Headers opencv2.framework/Headers + ln -s Versions/Current/Resources opencv2.framework/Resources + ln -s Versions/Current/opencv2 opencv2.framework/opencv2 + lipo -create \ + ${{ env.SOURCE_DIR }}/build-x86_64/install/lib/libopencv_world.a \ + ${{ env.SOURCE_DIR }}/build-arm64/install/lib/libopencv_world.a \ + -o opencv2.framework/Versions/A/opencv2 + cp -r ${{ env.SOURCE_DIR }}/build-arm64/install/include/opencv4/opencv2/* opencv2.framework/Versions/A/Headers/ || : + cp -r ${{ env.SOURCE_DIR }}/build-arm64/install/include/opencv2/* opencv2.framework/Versions/A/Headers/ || : + cp ${{ env.SOURCE_DIR }}/Info.plist opencv2.framework/Versions/A/Resources/ + rm -f ${{ env.PACKAGE_NAME }}.zip + zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip opencv2.framework + - name: test + run: | + cd test + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="x86_64;arm64" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE .. + cmake --build . -j 4 + - name: upload-zip + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.zip + windows: + strategy: + matrix: + opencv-version: [4.10.0] + os-compiler: + - { msvc-version: vs2015, windows-version: 2019, toolset-version: v140 } + - { msvc-version: vs2017, windows-version: 2019, toolset-version: v141 } + - { msvc-version: vs2019, windows-version: 2019, toolset-version: v142 } + - { msvc-version: vs2022, windows-version: 2022, toolset-version: v143 } + runs-on: windows-${{ matrix.os-compiler.windows-version }} + env: + UseMultiToolTask: true + COMMON_CMAKE_OPTIONS: -T ${{ matrix.os-compiler.toolset-version }},host=x64 -DCMAKE_INSTALL_PREFIX=install + steps: + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} + echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $env:GITHUB_ENV + echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-windows-${{ matrix.os-compiler.msvc-version }}" >> $env:GITHUB_ENV + - name: build-x86 + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-x86; cd build-x86 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A Win32 $(type ../options.txt) -DBUILD_opencv_world=OFF .. + cmake --build . --config Release -j 4 + cmake --build . --config Release --target install + - name: build-x64 + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-x64; cd build-x64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A x64 $(type ../options.txt) -DBUILD_opencv_world=OFF .. + cmake --build . --config Release -j 4 + cmake --build . --config Release --target install + - name: build-arm + if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-arm; cd build-arm + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A arm -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=ARM $(type ../options.txt) -DBUILD_opencv_world=OFF .. + cmake --build . --config Release -j 4 + cmake --build . --config Release --target install + - name: build-arm64 + if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-arm64; cd build-arm64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A arm64 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=ARM64 $(type ../options.txt) -DBUILD_opencv_world=OFF .. + cmake --build . --config Release -j 4 + cmake --build . --config Release --target install + - name: package + if: matrix.os-compiler.msvc-version == 'vs2015' || matrix.os-compiler.msvc-version == 'vs2017' + run: | + mkdir ${{ env.PACKAGE_NAME }} + mkdir ${{ env.PACKAGE_NAME }}/x86 + mkdir ${{ env.PACKAGE_NAME }}/x64 + Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-x86\install\*" -Destination "${{ env.PACKAGE_NAME }}\x86" + Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-x64\install\*" -Destination "${{ env.PACKAGE_NAME }}\x64" + 7z a -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} + - name: package + if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' + run: | + mkdir ${{ env.PACKAGE_NAME }} + mkdir ${{ env.PACKAGE_NAME }}/x86 + mkdir ${{ env.PACKAGE_NAME }}/x64 + mkdir ${{ env.PACKAGE_NAME }}/arm + mkdir ${{ env.PACKAGE_NAME }}/arm64 + Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-x86\install\*" -Destination "${{ env.PACKAGE_NAME }}\x86" + Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-x64\install\*" -Destination "${{ env.PACKAGE_NAME }}\x64" + Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-arm\install\*" -Destination "${{ env.PACKAGE_NAME }}\arm" + Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-arm64\install\*" -Destination "${{ env.PACKAGE_NAME }}\arm64" + 7z a -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} + - name: test-x86 + run: | + cd test + mkdir build-x86; cd build-x86 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A Win32 -DOpenCV_DIR="$env:GITHUB_WORKSPACE\${{ env.PACKAGE_NAME }}\x86" -DOpenCV_STATIC=ON .. + cmake --build . --config Release -j 4 + - name: test-x64 + run: | + cd test + mkdir build-x64; cd build-x64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A x64 -DOpenCV_DIR="$env:GITHUB_WORKSPACE\${{ env.PACKAGE_NAME }}\x64" -DOpenCV_STATIC=ON .. + cmake --build . --config Release -j 4 + - name: test-arm + if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' + run: | + cd test + mkdir build-arm; cd build-arm + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A arm -DOpenCV_DIR="$env:GITHUB_WORKSPACE\${{ env.PACKAGE_NAME }}\arm" -DOpenCV_STATIC=ON .. + cmake --build . --config Release -j 4 + - name: test-arm64 + if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' + run: | + cd test + mkdir build-arm64; cd build-arm64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A arm64 -DOpenCV_DIR="$env:GITHUB_WORKSPACE\${{ env.PACKAGE_NAME }}\arm64" -DOpenCV_STATIC=ON .. + cmake --build . --config Release -j 4 + - name: upload-zip + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.zip + + ubuntu: + strategy: + matrix: + opencv-version: [4.10.0] + os-ubuntu: + - { ubuntu-id: 2004, ubuntu-version: 20.04 } + - { ubuntu-id: 2204, ubuntu-version: 22.04 } + runs-on: ubuntu-${{ matrix.os-ubuntu.ubuntu-version }} + env: + COMMON_CMAKE_OPTIONS: -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release + steps: + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} + echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-ubuntu-${{ matrix.os-ubuntu.ubuntu-id }}" >> $GITHUB_ENV + - name: build + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} `cat ../options.txt` -DBUILD_opencv_world=OFF .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: package + run: | + rm -rf ${{ env.PACKAGE_NAME }} + mkdir -p ${{ env.PACKAGE_NAME }} + cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ + rm -f ${{ env.PACKAGE_NAME }}.zip + zip -9 -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} + - name: set-opencv-dir + if: matrix.opencv-version == '2.4.13.7' || matrix.opencv-version == '3.4.20' + run: echo "OPENCV_SUBDIR=share/OpenCV" >> $GITHUB_ENV + - name: set-opencv-dir + if: matrix.opencv-version == '4.10.0' + run: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV + - name: test + run: | + cd test + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j $(nproc) + - name: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.zip + + webassembly: + runs-on: ubuntu-20.04 + strategy: + matrix: + opencv-version: [4.10.0] + env: + COMMON_CMAKE_OPTIONS: | + -DCMAKE_TOOLCHAIN_FILE=../emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + steps: + - uses: actions/checkout@v4 + - name: emsdk + run: | + git clone https://github.com/emscripten-core/emsdk.git + cd emsdk + ./emsdk install $EMSCRIPTEN_VERSION + ./emsdk activate $EMSCRIPTEN_VERSION + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} + echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-webassembly" >> $GITHUB_ENV + - name: build + run: | + source emsdk/emsdk_env.sh + cd ${{ env.SOURCE_DIR }} + patch -p1 -i ../patches/opencv-${{ matrix.opencv-version }}-unsafe-xadd.patch + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=OFF -DCV_ENABLE_INTRINSICS=OFF -DBUILD_WASM_INTRIN_TESTS=OFF \ + -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0" \ + -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0" \ + `cat ../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: build-simd + run: | + source emsdk/emsdk_env.sh + cd ${{ env.SOURCE_DIR }} + mkdir build-simd && cd build-simd + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=OFF -DCV_ENABLE_INTRINSICS=ON -DBUILD_WASM_INTRIN_TESTS=OFF \ + -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0 -msimd128" \ + -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0 -msimd128" \ + `cat ../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: build-threads + run: | + source emsdk/emsdk_env.sh + cd ${{ env.SOURCE_DIR }} + patch -p1 -R -i ../patches/opencv-${{ matrix.opencv-version }}-unsafe-xadd.patch + mkdir build-threads && cd build-threads + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=ON -DCV_ENABLE_INTRINSICS=OFF -DBUILD_WASM_INTRIN_TESTS=OFF \ + -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ + -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ + `cat ../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: build-simd-threads + run: | + source emsdk/emsdk_env.sh + cd ${{ env.SOURCE_DIR }} + mkdir build-simd-threads && cd build-simd-threads + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=ON -DCV_ENABLE_INTRINSICS=ON -DBUILD_WASM_INTRIN_TESTS=OFF \ + -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ + -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ + `cat ../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: package + run: | + rm -rf ${{ env.PACKAGE_NAME }} + mkdir -p ${{ env.PACKAGE_NAME }} + cp -rf ${{ env.SOURCE_DIR }}/build/install ${{ env.PACKAGE_NAME }}/basic + cp -rf ${{ env.SOURCE_DIR }}/build-simd/install ${{ env.PACKAGE_NAME }}/simd + cp -rf ${{ env.SOURCE_DIR }}/build-threads/install ${{ env.PACKAGE_NAME }}/threads + cp -rf ${{ env.SOURCE_DIR }}/build-simd-threads/install ${{ env.PACKAGE_NAME }}/simd-threads + rm -f ${{ env.PACKAGE_NAME }}.zip + zip -9 -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} + - name: set-opencv-dir + if: matrix.opencv-version == '2.4.13.7' || matrix.opencv-version == '3.4.20' + run: echo "OPENCV_SUBDIR=share/OpenCV" >> $GITHUB_ENV + - name: set-opencv-dir + if: matrix.opencv-version == '4.10.0' + run: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV + - name: test + run: | + cd test + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0" \ + -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/basic/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j $(nproc) + - name: test-simd + run: | + cd test + mkdir build-simd && cd build-simd + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0 -msimd128" \ + -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0 -msimd128" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/simd/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j $(nproc) + - name: test-threads + run: | + cd test + mkdir build-threads && cd build-threads + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ + -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/threads/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j $(nproc) + - name: test-simd-threads + run: | + cd test + mkdir build-simd-threads && cd build-simd-threads + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ + -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/simd-threads/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j $(nproc) + - name: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.zip + + apple: + needs: [macos, ios, ios-simulator, mac-catalyst] + runs-on: macos-13 + strategy: + matrix: + opencv-version: [4.10.0] + steps: + - run: sudo xcode-select --switch /Applications/Xcode_15.2.app + - uses: actions/checkout@v4 + - name: setup-opencv-package + run: | + echo "MACOS_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-macos" >> $GITHUB_ENV + echo "IOS_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-ios" >> $GITHUB_ENV + echo "IOS_SIMULATOR_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-ios-simulator" >> $GITHUB_ENV + echo "MAC_CATALYST_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-mac-catalyst" >> $GITHUB_ENV + echo "WATCHOS_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-watchos" >> $GITHUB_ENV + echo "WATCHOS_SIMULATOR_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-watchos-simulator" >> $GITHUB_ENV + echo "TVOS_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-tvos" >> $GITHUB_ENV + echo "TVOS_SIMULATOR_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-tvos-simulator" >> $GITHUB_ENV + echo "VISIONOS_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-visionos" >> $GITHUB_ENV + echo "VISIONOS_SIMULATOR_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-visionos-simulator" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-apple" >> $GITHUB_ENV + - name: download-macos-package + uses: actions/download-artifact@v4 + with: + name: ${{ env.MACOS_PACKAGE_NAME }} + - name: download-ios-package + uses: actions/download-artifact@v4 + with: + name: ${{ env.IOS_PACKAGE_NAME }} + - name: download-ios-simulator-package + uses: actions/download-artifact@v4 + with: + name: ${{ env.IOS_SIMULATOR_PACKAGE_NAME }} + - name: download-mac-catalyst-package + uses: actions/download-artifact@v4 + with: + name: ${{ env.MAC_CATALYST_PACKAGE_NAME }} + - name: download-watchos-package + uses: actions/download-artifact@v4 + with: + name: ${{ env.WATCHOS_PACKAGE_NAME }} + - name: download-watchos-simulator-package + uses: actions/download-artifact@v4 + with: + name: ${{ env.WATCHOS_SIMULATOR_PACKAGE_NAME }} + - name: download-tvos-package + uses: actions/download-artifact@v4 + with: + name: ${{ env.TVOS_PACKAGE_NAME }} + - name: download-tvos-simulator-package + uses: actions/download-artifact@v4 + with: + name: ${{ env.TVOS_SIMULATOR_PACKAGE_NAME }} + - name: download-visionos-package + uses: actions/download-artifact@v4 + with: + name: ${{ env.VISIONOS_PACKAGE_NAME }} + - name: download-visionos-simulator-package + uses: actions/download-artifact@v4 + with: + name: ${{ env.VISIONOS_SIMULATOR_PACKAGE_NAME }} + - name: create-xcframwork + run: | + mkdir -p ${{ env.MACOS_PACKAGE_NAME }} + mkdir -p ${{ env.IOS_PACKAGE_NAME }} + mkdir -p ${{ env.IOS_SIMULATOR_PACKAGE_NAME }} + mkdir -p ${{ env.MAC_CATALYST_PACKAGE_NAME }} + mkdir -p ${{ env.WATCHOS_PACKAGE_NAME }} + mkdir -p ${{ env.WATCHOS_SIMULATOR_PACKAGE_NAME }} + mkdir -p ${{ env.TVOS_PACKAGE_NAME }} + mkdir -p ${{ env.TVOS_SIMULATOR_PACKAGE_NAME }} + mkdir -p ${{ env.VISIONOS_PACKAGE_NAME }} + mkdir -p ${{ env.VISIONOS_SIMULATOR_PACKAGE_NAME }} + unzip -q ${{ env.MACOS_PACKAGE_NAME }}.zip -d ${{ env.MACOS_PACKAGE_NAME }} + unzip -q ${{ env.IOS_PACKAGE_NAME }}.zip -d ${{ env.IOS_PACKAGE_NAME }} + unzip -q ${{ env.IOS_SIMULATOR_PACKAGE_NAME }}.zip -d ${{ env.IOS_SIMULATOR_PACKAGE_NAME }} + unzip -q ${{ env.MAC_CATALYST_PACKAGE_NAME }}.zip -d ${{ env.MAC_CATALYST_PACKAGE_NAME }} + unzip -q ${{ env.WATCHOS_PACKAGE_NAME }}.zip -d ${{ env.WATCHOS_PACKAGE_NAME }} + unzip -q ${{ env.WATCHOS_SIMULATOR_PACKAGE_NAME }}.zip -d ${{ env.WATCHOS_SIMULATOR_PACKAGE_NAME }} + unzip -q ${{ env.TVOS_PACKAGE_NAME }}.zip -d ${{ env.TVOS_PACKAGE_NAME }} + unzip -q ${{ env.TVOS_SIMULATOR_PACKAGE_NAME }}.zip -d ${{ env.TVOS_SIMULATOR_PACKAGE_NAME }} + unzip -q ${{ env.VISIONOS_PACKAGE_NAME }}.zip -d ${{ env.VISIONOS_PACKAGE_NAME }} + unzip -q ${{ env.VISIONOS_SIMULATOR_PACKAGE_NAME }}.zip -d ${{ env.VISIONOS_SIMULATOR_PACKAGE_NAME }} + xcodebuild -create-xcframework \ + -framework ${{ env.MACOS_PACKAGE_NAME }}/opencv2.framework \ + -framework ${{ env.IOS_PACKAGE_NAME }}/opencv2.framework \ + -framework ${{ env.IOS_SIMULATOR_PACKAGE_NAME }}/opencv2.framework \ + -framework ${{ env.MAC_CATALYST_PACKAGE_NAME }}/opencv2.framework \ + -framework ${{ env.WATCHOS_PACKAGE_NAME }}/opencv2.framework \ + -framework ${{ env.WATCHOS_SIMULATOR_PACKAGE_NAME }}/opencv2.framework \ + -framework ${{ env.TVOS_PACKAGE_NAME }}/opencv2.framework \ + -framework ${{ env.TVOS_SIMULATOR_PACKAGE_NAME }}/opencv2.framework \ + -framework ${{ env.VISIONOS_PACKAGE_NAME }}/opencv2.framework \ + -framework ${{ env.VISIONOS_SIMULATOR_PACKAGE_NAME }}/opencv2.framework \ + -output opencv2.xcframework + rm -f ${{ env.PACKAGE_NAME }}.zip + zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip opencv2.xcframework + - name: upload-zip + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.zip + + release: + permissions: + contents: write # for softprops/action-gh-release to create a release + needs: [android, ios, ios-simulator, armlinux, macos, mac-catalyst, windows, ubuntu, webassembly, apple] + runs-on: ubuntu-latest + steps: + - name: download + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: create-release + uses: softprops/action-gh-release@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag_name: ${{ needs.setup.outputs.VERSION }} + name: Release ${{ needs.setup.outputs.VERSION }} + files: artifacts/*/*.zip diff --git a/.gitignore b/.gitignore index 2f5838f..3549510 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -build/ +build*/ # Prerequisites *.d .vscode diff --git a/options.txt b/options.txt new file mode 100644 index 0000000..d889c9c --- /dev/null +++ b/options.txt @@ -0,0 +1,138 @@ +-DBUILD_ZLIB=ON +-DBUILD_TIFF=ON +-DBUILD_OPENJPEG=ON +-DBUILD_JASPER=OFF +-DBUILD_JPEG=ON +-DBUILD_PNG=ON +-DBUILD_OPENEXR=ON +-DBUILD_WEBP=ON +-DBUILD_TBB=OFF +-DBUILD_ITT=OFF +-DWITH_ADE=ON +-DWITH_CPUFEATURES=OFF +-DWITH_EIGEN=ON +-DWITH_HALIDE=OFF +-DWITH_VULKAN=ON +-DWITH_INF_ENGINE=OFF +-DWITH_NGRAPH=OFF +-DWITH_JASPER=OFF +-DWITH_OPENJPEG=ON +-DWITH_JPEG=ON +-DWITH_WEBP=ON +-DWITH_OPENEXR=ON +-DWITH_PNG=ON +-DWITH_TIFF=ON +-DWITH_OPENVX=OFF +-DWITH_GDCM=OFF +-DWITH_TBB=OFF +-DWITH_HPX=OFF +-DWITH_OPENMP=ON +-DWITH_PTHREADS_PF=OFF +-DWITH_CLP=OFF +-DWITH_OPENCL=ON +-DWITH_OPENCL_SVM=ON +-DWITH_VA=OFF +-DWITH_VA_INTEL=OFF +-DWITH_ITT=OFF +-DWITH_PROTOBUF=ON +-DWITH_IMGCODEC_HDR=ON +-DWITH_IMGCODEC_SUNRASTER=ON +-DWITH_IMGCODEC_PXM=ON +-DWITH_IMGCODEC_PFM=ON +-DWITH_QUIRC=ON +-DWITH_OBSENSOR=OFF +-DWITH_CANN=OFF +-DWITH_FLATBUFFERS=OFF +-DBUILD_SHARED_LIBS=OFF +-DBUILD_opencv_apps=OFF +-DBUILD_ANDROID_PROJECTS=OFF +-DBUILD_ANDROID_EXAMPLES=OFF +-DBUILD_DOCS=OFF +-DBUILD_EXAMPLES=OFF +-DBUILD_PACKAGE=OFF +-DBUILD_PERF_TESTS=OFF +-DBUILD_TESTS=OFF +-DBUILD_FAT_JAVA_LIB=OFF +-DBUILD_JAVA=OFF +-DBUILD_OBJC=OFF +-DBUILD_KOTLIN_EXTENSIONS=OFF +-DENABLE_PRECOMPILED_HEADERS=OFF +-DENABLE_FAST_MATH=ON +-DBUILD_opencv_world=OFF +-DBUILD_opencv_calib3d=ON +-DBUILD_opencv_dnn=ON +-DBUILD_opencv_features2d=ON +-DBUILD_opencv_flann=ON +-DBUILD_opencv_gapi=ON +-DBUILD_opencv_highgui=ON +-DBUILD_opencv_imgcodecs=ON +-DBUILD_opencv_imgproc=ON +-DBUILD_opencv_ml=ON +-DBUILD_opencv_objdetect=ON +-DBUILD_opencv_photo=ON +-DBUILD_opencv_stitching=ON +-DBUILD_opencv_video=ON +-DBUILD_opencv_videoio=ON +-DBUILD_opencv_aruco=ON +-DBUILD_opencv_img_hash=ON +-DBUILD_opencv_wechat_qrcode=ON +-DBUILD_opencv_bgsegm=ON +-DBUILD_opencv_bioinspired=ON +-DBUILD_opencv_ccalib=ON +-DBUILD_opencv_dnn_objdetect=ON +-DBUILD_opencv_dnn_superres=ON +-DBUILD_opencv_dpm=ON +-DBUILD_opencv_face=ON +-DBUILD_opencv_fuzzy=ON +-DBUILD_opencv_hfs=ON +-DBUILD_opencv_intensity_transform=ON +-DBUILD_opencv_line_descriptor=ON +-DBUILD_opencv_mcc=ON +-DBUILD_opencv_optflow=ON +-DBUILD_opencv_phase_unwrapping=ON +-DBUILD_opencv_plot=ON +-DBUILD_opencv_quality=ON +-DBUILD_opencv_rapid=ON +-DBUILD_opencv_reg=ON +-DBUILD_opencv_rgbd=ON +-DBUILD_opencv_saliency=ON +-DBUILD_opencv_shape=ON +-DBUILD_opencv_signal=ON +-DBUILD_opencv_stereo=ON +-DBUILD_opencv_structured_light=ON +-DBUILD_opencv_superres=ON +-DBUILD_opencv_surface_matching=ON +-DBUILD_opencv_tracking=ON +-DBUILD_opencv_videostab=ON +-DBUILD_opencv_xfeatures2d=ON +-DBUILD_opencv_ximgproc=ON +-DBUILD_opencv_xobjdetect=ON +-DBUILD_opencv_xphoto=ON +-DBUILD_opencv_alphamat=ON +-DBUILD_opencv_cannops=OFF +-DBUILD_opencv_cudaarithm=OFF +-DBUILD_opencv_cudabgsegm=OFF +-DBUILD_opencv_cudacodec=OFF +-DBUILD_opencv_cudafeatures2d=OFF +-DBUILD_opencv_cudafilters=OFF +-DBUILD_opencv_cudaimgproc=OFF +-DBUILD_opencv_cudalegacy=OFF +-DBUILD_opencv_cudaobjdetect=OFF +-DBUILD_opencv_cudaoptflow=OFF +-DBUILD_opencv_cudastereo=OFF +-DBUILD_opencv_cudawarping=OFF +-DBUILD_opencv_cudev=OFF +-DBUILD_opencv_cvv=OFF +-DBUILD_opencv_freetype=OFF +-DBUILD_opencv_hdf=OFF +-DBUILD_opencv_java=OFF +-DBUILD_opencv_objc=OFF +-DBUILD_opencv_js=OFF +-DBUILD_opencv_ts=OFF +-DBUILD_opencv_python2=OFF +-DBUILD_opencv_python3=OFF +-DBUILD_opencv_julia=OFF +-DBUILD_opencv_matlab=OFF +-DBUILD_opencv_ovis=OFF +-DBUILD_opencv_sfm=OFF +-DBUILD_opencv_viz=OFF diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..06d8cb3 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,17 @@ +project(opencv-mobile-test) +cmake_minimum_required(VERSION 3.5) + +# opencv4 requires c++11 +set(CMAKE_CXX_STANDARD 11) + +if(APPLE OR IOS) + # set OpenCV_DIR to where opencv2.framework resides + find_library(OpenCV_LIBS NAMES opencv2 PATHS ${OpenCV_DIR}) +else() + # set OpenCV_DIR to where OpenCVConfig.cmake resides + find_package(OpenCV REQUIRED) +endif() + +add_executable(opencv-mobile-test main.cpp) + +target_link_libraries(opencv-mobile-test ${OpenCV_LIBS}) diff --git a/test/main.cpp b/test/main.cpp new file mode 100644 index 0000000..f8d2873 --- /dev/null +++ b/test/main.cpp @@ -0,0 +1,14 @@ +#include +#include +#include + +int main() +{ + cv::Mat bgr = cv::imread("in.jpg", 1); + + cv::resize(bgr, bgr, cv::Size(200, 200)); + + cv::imwrite("out.jpg", bgr); + + return 0; +} diff --git a/toolchains/aarch64-linux-gnu.toolchain.cmake b/toolchains/aarch64-linux-gnu.toolchain.cmake new file mode 100644 index 0000000..b9b9f6c --- /dev/null +++ b/toolchains/aarch64-linux-gnu.toolchain.cmake @@ -0,0 +1,16 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR aarch64) + +set(CMAKE_C_COMPILER "aarch64-linux-gnu-gcc") +set(CMAKE_CXX_COMPILER "aarch64-linux-gnu-g++") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +set(CMAKE_C_FLAGS "-march=armv8-a") +set(CMAKE_CXX_FLAGS "-march=armv8-a") + +# cache flags +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags") diff --git a/toolchains/arm-linux-gnueabi.toolchain.cmake b/toolchains/arm-linux-gnueabi.toolchain.cmake new file mode 100644 index 0000000..b9e1881 --- /dev/null +++ b/toolchains/arm-linux-gnueabi.toolchain.cmake @@ -0,0 +1,16 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR arm) + +set(CMAKE_C_COMPILER "arm-linux-gnueabi-gcc") +set(CMAKE_CXX_COMPILER "arm-linux-gnueabi-g++") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +set(CMAKE_C_FLAGS "-march=armv7-a -mfloat-abi=softfp -mfpu=neon-vfpv4") +set(CMAKE_CXX_FLAGS "-march=armv7-a -mfloat-abi=softfp -mfpu=neon-vfpv4") + +# cache flags +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags") diff --git a/toolchains/arm-linux-gnueabihf.toolchain.cmake b/toolchains/arm-linux-gnueabihf.toolchain.cmake new file mode 100644 index 0000000..74ed5bf --- /dev/null +++ b/toolchains/arm-linux-gnueabihf.toolchain.cmake @@ -0,0 +1,16 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR arm) + +set(CMAKE_C_COMPILER "arm-linux-gnueabihf-gcc") +set(CMAKE_CXX_COMPILER "arm-linux-gnueabihf-g++") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +set(CMAKE_C_FLAGS "-march=armv7-a -mfloat-abi=hard -mfpu=neon") +set(CMAKE_CXX_FLAGS "-march=armv7-a -mfloat-abi=hard -mfpu=neon") + +# cache flags +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags") diff --git a/toolchains/ios.toolchain.cmake b/toolchains/ios.toolchain.cmake new file mode 100644 index 0000000..db2a327 --- /dev/null +++ b/toolchains/ios.toolchain.cmake @@ -0,0 +1,1135 @@ +# This file is part of the ios-cmake project. It was retrieved from +# https://github.com/leetal/ios-cmake.git, which is a fork of +# https://github.com/gerstrong/ios-cmake.git, which is a fork of +# https://github.com/cristeab/ios-cmake.git, which is a fork of +# https://code.google.com/p/ios-cmake/. Which in turn is based off of +# the Platform/Darwin.cmake and Platform/UnixPaths.cmake files which +# are included with CMake 2.8.4 +# +# The ios-cmake project is licensed under the new BSD license. +# +# Copyright (c) 2014, Bogdan Cristea and LTE Engineering Software, +# Kitware, Inc., Insight Software Consortium. All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# This file is based on the Platform/Darwin.cmake and +# Platform/UnixPaths.cmake files which are included with CMake 2.8.4 +# It has been altered for iOS development. +# +# Updated by Alex Stewart (alexs.mac@gmail.com) +# +# ***************************************************************************** +# Now maintained by Alexander Widerberg (widerbergaren [at] gmail.com) +# under the BSD-3-Clause license +# https://github.com/leetal/ios-cmake +# ***************************************************************************** +# +# INFORMATION / HELP +# +############################################################################### +# OPTIONS # +############################################################################### +# +# PLATFORM: (default "OS64") +# OS = Build for iPhoneOS. +# OS64 = Build for arm64 iphoneOS. +# OS64COMBINED = Build for arm64 x86_64 iphoneOS + iphoneOS Simulator. Combined into FAT STATIC lib (only supported on 3.14+ of CMake with "-G Xcode" argument in combination with the "cmake --install" CMake build step) +# SIMULATOR = Build for x86 i386 iphoneOS Simulator. +# SIMULATOR64 = Build for x86_64 iphoneOS Simulator. +# SIMULATORARM64 = Build for arm64 iphoneOS Simulator. +# SIMULATOR64COMBINED = Build for arm64 x86_64 iphoneOS Simulator. Combined into FAT STATIC lib (supported on 3.14+ of CMakewith "-G Xcode" argument ONLY) +# TVOS = Build for arm64 tvOS. +# TVOSCOMBINED = Build for arm64 x86_64 tvOS + tvOS Simulator. Combined into FAT STATIC lib (only supported on 3.14+ of CMake with "-G Xcode" argument in combination with the "cmake --install" CMake build step) +# SIMULATOR_TVOS = Build for x86_64 tvOS Simulator. +# SIMULATORARM64_TVOS = Build for arm64 tvOS Simulator. +# VISIONOSCOMBINED = Build for arm64 visionOS + visionOS Simulator. Combined into FAT STATIC lib (only supported on 3.14+ of CMake with "-G Xcode" argument in combination with the "cmake --install" CMake build step) +# VISIONOS = Build for arm64 visionOS. +# SIMULATOR_VISIONOS = Build for arm64 visionOS Simulator. +# WATCHOS = Build for armv7k arm64_32 for watchOS. +# WATCHOSCOMBINED = Build for armv7k arm64_32 x86_64 watchOS + watchOS Simulator. Combined into FAT STATIC lib (only supported on 3.14+ of CMake with "-G Xcode" argument in combination with the "cmake --install" CMake build step) +# SIMULATOR_WATCHOS = Build for x86_64 for watchOS Simulator. +# SIMULATORARM64_WATCHOS = Build for arm64 for watchOS Simulator. +# MAC = Build for x86_64 macOS. +# MAC_ARM64 = Build for Apple Silicon macOS. +# MAC_UNIVERSAL = Combined build for x86_64 and Apple Silicon on macOS. +# MAC_CATALYST = Build for x86_64 macOS with Catalyst support (iOS toolchain on macOS). +# Note: The build argument "MACOSX_DEPLOYMENT_TARGET" can be used to control min-version of macOS +# MAC_CATALYST_ARM64 = Build for Apple Silicon macOS with Catalyst support (iOS toolchain on macOS). +# Note: The build argument "MACOSX_DEPLOYMENT_TARGET" can be used to control min-version of macOS +# +# CMAKE_OSX_SYSROOT: Path to the SDK to use. By default this is +# automatically determined from PLATFORM and xcodebuild, but +# can also be manually specified (although this should not be required). +# +# CMAKE_DEVELOPER_ROOT: Path to the Developer directory for the platform +# being compiled for. By default, this is automatically determined from +# CMAKE_OSX_SYSROOT, but can also be manually specified (although this should +# not be required). +# +# DEPLOYMENT_TARGET: Minimum SDK version to target. Default 6.0 on watchOS, 13.0 on tvOS+iOS/iPadOS, 11.0 on macOS, 1.0 on visionOS +# +# NAMED_LANGUAGE_SUPPORT: +# ON (default) = Will require "enable_language(OBJC) and/or enable_language(OBJCXX)" for full OBJC|OBJCXX support +# OFF = Will embed the OBJC and OBJCXX flags into the CMAKE_C_FLAGS and CMAKE_CXX_FLAGS (legacy behavior, CMake version < 3.16) +# +# ENABLE_BITCODE: (ON|OFF) Enables or disables bitcode support. Default OFF +# +# ENABLE_ARC: (ON|OFF) Enables or disables ARC support. Default ON (ARC enabled by default) +# +# ENABLE_VISIBILITY: (ON|OFF) Enables or disables symbol visibility support. Default OFF (visibility hidden by default) +# +# ENABLE_STRICT_TRY_COMPILE: (ON|OFF) Enables or disables strict try_compile() on all Check* directives (will run linker +# to actually check if linking is possible). Default OFF (will set CMAKE_TRY_COMPILE_TARGET_TYPE to STATIC_LIBRARY) +# +# ARCHS: (armv7 armv7s armv7k arm64 arm64_32 i386 x86_64) If specified, will override the default architectures for the given PLATFORM +# OS = armv7 armv7s arm64 (if applicable) +# OS64 = arm64 (if applicable) +# SIMULATOR = i386 +# SIMULATOR64 = x86_64 +# SIMULATORARM64 = arm64 +# TVOS = arm64 +# SIMULATOR_TVOS = x86_64 (i386 has since long been deprecated) +# SIMULATORARM64_TVOS = arm64 +# WATCHOS = armv7k arm64_32 (if applicable) +# SIMULATOR_WATCHOS = x86_64 (i386 has since long been deprecated) +# SIMULATORARM64_WATCHOS = arm64 +# MAC = x86_64 +# MAC_ARM64 = arm64 +# MAC_UNIVERSAL = x86_64 arm64 +# MAC_CATALYST = x86_64 +# MAC_CATALYST_ARM64 = arm64 +# +# NOTE: When manually specifying ARCHS, put a semi-colon between the entries. E.g., -DARCHS="armv7;arm64" +# +############################################################################### +# END OPTIONS # +############################################################################### +# +# This toolchain defines the following properties (available via get_property()) for use externally: +# +# PLATFORM: The currently targeted platform. +# XCODE_VERSION: Version number (not including Build version) of Xcode detected. +# SDK_VERSION: Version of SDK being used. +# OSX_ARCHITECTURES: Architectures being compiled for (generated from PLATFORM). +# APPLE_TARGET_TRIPLE: Used by autoconf build systems. NOTE: If "ARCHS" is overridden, this will *NOT* be set! +# +# This toolchain defines the following macros for use externally: +# +# set_xcode_property (TARGET XCODE_PROPERTY XCODE_VALUE XCODE_VARIANT) +# A convenience macro for setting xcode specific properties on targets. +# Available variants are: All, Release, RelWithDebInfo, Debug, MinSizeRel +# example: set_xcode_property (myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1" "all"). +# +# find_host_package (PROGRAM ARGS) +# A macro used to find executable programs on the host system, not within the +# environment. Thanks to the android-cmake project for providing the +# command. +# + +cmake_minimum_required(VERSION 3.8.0) + +# CMake invokes the toolchain file twice during the first build, but only once during subsequent rebuilds. +if(DEFINED ENV{_IOS_TOOLCHAIN_HAS_RUN}) + return() +endif() +set(ENV{_IOS_TOOLCHAIN_HAS_RUN} true) + +# List of supported platform values +list(APPEND _supported_platforms + "OS" "OS64" "OS64COMBINED" "SIMULATOR" "SIMULATOR64" "SIMULATORARM64" "SIMULATOR64COMBINED" + "TVOS" "TVOSCOMBINED" "SIMULATOR_TVOS" "SIMULATORARM64_TVOS" + "WATCHOS" "WATCHOSCOMBINED" "SIMULATOR_WATCHOS" "SIMULATORARM64_WATCHOS" + "MAC" "MAC_ARM64" "MAC_UNIVERSAL" + "VISIONOS" "SIMULATOR_VISIONOS" "VISIONOSCOMBINED" + "MAC_CATALYST" "MAC_CATALYST_ARM64") + +# Cache what generator is used +set(USED_CMAKE_GENERATOR "${CMAKE_GENERATOR}") + +# Check if using a CMake version capable of building combined FAT builds (simulator and target slices combined in one static lib) +if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14") + set(MODERN_CMAKE YES) +endif() + +# Get the Xcode version being used. +# Problem: CMake runs toolchain files multiple times, but can't read cache variables on some runs. +# Workaround: On the first run (in which cache variables are always accessible), set an intermediary environment variable. +# +# NOTE: This pattern is used in many places in this toolchain to speed up checks of all sorts +if(DEFINED XCODE_VERSION_INT) + # Environment variables are always preserved. + set(ENV{_XCODE_VERSION_INT} "${XCODE_VERSION_INT}") +elseif(DEFINED ENV{_XCODE_VERSION_INT}) + set(XCODE_VERSION_INT "$ENV{_XCODE_VERSION_INT}") +elseif(NOT DEFINED XCODE_VERSION_INT) + find_program(XCODEBUILD_EXECUTABLE xcodebuild) + if(NOT XCODEBUILD_EXECUTABLE) + message(FATAL_ERROR "xcodebuild not found. Please install either the standalone commandline tools or Xcode.") + endif() + execute_process(COMMAND ${XCODEBUILD_EXECUTABLE} -version + OUTPUT_VARIABLE XCODE_VERSION_INT + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REGEX MATCH "Xcode [0-9\\.]+" XCODE_VERSION_INT "${XCODE_VERSION_INT}") + string(REGEX REPLACE "Xcode ([0-9\\.]+)" "\\1" XCODE_VERSION_INT "${XCODE_VERSION_INT}") + set(XCODE_VERSION_INT "${XCODE_VERSION_INT}" CACHE INTERNAL "") +endif() + +# Assuming that xcode 12.0 is installed you most probably have ios sdk 14.0 or later installed (tested on Big Sur) +# if you don't set a deployment target it will be set the way you only get 64-bit builds +#if(NOT DEFINED DEPLOYMENT_TARGET AND XCODE_VERSION_INT VERSION_GREATER 12.0) +# Temporarily fix the arm64 issues in CMake install-combined by excluding arm64 for simulator builds (needed for Apple Silicon...) +# set(CMAKE_XCODE_ATTRIBUTE_EXCLUDED_ARCHS[sdk=iphonesimulator*] "arm64") +#endif() + +# Check if the platform variable is set +if(DEFINED PLATFORM) + # Environment variables are always preserved. + set(ENV{_PLATFORM} "${PLATFORM}") +elseif(DEFINED ENV{_PLATFORM}) + set(PLATFORM "$ENV{_PLATFORM}") +elseif(NOT DEFINED PLATFORM) + message(FATAL_ERROR "PLATFORM argument not set. Bailing configure since I don't know what target you want to build for!") +endif () + +if(PLATFORM MATCHES ".*COMBINED" AND NOT CMAKE_GENERATOR MATCHES "Xcode") + message(FATAL_ERROR "The combined builds support requires Xcode to be used as a generator via '-G Xcode' command-line argument in CMake") +endif() + +# Safeguard that the platform value is set and is one of the supported values +list(FIND _supported_platforms ${PLATFORM} contains_PLATFORM) +if("${contains_PLATFORM}" EQUAL "-1") + string(REPLACE ";" "\n * " _supported_platforms_formatted "${_supported_platforms}") + message(FATAL_ERROR " Invalid PLATFORM specified! Current value: ${PLATFORM}.\n" + " Supported PLATFORM values: \n * ${_supported_platforms_formatted}") +endif() + +# Check if Apple Silicon is supported +if(PLATFORM MATCHES "^(MAC_ARM64)$|^(MAC_CATALYST_ARM64)$|^(MAC_UNIVERSAL)$" AND ${CMAKE_VERSION} VERSION_LESS "3.19.5") + message(FATAL_ERROR "Apple Silicon builds requires a minimum of CMake 3.19.5") +endif() + +# Touch the toolchain variable to suppress the "unused variable" warning. +# This happens if CMake is invoked with the same command line the second time. +if(CMAKE_TOOLCHAIN_FILE) +endif() + +# Fix for PThread library not in path +set(CMAKE_THREAD_LIBS_INIT "-lpthread") +set(CMAKE_HAVE_THREADS_LIBRARY 1) +set(CMAKE_USE_WIN32_THREADS_INIT 0) +set(CMAKE_USE_PTHREADS_INIT 1) + +# Specify named language support defaults. +if(NOT DEFINED NAMED_LANGUAGE_SUPPORT AND ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16") + set(NAMED_LANGUAGE_SUPPORT ON) + message(STATUS "[DEFAULTS] Using explicit named language support! E.g., enable_language(CXX) is needed in the project files.") +elseif(NOT DEFINED NAMED_LANGUAGE_SUPPORT AND ${CMAKE_VERSION} VERSION_LESS "3.16") + set(NAMED_LANGUAGE_SUPPORT OFF) + message(STATUS "[DEFAULTS] Disabling explicit named language support. Falling back to legacy behavior.") +elseif(DEFINED NAMED_LANGUAGE_SUPPORT AND ${CMAKE_VERSION} VERSION_LESS "3.16") + message(FATAL_ERROR "CMake named language support for OBJC and OBJCXX was added in CMake 3.16.") +endif() +set(NAMED_LANGUAGE_SUPPORT_INT ${NAMED_LANGUAGE_SUPPORT} CACHE BOOL + "Whether or not to enable explicit named language support" FORCE) + +# Specify the minimum version of the deployment target. +if(NOT DEFINED DEPLOYMENT_TARGET) + if (PLATFORM MATCHES "WATCHOS") + # Unless specified, SDK version 4.0 is used by default as minimum target version (watchOS). + set(DEPLOYMENT_TARGET "6.0") + elseif(PLATFORM STREQUAL "MAC") + # Unless specified, SDK version 10.13 (High Sierra) is used by default as the minimum target version (macos). + set(DEPLOYMENT_TARGET "11.0") + elseif(PLATFORM STREQUAL "VISIONOS" OR PLATFORM STREQUAL "SIMULATOR_VISIONOS" OR PLATFORM STREQUAL "VISIONOSCOMBINED") + # Unless specified, SDK version 1.0 is used by default as minimum target version (visionOS). + set(DEPLOYMENT_TARGET "1.0") + elseif(PLATFORM STREQUAL "MAC_ARM64") + # Unless specified, SDK version 11.0 (Big Sur) is used by default as the minimum target version (macOS on arm). + set(DEPLOYMENT_TARGET "11.0") + elseif(PLATFORM STREQUAL "MAC_UNIVERSAL") + # Unless specified, SDK version 11.0 (Big Sur) is used by default as minimum target version for universal builds. + set(DEPLOYMENT_TARGET "11.0") + elseif(PLATFORM STREQUAL "MAC_CATALYST" OR PLATFORM STREQUAL "MAC_CATALYST_ARM64") + # Unless specified, SDK version 13.0 is used by default as the minimum target version (mac catalyst minimum requirement). + set(DEPLOYMENT_TARGET "13.1") + else() + # Unless specified, SDK version 11.0 is used by default as the minimum target version (iOS, tvOS). + set(DEPLOYMENT_TARGET "13.0") + endif() + message(STATUS "[DEFAULTS] Using the default min-version since DEPLOYMENT_TARGET not provided!") +elseif(DEFINED DEPLOYMENT_TARGET AND PLATFORM MATCHES "^MAC_CATALYST" AND ${DEPLOYMENT_TARGET} VERSION_LESS "13.1") + message(FATAL_ERROR "Mac Catalyst builds requires a minimum deployment target of 13.1!") +endif() + +# Store the DEPLOYMENT_TARGET in the cache +set(DEPLOYMENT_TARGET "${DEPLOYMENT_TARGET}" CACHE INTERNAL "") + +# Handle the case where we are targeting iOS and a version above 10.3.4 (32-bit support dropped officially) +if(PLATFORM STREQUAL "OS" AND DEPLOYMENT_TARGET VERSION_GREATER_EQUAL 10.3.4) + set(PLATFORM "OS64") + message(STATUS "Targeting minimum SDK version ${DEPLOYMENT_TARGET}. Dropping 32-bit support.") +elseif(PLATFORM STREQUAL "SIMULATOR" AND DEPLOYMENT_TARGET VERSION_GREATER_EQUAL 10.3.4) + set(PLATFORM "SIMULATOR64") + message(STATUS "Targeting minimum SDK version ${DEPLOYMENT_TARGET}. Dropping 32-bit support.") +endif() + +set(PLATFORM_INT "${PLATFORM}") + +if(DEFINED ARCHS) + string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}") +endif() + +# Determine the platform name and architectures for use in xcodebuild commands +# from the specified PLATFORM_INT name. +if(PLATFORM_INT STREQUAL "OS") + set(SDK_NAME iphoneos) + if(NOT ARCHS) + set(ARCHS armv7 armv7s arm64) + set(APPLE_TARGET_TRIPLE_INT arm-apple-ios${DEPLOYMENT_TARGET}) + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}) + endif() +elseif(PLATFORM_INT STREQUAL "OS64") + set(SDK_NAME iphoneos) + if(NOT ARCHS) + if (XCODE_VERSION_INT VERSION_GREATER 10.0) + set(ARCHS arm64) # FIXME: Add arm64e when Apple has fixed the integration issues with it, libarclite_iphoneos.a is currently missing bitcode markers for example + else() + set(ARCHS arm64) + endif() + set(APPLE_TARGET_TRIPLE_INT arm64-apple-ios${DEPLOYMENT_TARGET}) + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}) + endif() +elseif(PLATFORM_INT STREQUAL "OS64COMBINED") + set(SDK_NAME iphoneos) + if(MODERN_CMAKE) + if(NOT ARCHS) + if (XCODE_VERSION_INT VERSION_GREATER 12.0) + set(ARCHS arm64 x86_64) + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphoneos*] "arm64") + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphonesimulator*] "x86_64 arm64") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphoneos*] "arm64") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphonesimulator*] "x86_64 arm64") + else() + set(ARCHS arm64 x86_64) + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphoneos*] "arm64") + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphonesimulator*] "x86_64") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphoneos*] "arm64") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphonesimulator*] "x86_64") + endif() + set(APPLE_TARGET_TRIPLE_INT arm64-x86_64-apple-ios${DEPLOYMENT_TARGET}) + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}) + endif() + else() + message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the OS64COMBINED setting work") + endif() +elseif(PLATFORM_INT STREQUAL "SIMULATOR64COMBINED") + set(SDK_NAME iphonesimulator) + if(MODERN_CMAKE) + if(NOT ARCHS) + if (XCODE_VERSION_INT VERSION_GREATER 12.0) + set(ARCHS arm64 x86_64) # FIXME: Add arm64e when Apple have fixed the integration issues with it, libarclite_iphoneos.a is currently missing bitcode markers for example + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphoneos*] "") + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphonesimulator*] "x86_64 arm64") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphoneos*] "") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphonesimulator*] "x86_64 arm64") + else() + set(ARCHS arm64 x86_64) + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphoneos*] "") + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphonesimulator*] "x86_64") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphoneos*] "") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphonesimulator*] "x86_64") + endif() + set(APPLE_TARGET_TRIPLE_INT aarch64-x86_64-apple-ios${DEPLOYMENT_TARGET}-simulator) + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-simulator) + endif() + else() + message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the SIMULATOR64COMBINED setting work") + endif() +elseif(PLATFORM_INT STREQUAL "SIMULATOR") + set(SDK_NAME iphonesimulator) + if(NOT ARCHS) + set(ARCHS i386) + set(APPLE_TARGET_TRIPLE_INT i386-apple-ios${DEPLOYMENT_TARGET}-simulator) + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-simulator) + endif() + message(DEPRECATION "SIMULATOR IS DEPRECATED. Consider using SIMULATOR64 instead.") +elseif(PLATFORM_INT STREQUAL "SIMULATOR64") + set(SDK_NAME iphonesimulator) + if(NOT ARCHS) + set(ARCHS x86_64) + set(APPLE_TARGET_TRIPLE_INT x86_64-apple-ios${DEPLOYMENT_TARGET}-simulator) + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-simulator) + endif() +elseif(PLATFORM_INT STREQUAL "SIMULATORARM64") + set(SDK_NAME iphonesimulator) + if(NOT ARCHS) + set(ARCHS arm64) + set(APPLE_TARGET_TRIPLE_INT arm64-apple-ios${DEPLOYMENT_TARGET}-simulator) + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-simulator) + endif() +elseif(PLATFORM_INT STREQUAL "TVOS") + set(SDK_NAME appletvos) + if(NOT ARCHS) + set(ARCHS arm64) + set(APPLE_TARGET_TRIPLE_INT arm64-apple-tvos${DEPLOYMENT_TARGET}) + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-tvos${DEPLOYMENT_TARGET}) + endif() +elseif (PLATFORM_INT STREQUAL "TVOSCOMBINED") + set(SDK_NAME appletvos) + if(MODERN_CMAKE) + if(NOT ARCHS) + set(ARCHS arm64 x86_64) + set(APPLE_TARGET_TRIPLE_INT arm64-x86_64-apple-tvos${DEPLOYMENT_TARGET}) + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=appletvos*] "arm64") + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=appletvsimulator*] "x86_64 arm64") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=appletvos*] "arm64") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=appletvsimulator*] "x86_64 arm64") + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-tvos${DEPLOYMENT_TARGET}) + endif() + else() + message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the TVOSCOMBINED setting work") + endif() +elseif(PLATFORM_INT STREQUAL "SIMULATOR_TVOS") + set(SDK_NAME appletvsimulator) + if(NOT ARCHS) + set(ARCHS x86_64) + set(APPLE_TARGET_TRIPLE_INT x86_64-apple-tvos${DEPLOYMENT_TARGET}-simulator) + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-tvos${DEPLOYMENT_TARGET}-simulator) + endif() +elseif(PLATFORM_INT STREQUAL "SIMULATORARM64_TVOS") + set(SDK_NAME appletvsimulator) + if(NOT ARCHS) + set(ARCHS arm64) + set(APPLE_TARGET_TRIPLE_INT arm64-apple-tvos${DEPLOYMENT_TARGET}-simulator) + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-tvos${DEPLOYMENT_TARGET}-simulator) + endif() +elseif(PLATFORM_INT STREQUAL "WATCHOS") + set(SDK_NAME watchos) + if(NOT ARCHS) + if (XCODE_VERSION_INT VERSION_GREATER 10.0) + set(ARCHS armv7k arm64_32) + set(APPLE_TARGET_TRIPLE_INT arm64_32-apple-watchos${DEPLOYMENT_TARGET}) + else() + set(ARCHS armv7k) + set(APPLE_TARGET_TRIPLE_INT arm-apple-watchos${DEPLOYMENT_TARGET}) + endif() + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos${DEPLOYMENT_TARGET}) + endif() +elseif(PLATFORM_INT STREQUAL "WATCHOSCOMBINED") + set(SDK_NAME watchos) + if(MODERN_CMAKE) + if(NOT ARCHS) + if (XCODE_VERSION_INT VERSION_GREATER 10.0) + set(ARCHS armv7k arm64_32 i386) + set(APPLE_TARGET_TRIPLE_INT arm64_32-i386-apple-watchos${DEPLOYMENT_TARGET}) + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchos*] "armv7k arm64_32") + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchsimulator*] "i386") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchos*] "armv7k arm64_32") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchsimulator*] "i386") + else() + set(ARCHS armv7k i386) + set(APPLE_TARGET_TRIPLE_INT arm-i386-apple-watchos${DEPLOYMENT_TARGET}) + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchos*] "armv7k") + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchsimulator*] "i386") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchos*] "armv7k") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchsimulator*] "i386") + endif() + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos${DEPLOYMENT_TARGET}) + endif() + else() + message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the WATCHOSCOMBINED setting work") + endif() +elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS") + set(SDK_NAME watchsimulator) + if(NOT ARCHS) + set(ARCHS i386) + set(APPLE_TARGET_TRIPLE_INT i386-apple-watchos${DEPLOYMENT_TARGET}-simulator) + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos${DEPLOYMENT_TARGET}-simulator) + endif() +elseif(PLATFORM_INT STREQUAL "SIMULATORARM64_WATCHOS") + set(SDK_NAME watchsimulator) + if(NOT ARCHS) + set(ARCHS arm64) + set(APPLE_TARGET_TRIPLE_INT arm64-apple-watchos${DEPLOYMENT_TARGET}-simulator) + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos${DEPLOYMENT_TARGET}-simulator) + endif() +elseif(PLATFORM_INT STREQUAL "SIMULATOR_VISIONOS") + set(SDK_NAME xrsimulator) + if(NOT ARCHS) + set(ARCHS arm64) + set(APPLE_TARGET_TRIPLE_INT arm64-apple-xros${DEPLOYMENT_TARGET}-simulator) + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-xros${DEPLOYMENT_TARGET}-simulator) + endif() +elseif(PLATFORM_INT STREQUAL "VISIONOS") + set(SDK_NAME xros) + if(NOT ARCHS) + set(ARCHS arm64) + set(APPLE_TARGET_TRIPLE_INT arm64-apple-xros${DEPLOYMENT_TARGET}) + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-xros${DEPLOYMENT_TARGET}) + endif() +elseif(PLATFORM_INT STREQUAL "VISIONOSCOMBINED") + set(SDK_NAME xros) + if(MODERN_CMAKE) + if(NOT ARCHS) + set(ARCHS arm64) + set(APPLE_TARGET_TRIPLE_INT arm64-apple-xros${DEPLOYMENT_TARGET}) + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=xros*] "arm64") + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=xrsimulator*] "arm64") + else() + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-xros${DEPLOYMENT_TARGET}) + endif() + else() + message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the VISIONOSCOMBINED setting work") + endif() +elseif(PLATFORM_INT STREQUAL "MAC" OR PLATFORM_INT STREQUAL "MAC_CATALYST") + set(SDK_NAME macosx) + if(NOT ARCHS) + set(ARCHS x86_64) + endif() + string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}") + if(PLATFORM_INT STREQUAL "MAC") + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-macosx${DEPLOYMENT_TARGET}) + elseif(PLATFORM_INT STREQUAL "MAC_CATALYST") + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-macabi) + endif() +elseif(PLATFORM_INT MATCHES "^(MAC_ARM64)$|^(MAC_CATALYST_ARM64)$") + set(SDK_NAME macosx) + if(NOT ARCHS) + set(ARCHS arm64) + endif() + string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}") + if(PLATFORM_INT STREQUAL "MAC_ARM64") + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-macosx${DEPLOYMENT_TARGET}) + elseif(PLATFORM_INT STREQUAL "MAC_CATALYST_ARM64") + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-macabi) + endif() +elseif(PLATFORM_INT STREQUAL "MAC_UNIVERSAL") + set(SDK_NAME macosx) + if(NOT ARCHS) + set(ARCHS "x86_64;arm64") + endif() + string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}") + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-macosx${DEPLOYMENT_TARGET}) +else() + message(FATAL_ERROR "Invalid PLATFORM: ${PLATFORM_INT}") +endif() + +string(REPLACE ";" " " ARCHS_SPACED "${ARCHS}") + +if(MODERN_CMAKE AND PLATFORM_INT MATCHES ".*COMBINED" AND NOT CMAKE_GENERATOR MATCHES "Xcode") + message(FATAL_ERROR "The COMBINED options only work with Xcode generator, -G Xcode") +endif() + +if(CMAKE_GENERATOR MATCHES "Xcode" AND PLATFORM_INT MATCHES "^MAC_CATALYST") + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") + set(CMAKE_XCODE_ATTRIBUTE_SUPPORTED_PLATFORMS "macosx") + set(CMAKE_XCODE_ATTRIBUTE_SUPPORTS_MACCATALYST "YES") + if(NOT DEFINED MACOSX_DEPLOYMENT_TARGET) + set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "10.15") + else() + set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "${MACOSX_DEPLOYMENT_TARGET}") + endif() +elseif(CMAKE_GENERATOR MATCHES "Xcode") + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") + set(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "${DEPLOYMENT_TARGET}") + if(NOT PLATFORM_INT MATCHES ".*COMBINED") + set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=${SDK_NAME}*] "${ARCHS_SPACED}") + set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=${SDK_NAME}*] "${ARCHS_SPACED}") + endif() +endif() + +# If the user did not specify the SDK root to use, then query xcodebuild for it. +if(DEFINED CMAKE_OSX_SYSROOT_INT) + # Environment variables are always preserved. + set(ENV{_CMAKE_OSX_SYSROOT_INT} "${CMAKE_OSX_SYSROOT_INT}") +elseif(DEFINED ENV{_CMAKE_OSX_SYSROOT_INT}) + set(CMAKE_OSX_SYSROOT_INT "$ENV{_CMAKE_OSX_SYSROOT_INT}") +elseif(NOT DEFINED CMAKE_OSX_SYSROOT_INT) + execute_process(COMMAND ${XCODEBUILD_EXECUTABLE} -version -sdk ${SDK_NAME} Path + OUTPUT_VARIABLE CMAKE_OSX_SYSROOT_INT + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() + +if (NOT DEFINED CMAKE_OSX_SYSROOT_INT AND NOT DEFINED CMAKE_OSX_SYSROOT) + message(SEND_ERROR "Please make sure that Xcode is installed and that the toolchain" + "is pointing to the correct path. Please run:" + "sudo xcode-select -s /Applications/Xcode.app/Contents/Developer" + "and see if that fixes the problem for you.") + message(FATAL_ERROR "Invalid CMAKE_OSX_SYSROOT: ${CMAKE_OSX_SYSROOT} " + "does not exist.") +elseif(DEFINED CMAKE_OSX_SYSROOT_INT) + set(CMAKE_OSX_SYSROOT_INT "${CMAKE_OSX_SYSROOT_INT}" CACHE INTERNAL "") + # Specify the location or name of the platform SDK to be used in CMAKE_OSX_SYSROOT. + set(CMAKE_OSX_SYSROOT "${CMAKE_OSX_SYSROOT_INT}" CACHE INTERNAL "") +endif() + +# Use bitcode or not +if(NOT DEFINED ENABLE_BITCODE) + message(STATUS "[DEFAULTS] Disabling bitcode support by default. ENABLE_BITCODE not provided for override!") + set(ENABLE_BITCODE OFF) +endif() +set(ENABLE_BITCODE_INT ${ENABLE_BITCODE} CACHE BOOL + "Whether or not to enable bitcode" FORCE) +# Use ARC or not +if(NOT DEFINED ENABLE_ARC) + # Unless specified, enable ARC support by default + set(ENABLE_ARC ON) + message(STATUS "[DEFAULTS] Enabling ARC support by default. ENABLE_ARC not provided!") +endif() +set(ENABLE_ARC_INT ${ENABLE_ARC} CACHE BOOL "Whether or not to enable ARC" FORCE) +# Use hidden visibility or not +if(NOT DEFINED ENABLE_VISIBILITY) + # Unless specified, disable symbols visibility by default + set(ENABLE_VISIBILITY OFF) + message(STATUS "[DEFAULTS] Hiding symbols visibility by default. ENABLE_VISIBILITY not provided!") +endif() +set(ENABLE_VISIBILITY_INT ${ENABLE_VISIBILITY} CACHE BOOL "Whether or not to hide symbols from the dynamic linker (-fvisibility=hidden)" FORCE) +# Set strict compiler checks or not +if(NOT DEFINED ENABLE_STRICT_TRY_COMPILE) + # Unless specified, disable strict try_compile() + set(ENABLE_STRICT_TRY_COMPILE OFF) + message(STATUS "[DEFAULTS] Using NON-strict compiler checks by default. ENABLE_STRICT_TRY_COMPILE not provided!") +endif() +set(ENABLE_STRICT_TRY_COMPILE_INT ${ENABLE_STRICT_TRY_COMPILE} CACHE BOOL + "Whether or not to use strict compiler checks" FORCE) + +# Get the SDK version information. +if(DEFINED SDK_VERSION) + # Environment variables are always preserved. + set(ENV{_SDK_VERSION} "${SDK_VERSION}") +elseif(DEFINED ENV{_SDK_VERSION}) + set(SDK_VERSION "$ENV{_SDK_VERSION}") +elseif(NOT DEFINED SDK_VERSION) + execute_process(COMMAND ${XCODEBUILD_EXECUTABLE} -sdk ${CMAKE_OSX_SYSROOT_INT} -version SDKVersion + OUTPUT_VARIABLE SDK_VERSION + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() + +# Find the Developer root for the specific iOS platform being compiled for +# from CMAKE_OSX_SYSROOT. Should be ../../ from SDK specified in +# CMAKE_OSX_SYSROOT. There does not appear to be a direct way to obtain +# this information from xcrun or xcodebuild. +if (NOT DEFINED CMAKE_DEVELOPER_ROOT AND NOT CMAKE_GENERATOR MATCHES "Xcode") + get_filename_component(PLATFORM_SDK_DIR ${CMAKE_OSX_SYSROOT_INT} PATH) + get_filename_component(CMAKE_DEVELOPER_ROOT ${PLATFORM_SDK_DIR} PATH) + if (NOT EXISTS "${CMAKE_DEVELOPER_ROOT}") + message(FATAL_ERROR "Invalid CMAKE_DEVELOPER_ROOT: ${CMAKE_DEVELOPER_ROOT} does not exist.") + endif() +endif() + +# Find the C & C++ compilers for the specified SDK. +if(DEFINED CMAKE_C_COMPILER) + # Environment variables are always preserved. + set(ENV{_CMAKE_C_COMPILER} "${CMAKE_C_COMPILER}") +elseif(DEFINED ENV{_CMAKE_C_COMPILER}) + set(CMAKE_C_COMPILER "$ENV{_CMAKE_C_COMPILER}") + set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) +elseif(NOT DEFINED CMAKE_C_COMPILER) + execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT_INT} -find clang + OUTPUT_VARIABLE CMAKE_C_COMPILER + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) +endif() +if(DEFINED CMAKE_CXX_COMPILER) + # Environment variables are always preserved. + set(ENV{_CMAKE_CXX_COMPILER} "${CMAKE_CXX_COMPILER}") +elseif(DEFINED ENV{_CMAKE_CXX_COMPILER}) + set(CMAKE_CXX_COMPILER "$ENV{_CMAKE_CXX_COMPILER}") +elseif(NOT DEFINED CMAKE_CXX_COMPILER) + execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT_INT} -find clang++ + OUTPUT_VARIABLE CMAKE_CXX_COMPILER + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() +# Find (Apple's) libtool. +if(DEFINED BUILD_LIBTOOL) + # Environment variables are always preserved. + set(ENV{_BUILD_LIBTOOL} "${BUILD_LIBTOOL}") +elseif(DEFINED ENV{_BUILD_LIBTOOL}) + set(BUILD_LIBTOOL "$ENV{_BUILD_LIBTOOL}") +elseif(NOT DEFINED BUILD_LIBTOOL) + execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT_INT} -find libtool + OUTPUT_VARIABLE BUILD_LIBTOOL + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() +# Find the toolchain's provided install_name_tool if none is found on the host +if(DEFINED CMAKE_INSTALL_NAME_TOOL) + # Environment variables are always preserved. + set(ENV{_CMAKE_INSTALL_NAME_TOOL} "${CMAKE_INSTALL_NAME_TOOL}") +elseif(DEFINED ENV{_CMAKE_INSTALL_NAME_TOOL}) + set(CMAKE_INSTALL_NAME_TOOL "$ENV{_CMAKE_INSTALL_NAME_TOOL}") +elseif(NOT DEFINED CMAKE_INSTALL_NAME_TOOL) + execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT_INT} -find install_name_tool + OUTPUT_VARIABLE CMAKE_INSTALL_NAME_TOOL_INT + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + set(CMAKE_INSTALL_NAME_TOOL ${CMAKE_INSTALL_NAME_TOOL_INT} CACHE INTERNAL "") +endif() + +# Configure libtool to be used instead of ar + ranlib to build static libraries. +# This is required on Xcode 7+, but should also work on previous versions of +# Xcode. +get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES) +foreach(lang ${languages}) + set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "${BUILD_LIBTOOL} -static -o " CACHE INTERNAL "") +endforeach() + +# CMake 3.14+ support building for iOS, watchOS, and tvOS out of the box. +if(MODERN_CMAKE) + if(SDK_NAME MATCHES "iphone") + set(CMAKE_SYSTEM_NAME iOS) + elseif(SDK_NAME MATCHES "xros") + set(CMAKE_SYSTEM_NAME visionOS) + elseif(SDK_NAME MATCHES "xrsimulator") + set(CMAKE_SYSTEM_NAME visionOS) + elseif(SDK_NAME MATCHES "macosx") + set(CMAKE_SYSTEM_NAME Darwin) + elseif(SDK_NAME MATCHES "appletv") + set(CMAKE_SYSTEM_NAME tvOS) + elseif(SDK_NAME MATCHES "watch") + set(CMAKE_SYSTEM_NAME watchOS) + endif() + # Provide flags for a combined FAT library build on newer CMake versions + if(PLATFORM_INT MATCHES ".*COMBINED") + set(CMAKE_IOS_INSTALL_COMBINED YES) + if(CMAKE_GENERATOR MATCHES "Xcode") + # Set the SDKROOT Xcode properties to a Xcode-friendly value (the SDK_NAME, E.g, iphoneos) + # This way, Xcode will automatically switch between the simulator and device SDK when building. + set(CMAKE_XCODE_ATTRIBUTE_SDKROOT "${SDK_NAME}") + # Force to not build just one ARCH, but all! + set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH "NO") + endif() + endif() +elseif(NOT DEFINED CMAKE_SYSTEM_NAME AND ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.10") + # Legacy code path prior to CMake 3.14 or fallback if no CMAKE_SYSTEM_NAME specified + set(CMAKE_SYSTEM_NAME iOS) +elseif(NOT DEFINED CMAKE_SYSTEM_NAME) + # Legacy code path before CMake 3.14 or fallback if no CMAKE_SYSTEM_NAME specified + set(CMAKE_SYSTEM_NAME Darwin) +endif() +# Standard settings. +set(CMAKE_SYSTEM_VERSION ${SDK_VERSION} CACHE INTERNAL "") +set(UNIX ON CACHE BOOL "") +set(APPLE ON CACHE BOOL "") +if(PLATFORM STREQUAL "MAC" OR PLATFORM STREQUAL "MAC_ARM64" OR PLATFORM STREQUAL "MAC_UNIVERSAL") + set(IOS OFF CACHE BOOL "") + set(MACOS ON CACHE BOOL "") +elseif(PLATFORM STREQUAL "MAC_CATALYST" OR PLATFORM STREQUAL "MAC_CATALYST_ARM64") + set(IOS ON CACHE BOOL "") + set(MACOS ON CACHE BOOL "") +elseif(PLATFORM STREQUAL "VISIONOS" OR PLATFORM STREQUAL "SIMULATOR_VISIONOS" OR PLATFORM STREQUAL "VISIONOSCOMBINED") + set(IOS OFF CACHE BOOL "") + set(VISIONOS ON CACHE BOOL "") +else() + set(IOS ON CACHE BOOL "") +endif() +# Set the architectures for which to build. +set(CMAKE_OSX_ARCHITECTURES ${ARCHS} CACHE INTERNAL "") +# Change the type of target generated for try_compile() so it'll work when cross-compiling, weak compiler checks +if(NOT ENABLE_STRICT_TRY_COMPILE_INT) + set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) +endif() +# All iOS/Darwin specific settings - some may be redundant. +if (NOT DEFINED CMAKE_MACOSX_BUNDLE) + set(CMAKE_MACOSX_BUNDLE YES) +endif() +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") +set(CMAKE_SHARED_LIBRARY_PREFIX "lib") +set(CMAKE_SHARED_LIBRARY_SUFFIX ".dylib") +set(CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES ".tbd" ".so") +set(CMAKE_SHARED_MODULE_PREFIX "lib") +set(CMAKE_SHARED_MODULE_SUFFIX ".so") +set(CMAKE_C_COMPILER_ABI ELF) +set(CMAKE_CXX_COMPILER_ABI ELF) +set(CMAKE_C_HAS_ISYSROOT 1) +set(CMAKE_CXX_HAS_ISYSROOT 1) +set(CMAKE_MODULE_EXISTS 1) +set(CMAKE_DL_LIBS "") +set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ") +set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ") +set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}") +set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}") + +if(ARCHS MATCHES "((^|;|, )(arm64|arm64e|x86_64))+") + set(CMAKE_C_SIZEOF_DATA_PTR 8) + set(CMAKE_CXX_SIZEOF_DATA_PTR 8) + if(ARCHS MATCHES "((^|;|, )(arm64|arm64e))+") + set(CMAKE_SYSTEM_PROCESSOR "aarch64") + else() + set(CMAKE_SYSTEM_PROCESSOR "x86_64") + endif() +else() + set(CMAKE_C_SIZEOF_DATA_PTR 4) + set(CMAKE_CXX_SIZEOF_DATA_PTR 4) + set(CMAKE_SYSTEM_PROCESSOR "arm") +endif() + +# Note that only Xcode 7+ supports the newer more specific: +# -m${SDK_NAME}-version-min flags, older versions of Xcode use: +# -m(ios/ios-simulator)-version-min instead. +if(${CMAKE_VERSION} VERSION_LESS "3.11") + if(PLATFORM_INT STREQUAL "OS" OR PLATFORM_INT STREQUAL "OS64") + if(XCODE_VERSION_INT VERSION_LESS 7.0) + set(SDK_NAME_VERSION_FLAGS + "-mios-version-min=${DEPLOYMENT_TARGET}") + else() + # Xcode 7.0+ uses flags we can build directly from SDK_NAME. + set(SDK_NAME_VERSION_FLAGS + "-m${SDK_NAME}-version-min=${DEPLOYMENT_TARGET}") + endif() + elseif(PLATFORM_INT STREQUAL "TVOS") + set(SDK_NAME_VERSION_FLAGS + "-mtvos-version-min=${DEPLOYMENT_TARGET}") + elseif(PLATFORM_INT STREQUAL "SIMULATOR_TVOS") + set(SDK_NAME_VERSION_FLAGS + "-mtvos-simulator-version-min=${DEPLOYMENT_TARGET}") +elseif(PLATFORM_INT STREQUAL "SIMULATORARM64_TVOS") + set(SDK_NAME_VERSION_FLAGS + "-mtvos-simulator-version-min=${DEPLOYMENT_TARGET}") + elseif(PLATFORM_INT STREQUAL "WATCHOS") + set(SDK_NAME_VERSION_FLAGS + "-mwatchos-version-min=${DEPLOYMENT_TARGET}") + elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS") + set(SDK_NAME_VERSION_FLAGS + "-mwatchos-simulator-version-min=${DEPLOYMENT_TARGET}") + elseif(PLATFORM_INT STREQUAL "SIMULATORARM64_WATCHOS") + set(SDK_NAME_VERSION_FLAGS + "-mwatchos-simulator-version-min=${DEPLOYMENT_TARGET}") + elseif(PLATFORM_INT STREQUAL "MAC") + set(SDK_NAME_VERSION_FLAGS + "-mmacosx-version-min=${DEPLOYMENT_TARGET}") + else() + # SIMULATOR or SIMULATOR64 both use -mios-simulator-version-min. + set(SDK_NAME_VERSION_FLAGS + "-mios-simulator-version-min=${DEPLOYMENT_TARGET}") + endif() +elseif(NOT PLATFORM_INT MATCHES "^MAC_CATALYST") + # Newer versions of CMake sets the version min flags correctly, skip this for Mac Catalyst targets + set(CMAKE_OSX_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET} CACHE INTERNAL "Minimum OS X deployment version") +endif() + +if(DEFINED APPLE_TARGET_TRIPLE_INT) + set(APPLE_TARGET_TRIPLE ${APPLE_TARGET_TRIPLE_INT} CACHE INTERNAL "") + set(CMAKE_C_COMPILER_TARGET ${APPLE_TARGET_TRIPLE}) + set(CMAKE_CXX_COMPILER_TARGET ${APPLE_TARGET_TRIPLE}) + set(CMAKE_ASM_COMPILER_TARGET ${APPLE_TARGET_TRIPLE}) +endif() + +if(PLATFORM_INT MATCHES "^MAC_CATALYST") + set(C_TARGET_FLAGS "-isystem ${CMAKE_OSX_SYSROOT_INT}/System/iOSSupport/usr/include -iframework ${CMAKE_OSX_SYSROOT_INT}/System/iOSSupport/System/Library/Frameworks") +endif() + +if(ENABLE_BITCODE_INT) + set(BITCODE "-fembed-bitcode") + set(CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE "bitcode") + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") +else() + set(BITCODE "") + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") +endif() + +if(ENABLE_ARC_INT) + set(FOBJC_ARC "-fobjc-arc") + set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "YES") +else() + set(FOBJC_ARC "-fno-objc-arc") + set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "NO") +endif() + +if(NAMED_LANGUAGE_SUPPORT_INT) + set(OBJC_VARS "-fobjc-abi-version=2 -DOBJC_OLD_DISPATCH_PROTOTYPES=0") + set(OBJC_LEGACY_VARS "") +else() + set(OBJC_VARS "") + set(OBJC_LEGACY_VARS "-fobjc-abi-version=2 -DOBJC_OLD_DISPATCH_PROTOTYPES=0") +endif() + +if(NOT ENABLE_VISIBILITY_INT) + foreach(lang ${languages}) + set(CMAKE_${lang}_VISIBILITY_PRESET "hidden" CACHE INTERNAL "") + endforeach() + set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN "YES") + set(VISIBILITY "-fvisibility=hidden -fvisibility-inlines-hidden") +else() + foreach(lang ${languages}) + set(CMAKE_${lang}_VISIBILITY_PRESET "default" CACHE INTERNAL "") + endforeach() + set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN "NO") + set(VISIBILITY "-fvisibility=default") +endif() + +if(DEFINED APPLE_TARGET_TRIPLE) + set(APPLE_TARGET_TRIPLE_FLAG "-target ${APPLE_TARGET_TRIPLE}") +endif() + +#Check if Xcode generator is used since that will handle these flags automagically +if(CMAKE_GENERATOR MATCHES "Xcode") + message(STATUS "Not setting any manual command-line buildflags, since Xcode is selected as the generator. Modifying the Xcode build-settings directly instead.") +else() + set(CMAKE_C_FLAGS "${C_TARGET_FLAGS} ${APPLE_TARGET_TRIPLE_FLAG} ${SDK_NAME_VERSION_FLAGS} ${OBJC_LEGACY_VARS} ${BITCODE} ${VISIBILITY} ${CMAKE_C_FLAGS}" CACHE INTERNAL + "Flags used by the compiler during all C build types.") + set(CMAKE_C_FLAGS_DEBUG "-O0 -g ${CMAKE_C_FLAGS_DEBUG}") + set(CMAKE_C_FLAGS_MINSIZEREL "-DNDEBUG -Os ${CMAKE_C_FLAGS_MINSIZEREL}") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "-DNDEBUG -O2 -g ${CMAKE_C_FLAGS_RELWITHDEBINFO}") + set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O3 ${CMAKE_C_FLAGS_RELEASE}") + set(CMAKE_CXX_FLAGS "${C_TARGET_FLAGS} ${APPLE_TARGET_TRIPLE_FLAG} ${SDK_NAME_VERSION_FLAGS} ${OBJC_LEGACY_VARS} ${BITCODE} ${VISIBILITY} ${CMAKE_CXX_FLAGS}" CACHE INTERNAL + "Flags used by the compiler during all CXX build types.") + set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g ${CMAKE_CXX_FLAGS_DEBUG}") + set(CMAKE_CXX_FLAGS_MINSIZEREL "-DNDEBUG -Os ${CMAKE_CXX_FLAGS_MINSIZEREL}") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-DNDEBUG -O2 -g ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") + set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3 ${CMAKE_CXX_FLAGS_RELEASE}") + if(NAMED_LANGUAGE_SUPPORT_INT) + set(CMAKE_OBJC_FLAGS "${C_TARGET_FLAGS} ${APPLE_TARGET_TRIPLE_FLAG} ${SDK_NAME_VERSION_FLAGS} ${BITCODE} ${VISIBILITY} ${FOBJC_ARC} ${OBJC_VARS} ${CMAKE_OBJC_FLAGS}" CACHE INTERNAL + "Flags used by the compiler during all OBJC build types.") + set(CMAKE_OBJC_FLAGS_DEBUG "-O0 -g ${CMAKE_OBJC_FLAGS_DEBUG}") + set(CMAKE_OBJC_FLAGS_MINSIZEREL "-DNDEBUG -Os ${CMAKE_OBJC_FLAGS_MINSIZEREL}") + set(CMAKE_OBJC_FLAGS_RELWITHDEBINFO "-DNDEBUG -O2 -g ${CMAKE_OBJC_FLAGS_RELWITHDEBINFO}") + set(CMAKE_OBJC_FLAGS_RELEASE "-DNDEBUG -O3 ${CMAKE_OBJC_FLAGS_RELEASE}") + set(CMAKE_OBJCXX_FLAGS "${C_TARGET_FLAGS} ${APPLE_TARGET_TRIPLE_FLAG} ${SDK_NAME_VERSION_FLAGS} ${BITCODE} ${VISIBILITY} ${FOBJC_ARC} ${OBJC_VARS} ${CMAKE_OBJCXX_FLAGS}" CACHE INTERNAL + "Flags used by the compiler during all OBJCXX build types.") + set(CMAKE_OBJCXX_FLAGS_DEBUG "-O0 -g ${CMAKE_OBJCXX_FLAGS_DEBUG}") + set(CMAKE_OBJCXX_FLAGS_MINSIZEREL "-DNDEBUG -Os ${CMAKE_OBJCXX_FLAGS_MINSIZEREL}") + set(CMAKE_OBJCXX_FLAGS_RELWITHDEBINFO "-DNDEBUG -O2 -g ${CMAKE_OBJCXX_FLAGS_RELWITHDEBINFO}") + set(CMAKE_OBJCXX_FLAGS_RELEASE "-DNDEBUG -O3 ${CMAKE_OBJCXX_FLAGS_RELEASE}") + endif() + set(CMAKE_C_LINK_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}" CACHE INTERNAL + "Flags used by the compiler for all C link types.") + set(CMAKE_CXX_LINK_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}" CACHE INTERNAL + "Flags used by the compiler for all CXX link types.") + if(NAMED_LANGUAGE_SUPPORT_INT) + set(CMAKE_OBJC_LINK_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_OBJC_LINK_FLAGS}" CACHE INTERNAL + "Flags used by the compiler for all OBJC link types.") + set(CMAKE_OBJCXX_LINK_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_OBJCXX_LINK_FLAGS}" CACHE INTERNAL + "Flags used by the compiler for all OBJCXX link types.") + endif() + set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS} -x assembler-with-cpp -arch ${CMAKE_OSX_ARCHITECTURES} ${APPLE_TARGET_TRIPLE_FLAG}" CACHE INTERNAL + "Flags used by the compiler for all ASM build types.") +endif() + +## Print status messages to inform of the current state +message(STATUS "Configuring ${SDK_NAME} build for platform: ${PLATFORM_INT}, architecture(s): ${ARCHS}") +message(STATUS "Using SDK: ${CMAKE_OSX_SYSROOT_INT}") +message(STATUS "Using C compiler: ${CMAKE_C_COMPILER}") +message(STATUS "Using CXX compiler: ${CMAKE_CXX_COMPILER}") +message(STATUS "Using libtool: ${BUILD_LIBTOOL}") +message(STATUS "Using install name tool: ${CMAKE_INSTALL_NAME_TOOL}") +if(DEFINED APPLE_TARGET_TRIPLE) + message(STATUS "Autoconf target triple: ${APPLE_TARGET_TRIPLE}") +endif() +message(STATUS "Using minimum deployment version: ${DEPLOYMENT_TARGET}" + " (SDK version: ${SDK_VERSION})") +if(MODERN_CMAKE) + message(STATUS "Merging integrated CMake 3.14+ iOS,tvOS,watchOS,macOS toolchain(s) with this toolchain!") + if(PLATFORM_INT MATCHES ".*COMBINED") + message(STATUS "Will combine built (static) artifacts into FAT lib...") + endif() +endif() +if(CMAKE_GENERATOR MATCHES "Xcode") + message(STATUS "Using Xcode version: ${XCODE_VERSION_INT}") +endif() +message(STATUS "CMake version: ${CMAKE_VERSION}") +if(DEFINED SDK_NAME_VERSION_FLAGS) + message(STATUS "Using version flags: ${SDK_NAME_VERSION_FLAGS}") +endif() +message(STATUS "Using a data_ptr size of: ${CMAKE_CXX_SIZEOF_DATA_PTR}") +if(ENABLE_BITCODE_INT) + message(STATUS "Bitcode: Enabled") +else() + message(STATUS "Bitcode: Disabled") +endif() + +if(ENABLE_ARC_INT) + message(STATUS "ARC: Enabled") +else() + message(STATUS "ARC: Disabled") +endif() + +if(ENABLE_VISIBILITY_INT) + message(STATUS "Hiding symbols: Disabled") +else() + message(STATUS "Hiding symbols: Enabled") +endif() + +# Set global properties +set_property(GLOBAL PROPERTY PLATFORM "${PLATFORM}") +set_property(GLOBAL PROPERTY APPLE_TARGET_TRIPLE "${APPLE_TARGET_TRIPLE_INT}") +set_property(GLOBAL PROPERTY SDK_VERSION "${SDK_VERSION}") +set_property(GLOBAL PROPERTY XCODE_VERSION "${XCODE_VERSION_INT}") +set_property(GLOBAL PROPERTY OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}") + +# Export configurable variables for the try_compile() command. +set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES + PLATFORM + XCODE_VERSION_INT + SDK_VERSION + NAMED_LANGUAGE_SUPPORT + DEPLOYMENT_TARGET + CMAKE_DEVELOPER_ROOT + CMAKE_OSX_SYSROOT_INT + ENABLE_BITCODE + ENABLE_ARC + CMAKE_ASM_COMPILER + CMAKE_C_COMPILER + CMAKE_C_COMPILER_TARGET + CMAKE_CXX_COMPILER + CMAKE_CXX_COMPILER_TARGET + BUILD_LIBTOOL + CMAKE_INSTALL_NAME_TOOL + CMAKE_C_FLAGS + CMAKE_C_DEBUG + CMAKE_C_MINSIZEREL + CMAKE_C_RELWITHDEBINFO + CMAKE_C_RELEASE + CMAKE_CXX_FLAGS + CMAKE_CXX_FLAGS_DEBUG + CMAKE_CXX_FLAGS_MINSIZEREL + CMAKE_CXX_FLAGS_RELWITHDEBINFO + CMAKE_CXX_FLAGS_RELEASE + CMAKE_C_LINK_FLAGS + CMAKE_CXX_LINK_FLAGS + CMAKE_ASM_FLAGS +) + +if(NAMED_LANGUAGE_SUPPORT_INT) + list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES + CMAKE_OBJC_FLAGS + CMAKE_OBJC_DEBUG + CMAKE_OBJC_MINSIZEREL + CMAKE_OBJC_RELWITHDEBINFO + CMAKE_OBJC_RELEASE + CMAKE_OBJCXX_FLAGS + CMAKE_OBJCXX_DEBUG + CMAKE_OBJCXX_MINSIZEREL + CMAKE_OBJCXX_RELWITHDEBINFO + CMAKE_OBJCXX_RELEASE + CMAKE_OBJC_LINK_FLAGS + CMAKE_OBJCXX_LINK_FLAGS + ) +endif() + +set(CMAKE_PLATFORM_HAS_INSTALLNAME 1) +set(CMAKE_SHARED_LINKER_FLAGS "-rpath @executable_path/Frameworks -rpath @loader_path/Frameworks") +set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names") +set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -Wl,-headerpad_max_install_names") +set(CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,") +set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,") +set(CMAKE_FIND_LIBRARY_SUFFIXES ".tbd" ".dylib" ".so" ".a") +set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name") + +# Set the find root to the SDK developer roots. +# Note: CMAKE_FIND_ROOT_PATH is only useful when cross-compiling. Thus, do not set on macOS builds. +if(NOT PLATFORM_INT MATCHES "^MAC.*$") + list(APPEND CMAKE_FIND_ROOT_PATH "${CMAKE_OSX_SYSROOT_INT}" CACHE INTERNAL "") + set(CMAKE_IGNORE_PATH "/System/Library/Frameworks;/usr/local/lib;/opt/homebrew" CACHE INTERNAL "") +endif() + +# Default to searching for frameworks first. +IF(NOT DEFINED CMAKE_FIND_FRAMEWORK) + set(CMAKE_FIND_FRAMEWORK FIRST) +ENDIF(NOT DEFINED CMAKE_FIND_FRAMEWORK) + +# Set up the default search directories for frameworks. +if(PLATFORM_INT MATCHES "^MAC_CATALYST") + set(CMAKE_FRAMEWORK_PATH + ${CMAKE_DEVELOPER_ROOT}/Library/PrivateFrameworks + ${CMAKE_OSX_SYSROOT_INT}/System/Library/Frameworks + ${CMAKE_OSX_SYSROOT_INT}/System/iOSSupport/System/Library/Frameworks + ${CMAKE_FRAMEWORK_PATH} CACHE INTERNAL "") +else() + set(CMAKE_FRAMEWORK_PATH + ${CMAKE_DEVELOPER_ROOT}/Library/PrivateFrameworks + ${CMAKE_OSX_SYSROOT_INT}/System/Library/Frameworks + ${CMAKE_FRAMEWORK_PATH} CACHE INTERNAL "") +endif() + +# By default, search both the specified iOS SDK and the remainder of the host filesystem. +if(NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH CACHE INTERNAL "") +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH CACHE INTERNAL "") +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH CACHE INTERNAL "") +endif() +if(NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH CACHE INTERNAL "") +endif() + +# +# Some helper-macros below to simplify and beautify the CMakeFile +# + +# This little macro lets you set any Xcode specific property. +macro(set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE XCODE_RELVERSION) + set(XCODE_RELVERSION_I "${XCODE_RELVERSION}") + if(XCODE_RELVERSION_I STREQUAL "All") + set_property(TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} "${XCODE_VALUE}") + else() + set_property(TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY}[variant=${XCODE_RELVERSION_I}] "${XCODE_VALUE}") + endif() +endmacro(set_xcode_property) + +# This macro lets you find executable programs on the host system. +macro(find_host_package) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER) + set(_TOOLCHAIN_IOS ${IOS}) + set(IOS OFF) + find_package(${ARGN}) + set(IOS ${_TOOLCHAIN_IOS}) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH) +endmacro(find_host_package) diff --git a/toolchains/riscv64-unknown-linux-musl.toolchain.cmake b/toolchains/riscv64-unknown-linux-musl.toolchain.cmake new file mode 100644 index 0000000..27ab640 --- /dev/null +++ b/toolchains/riscv64-unknown-linux-musl.toolchain.cmake @@ -0,0 +1,34 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR riscv64) +set(C906 True) + +if(DEFINED ENV{RISCV_ROOT_PATH}) + file(TO_CMAKE_PATH $ENV{RISCV_ROOT_PATH} RISCV_ROOT_PATH) +else() + message(FATAL_ERROR "RISCV_ROOT_PATH env must be defined") +endif() + +set(RISCV_ROOT_PATH ${RISCV_ROOT_PATH} CACHE STRING "root path to riscv toolchain") + +set(CMAKE_C_COMPILER "${RISCV_ROOT_PATH}/bin/riscv64-unknown-linux-musl-gcc") +set(CMAKE_CXX_COMPILER "${RISCV_ROOT_PATH}/bin/riscv64-unknown-linux-musl-g++") + +set(CMAKE_FIND_ROOT_PATH "${RISCV_ROOT_PATH}/riscv64-unknown-linux-musl") + +set(CMAKE_SYSROOT "${RISCV_ROOT_PATH}/sysroot") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + +set(CMAKE_C_FLAGS "-march=rv64gcv0p7_zfh_xtheadc -mabi=lp64d -mtune=c906") +set(CMAKE_CXX_FLAGS "-march=rv64gcv0p7_zfh_xtheadc -mabi=lp64d -mtune=c906") + +# cache flags +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags") + +# export RISCV_ROOT_PATH=/home/nihui/osd/host-tools/gcc/riscv64-linux-musl-x86_64 + +# cmake -DCMAKE_TOOLCHAIN_FILE=../../toolchains/riscv64-unknown-linux-musl.toolchain.cmake -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions" -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions" -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release `cat ../../opencv4_cmake_options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. From 5c2ee7a07fa982ff55233847a420e1adc8b56bfc Mon Sep 17 00:00:00 2001 From: rainy liu Date: Mon, 26 Aug 2024 15:43:33 +0800 Subject: [PATCH 02/41] fix options --- .github/workflows/release.yml | 46 +++++++++++++++++------------------ 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3b7c10c..bde47e5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -52,7 +52,7 @@ jobs: cd ${{ env.SOURCE_DIR }} mkdir build-armeabi-v7a && cd build-armeabi-v7a cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="armeabi-v7a" -DANDROID_ARM_NEON=ON \ - `cat ../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. cmake --build . -j $(nproc) cmake --build . --target install - name: build-arm64-v8a @@ -60,7 +60,7 @@ jobs: cd ${{ env.SOURCE_DIR }} mkdir build-arm64-v8a && cd build-arm64-v8a cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="arm64-v8a" \ - `cat ../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON -DOPENCV_EXTRA_FLAGS="-mno-outline-atomics" .. + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON -DOPENCV_EXTRA_FLAGS="-mno-outline-atomics" .. cmake --build . -j $(nproc) cmake --build . --target install - name: build-x86 @@ -68,7 +68,7 @@ jobs: cd ${{ env.SOURCE_DIR }} mkdir build-x86 && cd build-x86 cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="x86" \ - `cat ../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. cmake --build . -j $(nproc) cmake --build . --target install - name: build-x86_64 @@ -76,7 +76,7 @@ jobs: cd ${{ env.SOURCE_DIR }} mkdir build-x86_64 && cd build-x86_64 cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="x86_64" \ - `cat ../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. cmake --build . -j $(nproc) cmake --build . --target install - name: package @@ -156,7 +156,7 @@ jobs: cd ${{ env.SOURCE_DIR }} mkdir build-arm64 && cd build-arm64 cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="arm64" \ - `cat ../options.txt` -DBUILD_opencv_world=ON -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + `cat ../../options.txt` -DBUILD_opencv_world=ON -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. # workaround ar @list issue on macos cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } cmake --build . --target install @@ -225,7 +225,7 @@ jobs: cd ${{ env.SOURCE_DIR }} mkdir build-x86_64 && cd build-x86_64 cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="x86_64" \ - `cat ../options.txt` -DBUILD_opencv_world=ON -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + `cat ../../options.txt` -DBUILD_opencv_world=ON -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. # workaround ar @list issue on macos cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } cmake --build . --target install @@ -234,7 +234,7 @@ jobs: cd ${{ env.SOURCE_DIR }} mkdir build-arm64 && cd build-arm64 cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="arm64" \ - `cat ../options.txt` -DBUILD_opencv_world=ON -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + `cat ../../options.txt` -DBUILD_opencv_world=ON -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. # workaround ar @list issue on macos cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } cmake --build . --target install @@ -298,7 +298,7 @@ jobs: cd ${{ env.SOURCE_DIR }} mkdir build-arm-linux-gnueabi && cd build-arm-linux-gnueabi cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/arm-linux-gnueabi.toolchain.cmake \ - `cat ../options.txt` -DBUILD_opencv_world=OFF .. + `cat ../../options.txt` -DBUILD_opencv_world=OFF .. cmake --build . -j $(nproc) cmake --build . --target install - name: build-arm-linux-gnueabihf @@ -306,7 +306,7 @@ jobs: cd ${{ env.SOURCE_DIR }} mkdir build-arm-linux-gnueabihf && cd build-arm-linux-gnueabihf cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/arm-linux-gnueabihf.toolchain.cmake \ - `cat ../options.txt` -DBUILD_opencv_world=OFF .. + `cat ../../options.txt` -DBUILD_opencv_world=OFF .. cmake --build . -j $(nproc) cmake --build . --target install - name: build-aarch64-linux-gnu @@ -314,7 +314,7 @@ jobs: cd ${{ env.SOURCE_DIR }} mkdir build-aarch64-linux-gnu && cd build-aarch64-linux-gnu cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/aarch64-linux-gnu.toolchain.cmake \ - `cat ../options.txt` -DBUILD_opencv_world=OFF .. + `cat ../../options.txt` -DBUILD_opencv_world=OFF .. cmake --build . -j $(nproc) cmake --build . --target install - name: package @@ -392,7 +392,7 @@ jobs: cd ${{ env.SOURCE_DIR }} mkdir build-x86_64 && cd build-x86_64 cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=MAC -DARCHS="x86_64" \ - `cat ../options.txt` -DBUILD_opencv_world=ON .. + `cat ../../options.txt` -DBUILD_opencv_world=ON .. # workaround ar @list issue on macos cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } cmake --build . --target install @@ -401,7 +401,7 @@ jobs: cd ${{ env.SOURCE_DIR }} mkdir build-arm64 && cd build-arm64 cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=MAC_ARM64 -DARCHS="arm64" \ - `cat ../options.txt` -DBUILD_opencv_world=ON .. + `cat ../../options.txt` -DBUILD_opencv_world=ON .. # workaround ar @list issue on macos cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } cmake --build . --target install @@ -478,7 +478,7 @@ jobs: cd ${{ env.SOURCE_DIR }} mkdir build-x86_64 && cd build-x86_64 cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="x86_64" \ - `cat ../options.txt` -DBUILD_opencv_world=ON .. + `cat ../../options.txt` -DBUILD_opencv_world=ON .. # workaround ar @list issue on macos cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } cmake --build . --target install @@ -487,7 +487,7 @@ jobs: cd ${{ env.SOURCE_DIR }} mkdir build-arm64 && cd build-arm64 cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="arm64" \ - `cat ../options.txt` -DBUILD_opencv_world=ON .. + `cat ../../options.txt` -DBUILD_opencv_world=ON .. # workaround ar @list issue on macos cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } cmake --build . --target install @@ -546,14 +546,14 @@ jobs: run: | cd ${{ env.SOURCE_DIR }} mkdir build-x86; cd build-x86 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A Win32 $(type ../options.txt) -DBUILD_opencv_world=OFF .. + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A Win32 $(type ../../options.txt) -DBUILD_opencv_world=OFF .. cmake --build . --config Release -j 4 cmake --build . --config Release --target install - name: build-x64 run: | cd ${{ env.SOURCE_DIR }} mkdir build-x64; cd build-x64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A x64 $(type ../options.txt) -DBUILD_opencv_world=OFF .. + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A x64 $(type ../../options.txt) -DBUILD_opencv_world=OFF .. cmake --build . --config Release -j 4 cmake --build . --config Release --target install - name: build-arm @@ -561,7 +561,7 @@ jobs: run: | cd ${{ env.SOURCE_DIR }} mkdir build-arm; cd build-arm - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A arm -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=ARM $(type ../options.txt) -DBUILD_opencv_world=OFF .. + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A arm -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=ARM $(type ../../options.txt) -DBUILD_opencv_world=OFF .. cmake --build . --config Release -j 4 cmake --build . --config Release --target install - name: build-arm64 @@ -569,7 +569,7 @@ jobs: run: | cd ${{ env.SOURCE_DIR }} mkdir build-arm64; cd build-arm64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A arm64 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=ARM64 $(type ../options.txt) -DBUILD_opencv_world=OFF .. + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A arm64 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=ARM64 $(type ../../options.txt) -DBUILD_opencv_world=OFF .. cmake --build . --config Release -j 4 cmake --build . --config Release --target install - name: package @@ -648,7 +648,7 @@ jobs: run: | cd ${{ env.SOURCE_DIR }} mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} `cat ../options.txt` -DBUILD_opencv_world=OFF .. + cmake ${{ env.COMMON_CMAKE_OPTIONS }} `cat ../../options.txt` -DBUILD_opencv_world=OFF .. cmake --build . -j $(nproc) cmake --build . --target install - name: package @@ -710,7 +710,7 @@ jobs: -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=OFF -DCV_ENABLE_INTRINSICS=OFF -DBUILD_WASM_INTRIN_TESTS=OFF \ -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0" \ -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0" \ - `cat ../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. cmake --build . -j $(nproc) cmake --build . --target install - name: build-simd @@ -722,7 +722,7 @@ jobs: -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=OFF -DCV_ENABLE_INTRINSICS=ON -DBUILD_WASM_INTRIN_TESTS=OFF \ -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0 -msimd128" \ -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0 -msimd128" \ - `cat ../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. cmake --build . -j $(nproc) cmake --build . --target install - name: build-threads @@ -735,7 +735,7 @@ jobs: -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=ON -DCV_ENABLE_INTRINSICS=OFF -DBUILD_WASM_INTRIN_TESTS=OFF \ -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ - `cat ../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. cmake --build . -j $(nproc) cmake --build . --target install - name: build-simd-threads @@ -747,7 +747,7 @@ jobs: -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=ON -DCV_ENABLE_INTRINSICS=ON -DBUILD_WASM_INTRIN_TESTS=OFF \ -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ - `cat ../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. cmake --build . -j $(nproc) cmake --build . --target install - name: package From 06afdea2c8c834d736b03b89c4235d2bbe9d24f9 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Mon, 26 Aug 2024 15:55:21 +0800 Subject: [PATCH 03/41] fix --- .github/workflows/release.yml | 68 ++++--------------------- patches/opencv-4.10.0-unsafe-xadd.patch | 38 ++++++++++++++ 2 files changed, 47 insertions(+), 59 deletions(-) create mode 100644 patches/opencv-4.10.0-unsafe-xadd.patch diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bde47e5..4357514 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,9 +12,6 @@ env: IOS_DEPLOYMENT_TARGET: '13.0' MAC_DEPLOYMENT_TARGET: '11.0' MAC_CATALYST_DEPLOYMENT_TARGET: '13.1' - WATCHOS_DEPLOYMENT_TARGET: '6.0' - TVOS_DEPLOYMENT_TARGET: '11.0' - VISIONOS_DEPLOYMENT_TARGET: '1.0' ENABLE_BITCODE: OFF ENABLE_ARC: OFF ENABLE_VISIBILITY: OFF @@ -37,6 +34,7 @@ jobs: -DANDROID_PLATFORM=android-24 \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH="../build/opencv_contrib/modules" \ steps: - uses: actions/checkout@v4 - name: ndk-fix-debug @@ -134,10 +132,9 @@ jobs: -DENABLE_BITCODE=$ENABLE_BITCODE \ -DENABLE_ARC=$ENABLE_ARC \ -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ - -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions" \ - -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions" \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH="../build/opencv_contrib/modules" \ steps: - uses: actions/checkout@v4 - name: setup-opencv-source @@ -203,10 +200,9 @@ jobs: -DENABLE_BITCODE=$ENABLE_BITCODE \ -DENABLE_ARC=$ENABLE_ARC \ -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ - -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions" \ - -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions" \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH="../build/opencv_contrib/modules" \ steps: - uses: actions/checkout@v4 - name: setup-opencv-source @@ -276,10 +272,9 @@ jobs: opencv-version: [4.10.0] env: COMMON_CMAKE_OPTIONS: | - -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions" \ - -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions" \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH="../build/opencv_contrib/modules" \ steps: - name: arm-gnu-toolchain run: | @@ -374,6 +369,7 @@ jobs: -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH="../build/opencv_contrib/modules" \ steps: - uses: actions/checkout@v4 - name: setup-opencv-source @@ -460,6 +456,7 @@ jobs: -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions" \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH="../build/opencv_contrib/modules" \ steps: - uses: actions/checkout@v4 - name: setup-opencv-source @@ -533,7 +530,7 @@ jobs: runs-on: windows-${{ matrix.os-compiler.windows-version }} env: UseMultiToolTask: true - COMMON_CMAKE_OPTIONS: -T ${{ matrix.os-compiler.toolset-version }},host=x64 -DCMAKE_INSTALL_PREFIX=install + COMMON_CMAKE_OPTIONS: -T ${{ matrix.os-compiler.toolset-version }},host=x64 -DCMAKE_INSTALL_PREFIX=install -DOPENCV_EXTRA_MODULES_PATH="../build/opencv_contrib/modules" steps: - uses: actions/checkout@v4 - name: setup-opencv-source @@ -635,7 +632,7 @@ jobs: - { ubuntu-id: 2204, ubuntu-version: 22.04 } runs-on: ubuntu-${{ matrix.os-ubuntu.ubuntu-version }} env: - COMMON_CMAKE_OPTIONS: -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release + COMMON_CMAKE_OPTIONS: -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DOPENCV_EXTRA_MODULES_PATH="../build/opencv_contrib/modules" steps: - uses: actions/checkout@v4 - name: setup-opencv-source @@ -686,6 +683,7 @@ jobs: -DCMAKE_TOOLCHAIN_FILE=../emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH="../build/opencv_contrib/modules" \ steps: - uses: actions/checkout@v4 - name: emsdk @@ -823,12 +821,6 @@ jobs: echo "IOS_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-ios" >> $GITHUB_ENV echo "IOS_SIMULATOR_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-ios-simulator" >> $GITHUB_ENV echo "MAC_CATALYST_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-mac-catalyst" >> $GITHUB_ENV - echo "WATCHOS_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-watchos" >> $GITHUB_ENV - echo "WATCHOS_SIMULATOR_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-watchos-simulator" >> $GITHUB_ENV - echo "TVOS_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-tvos" >> $GITHUB_ENV - echo "TVOS_SIMULATOR_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-tvos-simulator" >> $GITHUB_ENV - echo "VISIONOS_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-visionos" >> $GITHUB_ENV - echo "VISIONOS_SIMULATOR_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-visionos-simulator" >> $GITHUB_ENV echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-apple" >> $GITHUB_ENV - name: download-macos-package uses: actions/download-artifact@v4 @@ -846,63 +838,21 @@ jobs: uses: actions/download-artifact@v4 with: name: ${{ env.MAC_CATALYST_PACKAGE_NAME }} - - name: download-watchos-package - uses: actions/download-artifact@v4 - with: - name: ${{ env.WATCHOS_PACKAGE_NAME }} - - name: download-watchos-simulator-package - uses: actions/download-artifact@v4 - with: - name: ${{ env.WATCHOS_SIMULATOR_PACKAGE_NAME }} - - name: download-tvos-package - uses: actions/download-artifact@v4 - with: - name: ${{ env.TVOS_PACKAGE_NAME }} - - name: download-tvos-simulator-package - uses: actions/download-artifact@v4 - with: - name: ${{ env.TVOS_SIMULATOR_PACKAGE_NAME }} - - name: download-visionos-package - uses: actions/download-artifact@v4 - with: - name: ${{ env.VISIONOS_PACKAGE_NAME }} - - name: download-visionos-simulator-package - uses: actions/download-artifact@v4 - with: - name: ${{ env.VISIONOS_SIMULATOR_PACKAGE_NAME }} - name: create-xcframwork run: | mkdir -p ${{ env.MACOS_PACKAGE_NAME }} mkdir -p ${{ env.IOS_PACKAGE_NAME }} mkdir -p ${{ env.IOS_SIMULATOR_PACKAGE_NAME }} mkdir -p ${{ env.MAC_CATALYST_PACKAGE_NAME }} - mkdir -p ${{ env.WATCHOS_PACKAGE_NAME }} - mkdir -p ${{ env.WATCHOS_SIMULATOR_PACKAGE_NAME }} - mkdir -p ${{ env.TVOS_PACKAGE_NAME }} - mkdir -p ${{ env.TVOS_SIMULATOR_PACKAGE_NAME }} - mkdir -p ${{ env.VISIONOS_PACKAGE_NAME }} - mkdir -p ${{ env.VISIONOS_SIMULATOR_PACKAGE_NAME }} unzip -q ${{ env.MACOS_PACKAGE_NAME }}.zip -d ${{ env.MACOS_PACKAGE_NAME }} unzip -q ${{ env.IOS_PACKAGE_NAME }}.zip -d ${{ env.IOS_PACKAGE_NAME }} unzip -q ${{ env.IOS_SIMULATOR_PACKAGE_NAME }}.zip -d ${{ env.IOS_SIMULATOR_PACKAGE_NAME }} unzip -q ${{ env.MAC_CATALYST_PACKAGE_NAME }}.zip -d ${{ env.MAC_CATALYST_PACKAGE_NAME }} - unzip -q ${{ env.WATCHOS_PACKAGE_NAME }}.zip -d ${{ env.WATCHOS_PACKAGE_NAME }} - unzip -q ${{ env.WATCHOS_SIMULATOR_PACKAGE_NAME }}.zip -d ${{ env.WATCHOS_SIMULATOR_PACKAGE_NAME }} - unzip -q ${{ env.TVOS_PACKAGE_NAME }}.zip -d ${{ env.TVOS_PACKAGE_NAME }} - unzip -q ${{ env.TVOS_SIMULATOR_PACKAGE_NAME }}.zip -d ${{ env.TVOS_SIMULATOR_PACKAGE_NAME }} - unzip -q ${{ env.VISIONOS_PACKAGE_NAME }}.zip -d ${{ env.VISIONOS_PACKAGE_NAME }} - unzip -q ${{ env.VISIONOS_SIMULATOR_PACKAGE_NAME }}.zip -d ${{ env.VISIONOS_SIMULATOR_PACKAGE_NAME }} xcodebuild -create-xcframework \ -framework ${{ env.MACOS_PACKAGE_NAME }}/opencv2.framework \ -framework ${{ env.IOS_PACKAGE_NAME }}/opencv2.framework \ -framework ${{ env.IOS_SIMULATOR_PACKAGE_NAME }}/opencv2.framework \ -framework ${{ env.MAC_CATALYST_PACKAGE_NAME }}/opencv2.framework \ - -framework ${{ env.WATCHOS_PACKAGE_NAME }}/opencv2.framework \ - -framework ${{ env.WATCHOS_SIMULATOR_PACKAGE_NAME }}/opencv2.framework \ - -framework ${{ env.TVOS_PACKAGE_NAME }}/opencv2.framework \ - -framework ${{ env.TVOS_SIMULATOR_PACKAGE_NAME }}/opencv2.framework \ - -framework ${{ env.VISIONOS_PACKAGE_NAME }}/opencv2.framework \ - -framework ${{ env.VISIONOS_SIMULATOR_PACKAGE_NAME }}/opencv2.framework \ -output opencv2.xcframework rm -f ${{ env.PACKAGE_NAME }}.zip zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip opencv2.xcframework diff --git a/patches/opencv-4.10.0-unsafe-xadd.patch b/patches/opencv-4.10.0-unsafe-xadd.patch new file mode 100644 index 0000000..c99a84c --- /dev/null +++ b/patches/opencv-4.10.0-unsafe-xadd.patch @@ -0,0 +1,38 @@ +diff -Nuarp opencv-4.10.0.orig/modules/core/include/opencv2/core/cvdef.h opencv-4.10.0/modules/core/include/opencv2/core/cvdef.h +--- opencv-4.10.0.orig/modules/core/include/opencv2/core/cvdef.h 2024-06-02 04:41:06.000000000 +0800 ++++ opencv-4.10.0/modules/core/include/opencv2/core/cvdef.h 2024-06-04 20:55:30.670342400 +0800 +@@ -693,33 +693,7 @@ __CV_ENUM_FLAGS_BITWISE_XOR_EQ (EnumTy + * exchange-add operation for atomic operations on reference counters * + \****************************************************************************************/ + +-#ifdef CV_XADD +- // allow to use user-defined macro +-#elif defined __GNUC__ || defined __clang__ +-# if defined __clang__ && __clang_major__ >= 3 && !defined __ANDROID__ && !defined __EMSCRIPTEN__ && !defined(__CUDACC__) && !defined __INTEL_COMPILER +-# ifdef __ATOMIC_ACQ_REL +-# define CV_XADD(addr, delta) __c11_atomic_fetch_add((_Atomic(int)*)(addr), delta, __ATOMIC_ACQ_REL) +-# else +-# define CV_XADD(addr, delta) __atomic_fetch_add((_Atomic(int)*)(addr), delta, 4) +-# endif +-# else +-# if defined __ATOMIC_ACQ_REL && !defined __clang__ +- // version for gcc >= 4.7 +-# define CV_XADD(addr, delta) (int)__atomic_fetch_add((unsigned*)(addr), (unsigned)(delta), __ATOMIC_ACQ_REL) +-# else +-# define CV_XADD(addr, delta) (int)__sync_fetch_and_add((unsigned*)(addr), (unsigned)(delta)) +-# endif +-# endif +-#elif defined _MSC_VER && !defined RC_INVOKED +-# include +-# define CV_XADD(addr, delta) (int)_InterlockedExchangeAdd((long volatile*)addr, delta) +-#else +- #ifdef OPENCV_FORCE_UNSAFE_XADD +- CV_INLINE int CV_XADD(int* addr, int delta) { int tmp = *addr; *addr += delta; return tmp; } +- #else +- #error "OpenCV: can't define safe CV_XADD macro for current platform (unsupported). Define CV_XADD macro through custom port header (see OPENCV_INCLUDE_PORT_FILE)" +- #endif +-#endif ++CV_INLINE int CV_XADD(void* addr, int delta) { int tmp = *(int*)addr; *(int*)addr += delta; return tmp; } + + + /****************************************************************************************\ From 8299e94751b29337633292ff95db5372cbfcf7c5 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Mon, 26 Aug 2024 16:02:31 +0800 Subject: [PATCH 04/41] fix --- .github/workflows/release.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4357514..4aa5074 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,7 +34,7 @@ jobs: -DANDROID_PLATFORM=android-24 \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="../build/opencv_contrib/modules" \ + -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ steps: - uses: actions/checkout@v4 - name: ndk-fix-debug @@ -134,7 +134,7 @@ jobs: -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="../build/opencv_contrib/modules" \ + -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ steps: - uses: actions/checkout@v4 - name: setup-opencv-source @@ -202,7 +202,7 @@ jobs: -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="../build/opencv_contrib/modules" \ + -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ steps: - uses: actions/checkout@v4 - name: setup-opencv-source @@ -274,7 +274,7 @@ jobs: COMMON_CMAKE_OPTIONS: | -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="../build/opencv_contrib/modules" \ + -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ steps: - name: arm-gnu-toolchain run: | @@ -369,7 +369,7 @@ jobs: -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="../build/opencv_contrib/modules" \ + -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ steps: - uses: actions/checkout@v4 - name: setup-opencv-source @@ -456,7 +456,7 @@ jobs: -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions" \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="../build/opencv_contrib/modules" \ + -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ steps: - uses: actions/checkout@v4 - name: setup-opencv-source @@ -530,7 +530,7 @@ jobs: runs-on: windows-${{ matrix.os-compiler.windows-version }} env: UseMultiToolTask: true - COMMON_CMAKE_OPTIONS: -T ${{ matrix.os-compiler.toolset-version }},host=x64 -DCMAKE_INSTALL_PREFIX=install -DOPENCV_EXTRA_MODULES_PATH="../build/opencv_contrib/modules" + COMMON_CMAKE_OPTIONS: -T ${{ matrix.os-compiler.toolset-version }},host=x64 -DCMAKE_INSTALL_PREFIX=install -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" steps: - uses: actions/checkout@v4 - name: setup-opencv-source @@ -632,7 +632,7 @@ jobs: - { ubuntu-id: 2204, ubuntu-version: 22.04 } runs-on: ubuntu-${{ matrix.os-ubuntu.ubuntu-version }} env: - COMMON_CMAKE_OPTIONS: -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DOPENCV_EXTRA_MODULES_PATH="../build/opencv_contrib/modules" + COMMON_CMAKE_OPTIONS: -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" steps: - uses: actions/checkout@v4 - name: setup-opencv-source @@ -683,7 +683,7 @@ jobs: -DCMAKE_TOOLCHAIN_FILE=../emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="../build/opencv_contrib/modules" \ + -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ steps: - uses: actions/checkout@v4 - name: emsdk From 2d3a9f3770cb529e1e310521fd0efa71e59c0088 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Mon, 26 Aug 2024 16:32:18 +0800 Subject: [PATCH 05/41] split --- .github/workflows/android.yml | 129 +++++ .github/workflows/apple.yml | 385 +++++++++++++++ .github/workflows/linux.yml | 165 +++++++ .github/workflows/release.yml | 882 ---------------------------------- .github/workflows/wasm.yml | 164 +++++++ .github/workflows/windows.yml | 134 ++++++ test/CMakeLists.txt | 4 + 7 files changed, 981 insertions(+), 882 deletions(-) create mode 100644 .github/workflows/android.yml create mode 100644 .github/workflows/apple.yml create mode 100644 .github/workflows/linux.yml delete mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/wasm.yml create mode 100644 .github/workflows/windows.yml diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml new file mode 100644 index 0000000..6016d69 --- /dev/null +++ b/.github/workflows/android.yml @@ -0,0 +1,129 @@ +name: android +# on: pull_request +on: + push: + tags: + - '*' + pull_request: + branches: ["main"] + +permissions: + contents: read + +jobs: + android: + runs-on: ubuntu-latest + strategy: + matrix: + opencv-version: [4.10.0] + env: + COMMON_CMAKE_OPTIONS: | + -DCMAKE_POLICY_DEFAULT_CMP0057=NEW \ + -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_LATEST_HOME/build/cmake/android.toolchain.cmake \ + -DANDROID_USE_LEGACY_TOOLCHAIN_FILE=False \ + -DANDROID_PLATFORM=android-24 \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ + steps: + - uses: actions/checkout@v4 + - name: ndk-fix-debug + run: sed -i -e '/^ -g$/d' $ANDROID_NDK_LATEST_HOME/build/cmake/android-legacy.toolchain.cmake + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} + echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-android" >> $GITHUB_ENV + - name: build-armeabi-v7a + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-armeabi-v7a && cd build-armeabi-v7a + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="armeabi-v7a" -DANDROID_ARM_NEON=ON \ + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: build-arm64-v8a + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-arm64-v8a && cd build-arm64-v8a + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="arm64-v8a" \ + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON -DOPENCV_EXTRA_FLAGS="-mno-outline-atomics" .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: build-x86 + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-x86 && cd build-x86 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="x86" \ + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: build-x86_64 + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-x86_64 && cd build-x86_64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="x86_64" \ + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: package + run: | + mkdir ${{ env.PACKAGE_NAME }} + cp -rf ${{ env.SOURCE_DIR }}/build-x86/install/* ${{ env.PACKAGE_NAME }}/ + cp -rf ${{ env.SOURCE_DIR }}/build-x86_64/install/* ${{ env.PACKAGE_NAME }}/ + cp -rf ${{ env.SOURCE_DIR }}/build-armeabi-v7a/install/* ${{ env.PACKAGE_NAME }}/ + cp -rf ${{ env.SOURCE_DIR }}/build-arm64-v8a/install/* ${{ env.PACKAGE_NAME }}/ + zip -9 -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} + - name: test-armeabi-v7a + run: | + cd test + mkdir build-armeabi-v7a && cd build-armeabi-v7a + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="armeabi-v7a" -DANDROID_ARM_NEON=ON \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/sdk/native/jni .. + cmake --build . -j $(nproc) + - name: test-arm64-v8a + run: | + cd test + mkdir build-arm64-v8a && cd build-arm64-v8a + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="arm64-v8a" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/sdk/native/jni .. + cmake --build . -j $(nproc) + - name: test-x86 + run: | + cd test + mkdir build-x86 && cd build-x86 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="x86" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/sdk/native/jni .. + cmake --build . -j $(nproc) + - name: test-x86_64 + run: | + cd test + mkdir build-x86_64 && cd build-x86_64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="x86_64" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/sdk/native/jni .. + cmake --build . -j $(nproc) + - name: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.zip + + release: + permissions: + contents: write # for softprops/action-gh-release to create a release + needs: [android] + runs-on: ubuntu-latest + steps: + - name: download + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: create-release + uses: softprops/action-gh-release@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag_name: ${{ needs.setup.outputs.VERSION }} + name: Release ${{ needs.setup.outputs.VERSION }} + files: artifacts/*/*.zip diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml new file mode 100644 index 0000000..c09009f --- /dev/null +++ b/.github/workflows/apple.yml @@ -0,0 +1,385 @@ +name: apple +# on: pull_request +on: + push: + tags: + - '*' + pull_request: + branches: ["main"] + +env: + DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer + IOS_DEPLOYMENT_TARGET: '13.0' + MAC_DEPLOYMENT_TARGET: '11.0' + MAC_CATALYST_DEPLOYMENT_TARGET: '13.1' + ENABLE_BITCODE: OFF + ENABLE_ARC: OFF + ENABLE_VISIBILITY: OFF + EMSCRIPTEN_VERSION: 3.1.28 + +permissions: + contents: read + +jobs: + ios: + runs-on: macos-13 + strategy: + matrix: + opencv-version: [4.10.0] + env: + COMMON_CMAKE_OPTIONS: | + -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ + -DPLATFORM=OS \ + -DDEPLOYMENT_TARGET=$IOS_DEPLOYMENT_TARGET \ + -DENABLE_BITCODE=$ENABLE_BITCODE \ + -DENABLE_ARC=$ENABLE_ARC \ + -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ + steps: + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} + echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-ios" >> $GITHUB_ENV + - name: build-arm64 + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-arm64 && cd build-arm64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="arm64" \ + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DWITH_OPENCL=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + # workaround ar @list issue on macos + cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } + cmake --build . --target install + - name: package + run: | + rm -rf opencv2.framework + mkdir -p opencv2.framework/Versions/A/Headers + mkdir -p opencv2.framework/Versions/A/Resources + ln -s A opencv2.framework/Versions/Current + ln -s Versions/Current/Headers opencv2.framework/Headers + ln -s Versions/Current/Resources opencv2.framework/Resources + ln -s Versions/Current/opencv2 opencv2.framework/opencv2 + lipo -create \ + ${{ env.SOURCE_DIR }}/build-arm64/install/lib/libopencv_world.a \ + -o opencv2.framework/Versions/A/opencv2 + cp -r ${{ env.SOURCE_DIR }}/build-arm64/install/include/opencv4/opencv2/* opencv2.framework/Versions/A/Headers/ || : + cp -r ${{ env.SOURCE_DIR }}/build-arm64/install/include/opencv2/* opencv2.framework/Versions/A/Headers/ || : + cp ${{ env.SOURCE_DIR }}/Info.plist opencv2.framework/Versions/A/Resources/ + rm -f ${{ env.PACKAGE_NAME }}.zip + zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip opencv2.framework + - name: test + run: | + cd test + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="arm64" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE .. + cmake --build . -j 4 + - name: upload-zip + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.zip + + ios-simulator: + runs-on: macos-13 + strategy: + matrix: + opencv-version: [4.10.0] + env: + COMMON_CMAKE_OPTIONS: | + -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ + -DPLATFORM=SIMULATOR \ + -DDEPLOYMENT_TARGET=$IOS_DEPLOYMENT_TARGET \ + -DENABLE_BITCODE=$ENABLE_BITCODE \ + -DENABLE_ARC=$ENABLE_ARC \ + -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ + steps: + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} + echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-ios-simulator" >> $GITHUB_ENV + - name: build-x86_64 + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-x86_64 && cd build-x86_64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="x86_64" \ + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + # workaround ar @list issue on macos + cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } + cmake --build . --target install + - name: build-arm64 + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-arm64 && cd build-arm64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="arm64" \ + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DWITH_OPENCL=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + # workaround ar @list issue on macos + cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } + cmake --build . --target install + - name: package + run: | + rm -rf opencv2.framework + mkdir -p opencv2.framework/Versions/A/Headers + mkdir -p opencv2.framework/Versions/A/Resources + ln -s A opencv2.framework/Versions/Current + ln -s Versions/Current/Headers opencv2.framework/Headers + ln -s Versions/Current/Resources opencv2.framework/Resources + ln -s Versions/Current/opencv2 opencv2.framework/opencv2 + lipo -create \ + ${{ env.SOURCE_DIR }}/build-x86_64/install/lib/libopencv_world.a \ + ${{ env.SOURCE_DIR }}/build-arm64/install/lib/libopencv_world.a \ + -o opencv2.framework/Versions/A/opencv2 + cp -r ${{ env.SOURCE_DIR }}/build-x86_64/install/include/opencv4/opencv2/* opencv2.framework/Versions/A/Headers/ || : + cp -r ${{ env.SOURCE_DIR }}/build-x86_64/install/include/opencv2/* opencv2.framework/Versions/A/Headers/ || : + cp ${{ env.SOURCE_DIR }}/Info.plist opencv2.framework/Versions/A/Resources/ + rm -f ${{ env.PACKAGE_NAME }}.zip + zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip opencv2.framework + - name: test + run: | + cd test + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="x86_64;arm64" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE .. + cmake --build . -j 4 + - name: upload-zip + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.zip + + macos: + runs-on: macos-13 + strategy: + matrix: + opencv-version: [4.10.0] + env: + COMMON_CMAKE_OPTIONS: | + -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ + -DDEPLOYMENT_TARGET=$MAC_DEPLOYMENT_TARGET \ + -DENABLE_BITCODE=OFF \ + -DENABLE_ARC=$ENABLE_ARC \ + -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ + steps: + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} + echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-macos" >> $GITHUB_ENV + - name: build-x86_64 + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-x86_64 && cd build-x86_64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=MAC -DARCHS="x86_64" \ + `cat ../../options.txt` -DBUILD_opencv_world=OFF .. + # workaround ar @list issue on macos + cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } + cmake --build . --target install + - name: build-arm64 + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-arm64 && cd build-arm64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=MAC_ARM64 -DARCHS="arm64" \ + `cat ../../options.txt` -DBUILD_opencv_world=OFF .. + # workaround ar @list issue on macos + cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } + cmake --build . --target install + - name: package + run: | + rm -rf opencv2.framework + mkdir -p opencv2.framework/Versions/A/Headers + mkdir -p opencv2.framework/Versions/A/Resources + ln -s A opencv2.framework/Versions/Current + ln -s Versions/Current/Headers opencv2.framework/Headers + ln -s Versions/Current/Resources opencv2.framework/Resources + ln -s Versions/Current/opencv2 opencv2.framework/opencv2 + lipo -create \ + ${{ env.SOURCE_DIR }}/build-x86_64/install/lib/libopencv_world.a \ + ${{ env.SOURCE_DIR }}/build-arm64/install/lib/libopencv_world.a \ + -o opencv2.framework/Versions/A/opencv2 + cp -r ${{ env.SOURCE_DIR }}/build-x86_64/install/include/opencv4/opencv2/* opencv2.framework/Versions/A/Headers/ || : + cp -r ${{ env.SOURCE_DIR }}/build-x86_64/install/include/opencv2/* opencv2.framework/Versions/A/Headers/ || : + cp ${{ env.SOURCE_DIR }}/Info.plist opencv2.framework/Versions/A/Resources/ + rm -f ${{ env.PACKAGE_NAME }}.zip + zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip opencv2.framework + - name: test-x86_64 + run: | + cd test + mkdir build-x86_64 && cd build-x86_64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=MAC -DARCHS="x86_64" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE .. + cmake --build . -j 4 + - name: test-arm64 + run: | + cd test + mkdir build-arm64 && cd build-arm64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=MAC_ARM64 -DARCHS="arm64" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE .. + cmake --build . -j 4 + - name: upload-zip + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.zip + + mac-catalyst: + runs-on: macos-13 + strategy: + matrix: + opencv-version: [4.10.0] + env: + COMMON_CMAKE_OPTIONS: | + -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ + -DPLATFORM=MAC_CATALYST \ + -DDEPLOYMENT_TARGET=$MAC_CATALYST_DEPLOYMENT_TARGET \ + -DENABLE_BITCODE=$ENABLE_BITCODE \ + -DENABLE_ARC=$ENABLE_ARC \ + -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ + steps: + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} + echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-mac-catalyst" >> $GITHUB_ENV + - name: build-x86_64 + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-x86_64 && cd build-x86_64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="x86_64" \ + `cat ../../options.txt` -DBUILD_opencv_world=OFF .. + # workaround ar @list issue on macos + cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } + cmake --build . --target install + - name: build-arm64 + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-arm64 && cd build-arm64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="arm64" \ + `cat ../../options.txt` -DBUILD_opencv_world=OFF .. + # workaround ar @list issue on macos + cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } + cmake --build . --target install + - name: package + run: | + rm -rf opencv2.framework + mkdir -p opencv2.framework/Versions/A/Headers + mkdir -p opencv2.framework/Versions/A/Resources + ln -s A opencv2.framework/Versions/Current + ln -s Versions/Current/Headers opencv2.framework/Headers + ln -s Versions/Current/Resources opencv2.framework/Resources + ln -s Versions/Current/opencv2 opencv2.framework/opencv2 + lipo -create \ + ${{ env.SOURCE_DIR }}/build-x86_64/install/lib/libopencv_world.a \ + ${{ env.SOURCE_DIR }}/build-arm64/install/lib/libopencv_world.a \ + -o opencv2.framework/Versions/A/opencv2 + cp -r ${{ env.SOURCE_DIR }}/build-arm64/install/include/opencv4/opencv2/* opencv2.framework/Versions/A/Headers/ || : + cp -r ${{ env.SOURCE_DIR }}/build-arm64/install/include/opencv2/* opencv2.framework/Versions/A/Headers/ || : + cp ${{ env.SOURCE_DIR }}/Info.plist opencv2.framework/Versions/A/Resources/ + rm -f ${{ env.PACKAGE_NAME }}.zip + zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip opencv2.framework + - name: test + run: | + cd test + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="x86_64;arm64" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE .. + cmake --build . -j 4 + - name: upload-zip + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.zip + + apple: + needs: [macos, ios, ios-simulator, mac-catalyst] + runs-on: macos-13 + strategy: + matrix: + opencv-version: [4.10.0] + steps: + - run: sudo xcode-select --switch /Applications/Xcode_15.2.app + - uses: actions/checkout@v4 + - name: setup-opencv-package + run: | + echo "MACOS_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-macos" >> $GITHUB_ENV + echo "IOS_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-ios" >> $GITHUB_ENV + echo "IOS_SIMULATOR_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-ios-simulator" >> $GITHUB_ENV + echo "MAC_CATALYST_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-mac-catalyst" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-apple" >> $GITHUB_ENV + - name: download-macos-package + uses: actions/download-artifact@v4 + with: + name: ${{ env.MACOS_PACKAGE_NAME }} + - name: download-ios-package + uses: actions/download-artifact@v4 + with: + name: ${{ env.IOS_PACKAGE_NAME }} + - name: download-ios-simulator-package + uses: actions/download-artifact@v4 + with: + name: ${{ env.IOS_SIMULATOR_PACKAGE_NAME }} + - name: download-mac-catalyst-package + uses: actions/download-artifact@v4 + with: + name: ${{ env.MAC_CATALYST_PACKAGE_NAME }} + - name: create-xcframwork + run: | + mkdir -p ${{ env.MACOS_PACKAGE_NAME }} + mkdir -p ${{ env.IOS_PACKAGE_NAME }} + mkdir -p ${{ env.IOS_SIMULATOR_PACKAGE_NAME }} + mkdir -p ${{ env.MAC_CATALYST_PACKAGE_NAME }} + unzip -q ${{ env.MACOS_PACKAGE_NAME }}.zip -d ${{ env.MACOS_PACKAGE_NAME }} + unzip -q ${{ env.IOS_PACKAGE_NAME }}.zip -d ${{ env.IOS_PACKAGE_NAME }} + unzip -q ${{ env.IOS_SIMULATOR_PACKAGE_NAME }}.zip -d ${{ env.IOS_SIMULATOR_PACKAGE_NAME }} + unzip -q ${{ env.MAC_CATALYST_PACKAGE_NAME }}.zip -d ${{ env.MAC_CATALYST_PACKAGE_NAME }} + xcodebuild -create-xcframework \ + -framework ${{ env.MACOS_PACKAGE_NAME }}/opencv2.framework \ + -framework ${{ env.IOS_PACKAGE_NAME }}/opencv2.framework \ + -framework ${{ env.IOS_SIMULATOR_PACKAGE_NAME }}/opencv2.framework \ + -framework ${{ env.MAC_CATALYST_PACKAGE_NAME }}/opencv2.framework \ + -output opencv2.xcframework + rm -f ${{ env.PACKAGE_NAME }}.zip + zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip opencv2.xcframework + - name: upload-zip + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.zip + + release: + permissions: + contents: write # for softprops/action-gh-release to create a release + needs: [ios, ios-simulator, macos, mac-catalyst, apple] + runs-on: ubuntu-latest + steps: + - name: download + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: create-release + uses: softprops/action-gh-release@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag_name: ${{ needs.setup.outputs.VERSION }} + name: Release ${{ needs.setup.outputs.VERSION }} + files: artifacts/*/*.zip diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 0000000..94c5ad5 --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,165 @@ +name: linux +# on: pull_request +on: + push: + tags: + - '*' + pull_request: + branches: ["main"] + +permissions: + contents: read + +jobs: + armlinux: + runs-on: ubuntu-latest + strategy: + matrix: + opencv-version: [4.10.0] + env: + COMMON_CMAKE_OPTIONS: | + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ + steps: + - name: arm-gnu-toolchain + run: | + sudo apt-get update + sudo apt-get install g++-arm-linux-gnueabi g++-arm-linux-gnueabihf g++-aarch64-linux-gnu + + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} + echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-armlinux" >> $GITHUB_ENV + - name: build-arm-linux-gnueabi + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-arm-linux-gnueabi && cd build-arm-linux-gnueabi + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/arm-linux-gnueabi.toolchain.cmake \ + `cat ../../options.txt` -DBUILD_opencv_world=OFF .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: build-arm-linux-gnueabihf + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-arm-linux-gnueabihf && cd build-arm-linux-gnueabihf + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/arm-linux-gnueabihf.toolchain.cmake \ + `cat ../../options.txt` -DBUILD_opencv_world=OFF .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: build-aarch64-linux-gnu + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-aarch64-linux-gnu && cd build-aarch64-linux-gnu + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/aarch64-linux-gnu.toolchain.cmake \ + `cat ../../options.txt` -DBUILD_opencv_world=OFF .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: package + run: | + mkdir ${{ env.PACKAGE_NAME }} + mkdir ${{ env.PACKAGE_NAME }}/arm-linux-gnueabi + mkdir ${{ env.PACKAGE_NAME }}/arm-linux-gnueabihf + mkdir ${{ env.PACKAGE_NAME }}/aarch64-linux-gnu + cp -rf ${{ env.SOURCE_DIR }}/build-arm-linux-gnueabi/install/* ${{ env.PACKAGE_NAME }}/arm-linux-gnueabi/ + cp -rf ${{ env.SOURCE_DIR }}/build-arm-linux-gnueabihf/install/* ${{ env.PACKAGE_NAME }}/arm-linux-gnueabihf/ + cp -rf ${{ env.SOURCE_DIR }}/build-aarch64-linux-gnu/install/* ${{ env.PACKAGE_NAME }}/aarch64-linux-gnu/ + zip -9 -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} + - name: set-opencv-dir + if: matrix.opencv-version == '4.10.0' + run: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV + - name: test-arm-linux-gnueabi + run: | + cd test + mkdir build-arm-linux-gnueabi && cd build-arm-linux-gnueabi + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/arm-linux-gnueabi.toolchain.cmake \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/arm-linux-gnueabi/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j $(nproc) + - name: test-arm-linux-gnueabihf + run: | + cd test + mkdir build-arm-linux-gnueabihf && cd build-arm-linux-gnueabihf + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/arm-linux-gnueabihf.toolchain.cmake \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/arm-linux-gnueabihf/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j $(nproc) + - name: test-aarch64-linux-gnu + run: | + cd test + mkdir build-aarch64-linux-gnu && cd build-aarch64-linux-gnu + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/aarch64-linux-gnu.toolchain.cmake \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/aarch64-linux-gnu/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j $(nproc) + - name: upload-zip + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.zip + + ubuntu: + strategy: + matrix: + opencv-version: [4.10.0] + os-ubuntu: + - { ubuntu-id: 2004, ubuntu-version: 20.04 } + - { ubuntu-id: 2204, ubuntu-version: 22.04 } + runs-on: ubuntu-${{ matrix.os-ubuntu.ubuntu-version }} + env: + COMMON_CMAKE_OPTIONS: -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" + steps: + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} + echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-ubuntu-${{ matrix.os-ubuntu.ubuntu-id }}" >> $GITHUB_ENV + - name: build + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} `cat ../../options.txt` -DBUILD_opencv_world=OFF .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: package + run: | + rm -rf ${{ env.PACKAGE_NAME }} + mkdir -p ${{ env.PACKAGE_NAME }} + cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ + rm -f ${{ env.PACKAGE_NAME }}.zip + zip -9 -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} + - name: set-opencv-dir + if: matrix.opencv-version == '4.10.0' + run: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV + - name: test + run: | + cd test + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j $(nproc) + - name: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.zip + + release: + permissions: + contents: write # for softprops/action-gh-release to create a release + needs: [armlinux, ubuntu] + runs-on: ubuntu-latest + steps: + - name: download + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: create-release + uses: softprops/action-gh-release@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag_name: ${{ needs.setup.outputs.VERSION }} + name: Release ${{ needs.setup.outputs.VERSION }} + files: artifacts/*/*.zip diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 4aa5074..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,882 +0,0 @@ -name: release -# on: pull_request -on: - push: - tags: - - '*' - pull_request: - branches: ["main"] - -env: - DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer - IOS_DEPLOYMENT_TARGET: '13.0' - MAC_DEPLOYMENT_TARGET: '11.0' - MAC_CATALYST_DEPLOYMENT_TARGET: '13.1' - ENABLE_BITCODE: OFF - ENABLE_ARC: OFF - ENABLE_VISIBILITY: OFF - EMSCRIPTEN_VERSION: 3.1.28 - -permissions: - contents: read - -jobs: - android: - runs-on: ubuntu-latest - strategy: - matrix: - opencv-version: [4.10.0] - env: - COMMON_CMAKE_OPTIONS: | - -DCMAKE_POLICY_DEFAULT_CMP0057=NEW \ - -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_LATEST_HOME/build/cmake/android.toolchain.cmake \ - -DANDROID_USE_LEGACY_TOOLCHAIN_FILE=False \ - -DANDROID_PLATFORM=android-24 \ - -DCMAKE_INSTALL_PREFIX=install \ - -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ - steps: - - uses: actions/checkout@v4 - - name: ndk-fix-debug - run: sed -i -e '/^ -g$/d' $ANDROID_NDK_LATEST_HOME/build/cmake/android-legacy.toolchain.cmake - - name: setup-opencv-source - run: | - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} - echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-android" >> $GITHUB_ENV - - name: build-armeabi-v7a - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-armeabi-v7a && cd build-armeabi-v7a - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="armeabi-v7a" -DANDROID_ARM_NEON=ON \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. - cmake --build . -j $(nproc) - cmake --build . --target install - - name: build-arm64-v8a - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-arm64-v8a && cd build-arm64-v8a - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="arm64-v8a" \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON -DOPENCV_EXTRA_FLAGS="-mno-outline-atomics" .. - cmake --build . -j $(nproc) - cmake --build . --target install - - name: build-x86 - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-x86 && cd build-x86 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="x86" \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. - cmake --build . -j $(nproc) - cmake --build . --target install - - name: build-x86_64 - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-x86_64 && cd build-x86_64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="x86_64" \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. - cmake --build . -j $(nproc) - cmake --build . --target install - - name: package - run: | - mkdir ${{ env.PACKAGE_NAME }} - cp -rf ${{ env.SOURCE_DIR }}/build-x86/install/* ${{ env.PACKAGE_NAME }}/ - cp -rf ${{ env.SOURCE_DIR }}/build-x86_64/install/* ${{ env.PACKAGE_NAME }}/ - cp -rf ${{ env.SOURCE_DIR }}/build-armeabi-v7a/install/* ${{ env.PACKAGE_NAME }}/ - cp -rf ${{ env.SOURCE_DIR }}/build-arm64-v8a/install/* ${{ env.PACKAGE_NAME }}/ - zip -9 -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} - - name: test-armeabi-v7a - run: | - cd test - mkdir build-armeabi-v7a && cd build-armeabi-v7a - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="armeabi-v7a" -DANDROID_ARM_NEON=ON \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/sdk/native/jni .. - cmake --build . -j $(nproc) - - name: test-arm64-v8a - run: | - cd test - mkdir build-arm64-v8a && cd build-arm64-v8a - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="arm64-v8a" \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/sdk/native/jni .. - cmake --build . -j $(nproc) - - name: test-x86 - run: | - cd test - mkdir build-x86 && cd build-x86 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="x86" \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/sdk/native/jni .. - cmake --build . -j $(nproc) - - name: test-x86_64 - run: | - cd test - mkdir build-x86_64 && cd build-x86_64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="x86_64" \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/sdk/native/jni .. - cmake --build . -j $(nproc) - - name: upload - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PACKAGE_NAME }} - path: ${{ env.PACKAGE_NAME }}.zip - - ios: - runs-on: macos-13 - strategy: - matrix: - opencv-version: [4.10.0] - env: - COMMON_CMAKE_OPTIONS: | - -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ - -DPLATFORM=OS \ - -DDEPLOYMENT_TARGET=$IOS_DEPLOYMENT_TARGET \ - -DENABLE_BITCODE=$ENABLE_BITCODE \ - -DENABLE_ARC=$ENABLE_ARC \ - -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ - -DCMAKE_INSTALL_PREFIX=install \ - -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ - steps: - - uses: actions/checkout@v4 - - name: setup-opencv-source - run: | - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} - echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-ios" >> $GITHUB_ENV - - name: workaround-opencv2-list - if: matrix.opencv-version == '2.4.13.7' - run: | - # workaround ar @list issue on macos - sed -i -e 's!\\"${objpath4}\\"!${objpath4}!g' ${{ env.SOURCE_DIR }}/modules/world/CMakeLists.txt - - name: build-arm64 - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-arm64 && cd build-arm64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="arm64" \ - `cat ../../options.txt` -DBUILD_opencv_world=ON -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. - # workaround ar @list issue on macos - cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } - cmake --build . --target install - - name: package - run: | - rm -rf opencv2.framework - mkdir -p opencv2.framework/Versions/A/Headers - mkdir -p opencv2.framework/Versions/A/Resources - ln -s A opencv2.framework/Versions/Current - ln -s Versions/Current/Headers opencv2.framework/Headers - ln -s Versions/Current/Resources opencv2.framework/Resources - ln -s Versions/Current/opencv2 opencv2.framework/opencv2 - lipo -create \ - ${{ env.SOURCE_DIR }}/build-arm64/install/lib/libopencv_world.a \ - -o opencv2.framework/Versions/A/opencv2 - cp -r ${{ env.SOURCE_DIR }}/build-arm64/install/include/opencv4/opencv2/* opencv2.framework/Versions/A/Headers/ || : - cp -r ${{ env.SOURCE_DIR }}/build-arm64/install/include/opencv2/* opencv2.framework/Versions/A/Headers/ || : - cp ${{ env.SOURCE_DIR }}/Info.plist opencv2.framework/Versions/A/Resources/ - rm -f ${{ env.PACKAGE_NAME }}.zip - zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip opencv2.framework - - name: test - run: | - cd test - mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="arm64" \ - -DOpenCV_DIR=$GITHUB_WORKSPACE .. - cmake --build . -j 4 - - name: upload-zip - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PACKAGE_NAME }} - path: ${{ env.PACKAGE_NAME }}.zip - - ios-simulator: - runs-on: macos-13 - strategy: - matrix: - opencv-version: [4.10.0] - env: - COMMON_CMAKE_OPTIONS: | - -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ - -DPLATFORM=SIMULATOR \ - -DDEPLOYMENT_TARGET=$IOS_DEPLOYMENT_TARGET \ - -DENABLE_BITCODE=$ENABLE_BITCODE \ - -DENABLE_ARC=$ENABLE_ARC \ - -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ - -DCMAKE_INSTALL_PREFIX=install \ - -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ - steps: - - uses: actions/checkout@v4 - - name: setup-opencv-source - run: | - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} - echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-ios-simulator" >> $GITHUB_ENV - - name: workaround-opencv2-list - if: matrix.opencv-version == '2.4.13.7' - run: | - # workaround ar @list issue on macos - sed -i -e 's!\\"${objpath4}\\"!${objpath4}!g' ${{ env.SOURCE_DIR }}/modules/world/CMakeLists.txt - - name: build-x86_64 - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-x86_64 && cd build-x86_64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="x86_64" \ - `cat ../../options.txt` -DBUILD_opencv_world=ON -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. - # workaround ar @list issue on macos - cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } - cmake --build . --target install - - name: build-arm64 - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-arm64 && cd build-arm64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="arm64" \ - `cat ../../options.txt` -DBUILD_opencv_world=ON -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. - # workaround ar @list issue on macos - cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } - cmake --build . --target install - - name: package - run: | - rm -rf opencv2.framework - mkdir -p opencv2.framework/Versions/A/Headers - mkdir -p opencv2.framework/Versions/A/Resources - ln -s A opencv2.framework/Versions/Current - ln -s Versions/Current/Headers opencv2.framework/Headers - ln -s Versions/Current/Resources opencv2.framework/Resources - ln -s Versions/Current/opencv2 opencv2.framework/opencv2 - lipo -create \ - ${{ env.SOURCE_DIR }}/build-x86_64/install/lib/libopencv_world.a \ - ${{ env.SOURCE_DIR }}/build-arm64/install/lib/libopencv_world.a \ - -o opencv2.framework/Versions/A/opencv2 - cp -r ${{ env.SOURCE_DIR }}/build-x86_64/install/include/opencv4/opencv2/* opencv2.framework/Versions/A/Headers/ || : - cp -r ${{ env.SOURCE_DIR }}/build-x86_64/install/include/opencv2/* opencv2.framework/Versions/A/Headers/ || : - cp ${{ env.SOURCE_DIR }}/Info.plist opencv2.framework/Versions/A/Resources/ - rm -f ${{ env.PACKAGE_NAME }}.zip - zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip opencv2.framework - - name: test - run: | - cd test - mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="x86_64;arm64" \ - -DOpenCV_DIR=$GITHUB_WORKSPACE .. - cmake --build . -j 4 - - name: upload-zip - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PACKAGE_NAME }} - path: ${{ env.PACKAGE_NAME }}.zip - - armlinux: - runs-on: ubuntu-latest - strategy: - matrix: - opencv-version: [4.10.0] - env: - COMMON_CMAKE_OPTIONS: | - -DCMAKE_INSTALL_PREFIX=install \ - -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ - steps: - - name: arm-gnu-toolchain - run: | - sudo apt-get update - sudo apt-get install g++-arm-linux-gnueabi g++-arm-linux-gnueabihf g++-aarch64-linux-gnu - - - uses: actions/checkout@v4 - - name: setup-opencv-source - run: | - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} - echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-armlinux" >> $GITHUB_ENV - - name: build-arm-linux-gnueabi - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-arm-linux-gnueabi && cd build-arm-linux-gnueabi - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/arm-linux-gnueabi.toolchain.cmake \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF .. - cmake --build . -j $(nproc) - cmake --build . --target install - - name: build-arm-linux-gnueabihf - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-arm-linux-gnueabihf && cd build-arm-linux-gnueabihf - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/arm-linux-gnueabihf.toolchain.cmake \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF .. - cmake --build . -j $(nproc) - cmake --build . --target install - - name: build-aarch64-linux-gnu - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-aarch64-linux-gnu && cd build-aarch64-linux-gnu - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/aarch64-linux-gnu.toolchain.cmake \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF .. - cmake --build . -j $(nproc) - cmake --build . --target install - - name: package - run: | - mkdir ${{ env.PACKAGE_NAME }} - mkdir ${{ env.PACKAGE_NAME }}/arm-linux-gnueabi - mkdir ${{ env.PACKAGE_NAME }}/arm-linux-gnueabihf - mkdir ${{ env.PACKAGE_NAME }}/aarch64-linux-gnu - cp -rf ${{ env.SOURCE_DIR }}/build-arm-linux-gnueabi/install/* ${{ env.PACKAGE_NAME }}/arm-linux-gnueabi/ - cp -rf ${{ env.SOURCE_DIR }}/build-arm-linux-gnueabihf/install/* ${{ env.PACKAGE_NAME }}/arm-linux-gnueabihf/ - cp -rf ${{ env.SOURCE_DIR }}/build-aarch64-linux-gnu/install/* ${{ env.PACKAGE_NAME }}/aarch64-linux-gnu/ - zip -9 -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} - - name: set-opencv-dir - if: matrix.opencv-version == '2.4.13.7' || matrix.opencv-version == '3.4.20' - run: echo "OPENCV_SUBDIR=share/OpenCV" >> $GITHUB_ENV - - name: set-opencv-dir - if: matrix.opencv-version == '4.10.0' - run: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV - - name: test-arm-linux-gnueabi - run: | - cd test - mkdir build-arm-linux-gnueabi && cd build-arm-linux-gnueabi - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/arm-linux-gnueabi.toolchain.cmake \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/arm-linux-gnueabi/${{ env.OPENCV_SUBDIR }} .. - cmake --build . -j $(nproc) - - name: test-arm-linux-gnueabihf - run: | - cd test - mkdir build-arm-linux-gnueabihf && cd build-arm-linux-gnueabihf - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/arm-linux-gnueabihf.toolchain.cmake \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/arm-linux-gnueabihf/${{ env.OPENCV_SUBDIR }} .. - cmake --build . -j $(nproc) - - name: test-aarch64-linux-gnu - run: | - cd test - mkdir build-aarch64-linux-gnu && cd build-aarch64-linux-gnu - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/aarch64-linux-gnu.toolchain.cmake \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/aarch64-linux-gnu/${{ env.OPENCV_SUBDIR }} .. - cmake --build . -j $(nproc) - - name: upload-zip - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PACKAGE_NAME }} - path: ${{ env.PACKAGE_NAME }}.zip - - macos: - runs-on: macos-13 - strategy: - matrix: - opencv-version: [4.10.0] - env: - COMMON_CMAKE_OPTIONS: | - -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ - -DDEPLOYMENT_TARGET=$MAC_DEPLOYMENT_TARGET \ - -DENABLE_BITCODE=OFF \ - -DENABLE_ARC=$ENABLE_ARC \ - -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ - -DCMAKE_INSTALL_PREFIX=install \ - -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ - steps: - - uses: actions/checkout@v4 - - name: setup-opencv-source - run: | - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} - echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-macos" >> $GITHUB_ENV - - name: workaround-opencv2-list - if: matrix.opencv-version == '2.4.13.7' - run: | - # workaround ar @list issue on macos - sed -i -e 's!\\"${objpath4}\\"!${objpath4}!g' ${{ env.SOURCE_DIR }}/modules/world/CMakeLists.txt - - name: build-x86_64 - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-x86_64 && cd build-x86_64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=MAC -DARCHS="x86_64" \ - `cat ../../options.txt` -DBUILD_opencv_world=ON .. - # workaround ar @list issue on macos - cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } - cmake --build . --target install - - name: build-arm64 - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-arm64 && cd build-arm64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=MAC_ARM64 -DARCHS="arm64" \ - `cat ../../options.txt` -DBUILD_opencv_world=ON .. - # workaround ar @list issue on macos - cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } - cmake --build . --target install - - name: package - run: | - rm -rf opencv2.framework - mkdir -p opencv2.framework/Versions/A/Headers - mkdir -p opencv2.framework/Versions/A/Resources - ln -s A opencv2.framework/Versions/Current - ln -s Versions/Current/Headers opencv2.framework/Headers - ln -s Versions/Current/Resources opencv2.framework/Resources - ln -s Versions/Current/opencv2 opencv2.framework/opencv2 - lipo -create \ - ${{ env.SOURCE_DIR }}/build-x86_64/install/lib/libopencv_world.a \ - ${{ env.SOURCE_DIR }}/build-arm64/install/lib/libopencv_world.a \ - -o opencv2.framework/Versions/A/opencv2 - cp -r ${{ env.SOURCE_DIR }}/build-x86_64/install/include/opencv4/opencv2/* opencv2.framework/Versions/A/Headers/ || : - cp -r ${{ env.SOURCE_DIR }}/build-x86_64/install/include/opencv2/* opencv2.framework/Versions/A/Headers/ || : - cp ${{ env.SOURCE_DIR }}/Info.plist opencv2.framework/Versions/A/Resources/ - rm -f ${{ env.PACKAGE_NAME }}.zip - zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip opencv2.framework - - name: test-x86_64 - run: | - cd test - mkdir build-x86_64 && cd build-x86_64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=MAC -DARCHS="x86_64" \ - -DOpenCV_DIR=$GITHUB_WORKSPACE .. - cmake --build . -j 4 - - name: test-arm64 - run: | - cd test - mkdir build-arm64 && cd build-arm64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=MAC_ARM64 -DARCHS="arm64" \ - -DOpenCV_DIR=$GITHUB_WORKSPACE .. - cmake --build . -j 4 - - name: upload-zip - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PACKAGE_NAME }} - path: ${{ env.PACKAGE_NAME }}.zip - - mac-catalyst: - runs-on: macos-13 - strategy: - matrix: - opencv-version: [4.10.0] - env: - COMMON_CMAKE_OPTIONS: | - -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ - -DPLATFORM=MAC_CATALYST \ - -DDEPLOYMENT_TARGET=$MAC_CATALYST_DEPLOYMENT_TARGET \ - -DENABLE_BITCODE=$ENABLE_BITCODE \ - -DENABLE_ARC=$ENABLE_ARC \ - -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ - -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions" \ - -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions" \ - -DCMAKE_INSTALL_PREFIX=install \ - -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ - steps: - - uses: actions/checkout@v4 - - name: setup-opencv-source - run: | - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} - echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-mac-catalyst" >> $GITHUB_ENV - - name: workaround-opencv2-list - if: matrix.opencv-version == '2.4.13.7' - run: | - # workaround ar @list issue on macos - sed -i -e 's!\\"${objpath4}\\"!${objpath4}!g' ${{ env.SOURCE_DIR }}/modules/world/CMakeLists.txt - - name: build-x86_64 - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-x86_64 && cd build-x86_64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="x86_64" \ - `cat ../../options.txt` -DBUILD_opencv_world=ON .. - # workaround ar @list issue on macos - cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } - cmake --build . --target install - - name: build-arm64 - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-arm64 && cd build-arm64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="arm64" \ - `cat ../../options.txt` -DBUILD_opencv_world=ON .. - # workaround ar @list issue on macos - cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } - cmake --build . --target install - - name: package - run: | - rm -rf opencv2.framework - mkdir -p opencv2.framework/Versions/A/Headers - mkdir -p opencv2.framework/Versions/A/Resources - ln -s A opencv2.framework/Versions/Current - ln -s Versions/Current/Headers opencv2.framework/Headers - ln -s Versions/Current/Resources opencv2.framework/Resources - ln -s Versions/Current/opencv2 opencv2.framework/opencv2 - lipo -create \ - ${{ env.SOURCE_DIR }}/build-x86_64/install/lib/libopencv_world.a \ - ${{ env.SOURCE_DIR }}/build-arm64/install/lib/libopencv_world.a \ - -o opencv2.framework/Versions/A/opencv2 - cp -r ${{ env.SOURCE_DIR }}/build-arm64/install/include/opencv4/opencv2/* opencv2.framework/Versions/A/Headers/ || : - cp -r ${{ env.SOURCE_DIR }}/build-arm64/install/include/opencv2/* opencv2.framework/Versions/A/Headers/ || : - cp ${{ env.SOURCE_DIR }}/Info.plist opencv2.framework/Versions/A/Resources/ - rm -f ${{ env.PACKAGE_NAME }}.zip - zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip opencv2.framework - - name: test - run: | - cd test - mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="x86_64;arm64" \ - -DOpenCV_DIR=$GITHUB_WORKSPACE .. - cmake --build . -j 4 - - name: upload-zip - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PACKAGE_NAME }} - path: ${{ env.PACKAGE_NAME }}.zip - windows: - strategy: - matrix: - opencv-version: [4.10.0] - os-compiler: - - { msvc-version: vs2015, windows-version: 2019, toolset-version: v140 } - - { msvc-version: vs2017, windows-version: 2019, toolset-version: v141 } - - { msvc-version: vs2019, windows-version: 2019, toolset-version: v142 } - - { msvc-version: vs2022, windows-version: 2022, toolset-version: v143 } - runs-on: windows-${{ matrix.os-compiler.windows-version }} - env: - UseMultiToolTask: true - COMMON_CMAKE_OPTIONS: -T ${{ matrix.os-compiler.toolset-version }},host=x64 -DCMAKE_INSTALL_PREFIX=install -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" - steps: - - uses: actions/checkout@v4 - - name: setup-opencv-source - run: | - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} - echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $env:GITHUB_ENV - echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-windows-${{ matrix.os-compiler.msvc-version }}" >> $env:GITHUB_ENV - - name: build-x86 - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-x86; cd build-x86 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A Win32 $(type ../../options.txt) -DBUILD_opencv_world=OFF .. - cmake --build . --config Release -j 4 - cmake --build . --config Release --target install - - name: build-x64 - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-x64; cd build-x64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A x64 $(type ../../options.txt) -DBUILD_opencv_world=OFF .. - cmake --build . --config Release -j 4 - cmake --build . --config Release --target install - - name: build-arm - if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-arm; cd build-arm - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A arm -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=ARM $(type ../../options.txt) -DBUILD_opencv_world=OFF .. - cmake --build . --config Release -j 4 - cmake --build . --config Release --target install - - name: build-arm64 - if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-arm64; cd build-arm64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A arm64 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=ARM64 $(type ../../options.txt) -DBUILD_opencv_world=OFF .. - cmake --build . --config Release -j 4 - cmake --build . --config Release --target install - - name: package - if: matrix.os-compiler.msvc-version == 'vs2015' || matrix.os-compiler.msvc-version == 'vs2017' - run: | - mkdir ${{ env.PACKAGE_NAME }} - mkdir ${{ env.PACKAGE_NAME }}/x86 - mkdir ${{ env.PACKAGE_NAME }}/x64 - Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-x86\install\*" -Destination "${{ env.PACKAGE_NAME }}\x86" - Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-x64\install\*" -Destination "${{ env.PACKAGE_NAME }}\x64" - 7z a -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} - - name: package - if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' - run: | - mkdir ${{ env.PACKAGE_NAME }} - mkdir ${{ env.PACKAGE_NAME }}/x86 - mkdir ${{ env.PACKAGE_NAME }}/x64 - mkdir ${{ env.PACKAGE_NAME }}/arm - mkdir ${{ env.PACKAGE_NAME }}/arm64 - Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-x86\install\*" -Destination "${{ env.PACKAGE_NAME }}\x86" - Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-x64\install\*" -Destination "${{ env.PACKAGE_NAME }}\x64" - Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-arm\install\*" -Destination "${{ env.PACKAGE_NAME }}\arm" - Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-arm64\install\*" -Destination "${{ env.PACKAGE_NAME }}\arm64" - 7z a -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} - - name: test-x86 - run: | - cd test - mkdir build-x86; cd build-x86 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A Win32 -DOpenCV_DIR="$env:GITHUB_WORKSPACE\${{ env.PACKAGE_NAME }}\x86" -DOpenCV_STATIC=ON .. - cmake --build . --config Release -j 4 - - name: test-x64 - run: | - cd test - mkdir build-x64; cd build-x64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A x64 -DOpenCV_DIR="$env:GITHUB_WORKSPACE\${{ env.PACKAGE_NAME }}\x64" -DOpenCV_STATIC=ON .. - cmake --build . --config Release -j 4 - - name: test-arm - if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' - run: | - cd test - mkdir build-arm; cd build-arm - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A arm -DOpenCV_DIR="$env:GITHUB_WORKSPACE\${{ env.PACKAGE_NAME }}\arm" -DOpenCV_STATIC=ON .. - cmake --build . --config Release -j 4 - - name: test-arm64 - if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' - run: | - cd test - mkdir build-arm64; cd build-arm64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A arm64 -DOpenCV_DIR="$env:GITHUB_WORKSPACE\${{ env.PACKAGE_NAME }}\arm64" -DOpenCV_STATIC=ON .. - cmake --build . --config Release -j 4 - - name: upload-zip - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PACKAGE_NAME }} - path: ${{ env.PACKAGE_NAME }}.zip - - ubuntu: - strategy: - matrix: - opencv-version: [4.10.0] - os-ubuntu: - - { ubuntu-id: 2004, ubuntu-version: 20.04 } - - { ubuntu-id: 2204, ubuntu-version: 22.04 } - runs-on: ubuntu-${{ matrix.os-ubuntu.ubuntu-version }} - env: - COMMON_CMAKE_OPTIONS: -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" - steps: - - uses: actions/checkout@v4 - - name: setup-opencv-source - run: | - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} - echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-ubuntu-${{ matrix.os-ubuntu.ubuntu-id }}" >> $GITHUB_ENV - - name: build - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} `cat ../../options.txt` -DBUILD_opencv_world=OFF .. - cmake --build . -j $(nproc) - cmake --build . --target install - - name: package - run: | - rm -rf ${{ env.PACKAGE_NAME }} - mkdir -p ${{ env.PACKAGE_NAME }} - cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ - rm -f ${{ env.PACKAGE_NAME }}.zip - zip -9 -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} - - name: set-opencv-dir - if: matrix.opencv-version == '2.4.13.7' || matrix.opencv-version == '3.4.20' - run: echo "OPENCV_SUBDIR=share/OpenCV" >> $GITHUB_ENV - - name: set-opencv-dir - if: matrix.opencv-version == '4.10.0' - run: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV - - name: test - run: | - cd test - mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} .. - cmake --build . -j $(nproc) - - name: upload - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PACKAGE_NAME }} - path: ${{ env.PACKAGE_NAME }}.zip - - webassembly: - runs-on: ubuntu-20.04 - strategy: - matrix: - opencv-version: [4.10.0] - env: - COMMON_CMAKE_OPTIONS: | - -DCMAKE_TOOLCHAIN_FILE=../emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \ - -DCMAKE_INSTALL_PREFIX=install \ - -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ - steps: - - uses: actions/checkout@v4 - - name: emsdk - run: | - git clone https://github.com/emscripten-core/emsdk.git - cd emsdk - ./emsdk install $EMSCRIPTEN_VERSION - ./emsdk activate $EMSCRIPTEN_VERSION - - name: setup-opencv-source - run: | - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} - echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-webassembly" >> $GITHUB_ENV - - name: build - run: | - source emsdk/emsdk_env.sh - cd ${{ env.SOURCE_DIR }} - patch -p1 -i ../patches/opencv-${{ matrix.opencv-version }}-unsafe-xadd.patch - mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=OFF -DCV_ENABLE_INTRINSICS=OFF -DBUILD_WASM_INTRIN_TESTS=OFF \ - -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0" \ - -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0" \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. - cmake --build . -j $(nproc) - cmake --build . --target install - - name: build-simd - run: | - source emsdk/emsdk_env.sh - cd ${{ env.SOURCE_DIR }} - mkdir build-simd && cd build-simd - cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=OFF -DCV_ENABLE_INTRINSICS=ON -DBUILD_WASM_INTRIN_TESTS=OFF \ - -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0 -msimd128" \ - -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0 -msimd128" \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. - cmake --build . -j $(nproc) - cmake --build . --target install - - name: build-threads - run: | - source emsdk/emsdk_env.sh - cd ${{ env.SOURCE_DIR }} - patch -p1 -R -i ../patches/opencv-${{ matrix.opencv-version }}-unsafe-xadd.patch - mkdir build-threads && cd build-threads - cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=ON -DCV_ENABLE_INTRINSICS=OFF -DBUILD_WASM_INTRIN_TESTS=OFF \ - -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ - -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. - cmake --build . -j $(nproc) - cmake --build . --target install - - name: build-simd-threads - run: | - source emsdk/emsdk_env.sh - cd ${{ env.SOURCE_DIR }} - mkdir build-simd-threads && cd build-simd-threads - cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=ON -DCV_ENABLE_INTRINSICS=ON -DBUILD_WASM_INTRIN_TESTS=OFF \ - -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ - -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. - cmake --build . -j $(nproc) - cmake --build . --target install - - name: package - run: | - rm -rf ${{ env.PACKAGE_NAME }} - mkdir -p ${{ env.PACKAGE_NAME }} - cp -rf ${{ env.SOURCE_DIR }}/build/install ${{ env.PACKAGE_NAME }}/basic - cp -rf ${{ env.SOURCE_DIR }}/build-simd/install ${{ env.PACKAGE_NAME }}/simd - cp -rf ${{ env.SOURCE_DIR }}/build-threads/install ${{ env.PACKAGE_NAME }}/threads - cp -rf ${{ env.SOURCE_DIR }}/build-simd-threads/install ${{ env.PACKAGE_NAME }}/simd-threads - rm -f ${{ env.PACKAGE_NAME }}.zip - zip -9 -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} - - name: set-opencv-dir - if: matrix.opencv-version == '2.4.13.7' || matrix.opencv-version == '3.4.20' - run: echo "OPENCV_SUBDIR=share/OpenCV" >> $GITHUB_ENV - - name: set-opencv-dir - if: matrix.opencv-version == '4.10.0' - run: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV - - name: test - run: | - cd test - mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0" \ - -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0" \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/basic/${{ env.OPENCV_SUBDIR }} .. - cmake --build . -j $(nproc) - - name: test-simd - run: | - cd test - mkdir build-simd && cd build-simd - cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0 -msimd128" \ - -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0 -msimd128" \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/simd/${{ env.OPENCV_SUBDIR }} .. - cmake --build . -j $(nproc) - - name: test-threads - run: | - cd test - mkdir build-threads && cd build-threads - cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ - -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/threads/${{ env.OPENCV_SUBDIR }} .. - cmake --build . -j $(nproc) - - name: test-simd-threads - run: | - cd test - mkdir build-simd-threads && cd build-simd-threads - cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ - -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/simd-threads/${{ env.OPENCV_SUBDIR }} .. - cmake --build . -j $(nproc) - - name: upload - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PACKAGE_NAME }} - path: ${{ env.PACKAGE_NAME }}.zip - - apple: - needs: [macos, ios, ios-simulator, mac-catalyst] - runs-on: macos-13 - strategy: - matrix: - opencv-version: [4.10.0] - steps: - - run: sudo xcode-select --switch /Applications/Xcode_15.2.app - - uses: actions/checkout@v4 - - name: setup-opencv-package - run: | - echo "MACOS_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-macos" >> $GITHUB_ENV - echo "IOS_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-ios" >> $GITHUB_ENV - echo "IOS_SIMULATOR_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-ios-simulator" >> $GITHUB_ENV - echo "MAC_CATALYST_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-mac-catalyst" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-apple" >> $GITHUB_ENV - - name: download-macos-package - uses: actions/download-artifact@v4 - with: - name: ${{ env.MACOS_PACKAGE_NAME }} - - name: download-ios-package - uses: actions/download-artifact@v4 - with: - name: ${{ env.IOS_PACKAGE_NAME }} - - name: download-ios-simulator-package - uses: actions/download-artifact@v4 - with: - name: ${{ env.IOS_SIMULATOR_PACKAGE_NAME }} - - name: download-mac-catalyst-package - uses: actions/download-artifact@v4 - with: - name: ${{ env.MAC_CATALYST_PACKAGE_NAME }} - - name: create-xcframwork - run: | - mkdir -p ${{ env.MACOS_PACKAGE_NAME }} - mkdir -p ${{ env.IOS_PACKAGE_NAME }} - mkdir -p ${{ env.IOS_SIMULATOR_PACKAGE_NAME }} - mkdir -p ${{ env.MAC_CATALYST_PACKAGE_NAME }} - unzip -q ${{ env.MACOS_PACKAGE_NAME }}.zip -d ${{ env.MACOS_PACKAGE_NAME }} - unzip -q ${{ env.IOS_PACKAGE_NAME }}.zip -d ${{ env.IOS_PACKAGE_NAME }} - unzip -q ${{ env.IOS_SIMULATOR_PACKAGE_NAME }}.zip -d ${{ env.IOS_SIMULATOR_PACKAGE_NAME }} - unzip -q ${{ env.MAC_CATALYST_PACKAGE_NAME }}.zip -d ${{ env.MAC_CATALYST_PACKAGE_NAME }} - xcodebuild -create-xcframework \ - -framework ${{ env.MACOS_PACKAGE_NAME }}/opencv2.framework \ - -framework ${{ env.IOS_PACKAGE_NAME }}/opencv2.framework \ - -framework ${{ env.IOS_SIMULATOR_PACKAGE_NAME }}/opencv2.framework \ - -framework ${{ env.MAC_CATALYST_PACKAGE_NAME }}/opencv2.framework \ - -output opencv2.xcframework - rm -f ${{ env.PACKAGE_NAME }}.zip - zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip opencv2.xcframework - - name: upload-zip - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PACKAGE_NAME }} - path: ${{ env.PACKAGE_NAME }}.zip - - release: - permissions: - contents: write # for softprops/action-gh-release to create a release - needs: [android, ios, ios-simulator, armlinux, macos, mac-catalyst, windows, ubuntu, webassembly, apple] - runs-on: ubuntu-latest - steps: - - name: download - uses: actions/download-artifact@v4 - with: - path: artifacts - - - name: create-release - uses: softprops/action-gh-release@v2 - with: - token: ${{ secrets.GITHUB_TOKEN }} - tag_name: ${{ needs.setup.outputs.VERSION }} - name: Release ${{ needs.setup.outputs.VERSION }} - files: artifacts/*/*.zip diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml new file mode 100644 index 0000000..e7d65dc --- /dev/null +++ b/.github/workflows/wasm.yml @@ -0,0 +1,164 @@ +name: wasm +# on: pull_request +on: + push: + tags: + - '*' + pull_request: + branches: ["main"] + +env: + EMSCRIPTEN_VERSION: 3.1.28 + +permissions: + contents: read + +jobs: + webassembly: + runs-on: ubuntu-20.04 + strategy: + matrix: + opencv-version: [4.10.0] + env: + COMMON_CMAKE_OPTIONS: | + -DCMAKE_TOOLCHAIN_FILE=../emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \ + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ + steps: + - uses: actions/checkout@v4 + - name: emsdk + run: | + git clone https://github.com/emscripten-core/emsdk.git + cd emsdk + ./emsdk install $EMSCRIPTEN_VERSION + ./emsdk activate $EMSCRIPTEN_VERSION + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} + echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-webassembly" >> $GITHUB_ENV + - name: build + run: | + source emsdk/emsdk_env.sh + cd ${{ env.SOURCE_DIR }} + patch -p1 -i ../patches/opencv-${{ matrix.opencv-version }}-unsafe-xadd.patch + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=OFF -DCV_ENABLE_INTRINSICS=OFF -DBUILD_WASM_INTRIN_TESTS=OFF \ + -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0" \ + -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0" \ + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: build-simd + run: | + source emsdk/emsdk_env.sh + cd ${{ env.SOURCE_DIR }} + mkdir build-simd && cd build-simd + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=OFF -DCV_ENABLE_INTRINSICS=ON -DBUILD_WASM_INTRIN_TESTS=OFF \ + -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0 -msimd128" \ + -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0 -msimd128" \ + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: build-threads + run: | + source emsdk/emsdk_env.sh + cd ${{ env.SOURCE_DIR }} + patch -p1 -R -i ../patches/opencv-${{ matrix.opencv-version }}-unsafe-xadd.patch + mkdir build-threads && cd build-threads + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=ON -DCV_ENABLE_INTRINSICS=OFF -DBUILD_WASM_INTRIN_TESTS=OFF \ + -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ + -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: build-simd-threads + run: | + source emsdk/emsdk_env.sh + cd ${{ env.SOURCE_DIR }} + mkdir build-simd-threads && cd build-simd-threads + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=ON -DCV_ENABLE_INTRINSICS=ON -DBUILD_WASM_INTRIN_TESTS=OFF \ + -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ + -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: package + run: | + rm -rf ${{ env.PACKAGE_NAME }} + mkdir -p ${{ env.PACKAGE_NAME }} + cp -rf ${{ env.SOURCE_DIR }}/build/install ${{ env.PACKAGE_NAME }}/basic + cp -rf ${{ env.SOURCE_DIR }}/build-simd/install ${{ env.PACKAGE_NAME }}/simd + cp -rf ${{ env.SOURCE_DIR }}/build-threads/install ${{ env.PACKAGE_NAME }}/threads + cp -rf ${{ env.SOURCE_DIR }}/build-simd-threads/install ${{ env.PACKAGE_NAME }}/simd-threads + rm -f ${{ env.PACKAGE_NAME }}.zip + zip -9 -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} + - name: set-opencv-dir + if: matrix.opencv-version == '4.10.0' + run: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV + - name: test + run: | + cd test + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0" \ + -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/basic/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j $(nproc) + - name: test-simd + run: | + cd test + mkdir build-simd && cd build-simd + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0 -msimd128" \ + -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0 -msimd128" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/simd/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j $(nproc) + - name: test-threads + run: | + cd test + mkdir build-threads && cd build-threads + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ + -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/threads/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j $(nproc) + - name: test-simd-threads + run: | + cd test + mkdir build-simd-threads && cd build-simd-threads + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ + -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/simd-threads/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j $(nproc) + - name: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.zip + + release: + permissions: + contents: write # for softprops/action-gh-release to create a release + needs: [webassembly] + runs-on: ubuntu-latest + steps: + - name: download + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: create-release + uses: softprops/action-gh-release@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag_name: ${{ needs.setup.outputs.VERSION }} + name: Release ${{ needs.setup.outputs.VERSION }} + files: artifacts/*/*.zip diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 0000000..fabf75f --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,134 @@ +name: windows +# on: pull_request +on: + push: + tags: + - '*' + pull_request: + branches: ["main"] + +permissions: + contents: read + +jobs: + windows: + strategy: + matrix: + opencv-version: [4.10.0] + os-compiler: + - { msvc-version: vs2019, windows-version: 2019, toolset-version: v142 } + - { msvc-version: vs2022, windows-version: 2022, toolset-version: v143 } + runs-on: windows-${{ matrix.os-compiler.windows-version }} + env: + UseMultiToolTask: true + COMMON_CMAKE_OPTIONS: -T ${{ matrix.os-compiler.toolset-version }},host=x64 -DCMAKE_INSTALL_PREFIX=install -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" + steps: + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} + echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $env:GITHUB_ENV + echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-windows-${{ matrix.os-compiler.msvc-version }}" >> $env:GITHUB_ENV + - name: build-x86 + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-x86; cd build-x86 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A Win32 $(type ../../options.txt) -DBUILD_opencv_world=OFF .. + cmake --build . --config Release -j 4 + cmake --build . --config Release --target install + - name: build-x64 + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-x64; cd build-x64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A x64 $(type ../../options.txt) -DBUILD_opencv_world=OFF .. + cmake --build . --config Release -j 4 + cmake --build . --config Release --target install + - name: build-arm + if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-arm; cd build-arm + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A arm -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=ARM $(type ../../options.txt) -DBUILD_opencv_world=OFF .. + cmake --build . --config Release -j 4 + cmake --build . --config Release --target install + - name: build-arm64 + if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-arm64; cd build-arm64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A arm64 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=ARM64 $(type ../../options.txt) -DBUILD_opencv_world=OFF .. + cmake --build . --config Release -j 4 + cmake --build . --config Release --target install + - name: package + if: matrix.os-compiler.msvc-version == 'vs2015' || matrix.os-compiler.msvc-version == 'vs2017' + run: | + mkdir ${{ env.PACKAGE_NAME }} + mkdir ${{ env.PACKAGE_NAME }}/x86 + mkdir ${{ env.PACKAGE_NAME }}/x64 + Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-x86\install\*" -Destination "${{ env.PACKAGE_NAME }}\x86" + Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-x64\install\*" -Destination "${{ env.PACKAGE_NAME }}\x64" + 7z a -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} + - name: package + if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' + run: | + mkdir ${{ env.PACKAGE_NAME }} + mkdir ${{ env.PACKAGE_NAME }}/x86 + mkdir ${{ env.PACKAGE_NAME }}/x64 + mkdir ${{ env.PACKAGE_NAME }}/arm + mkdir ${{ env.PACKAGE_NAME }}/arm64 + Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-x86\install\*" -Destination "${{ env.PACKAGE_NAME }}\x86" + Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-x64\install\*" -Destination "${{ env.PACKAGE_NAME }}\x64" + Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-arm\install\*" -Destination "${{ env.PACKAGE_NAME }}\arm" + Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-arm64\install\*" -Destination "${{ env.PACKAGE_NAME }}\arm64" + 7z a -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} + - name: test-x86 + run: | + cd test + mkdir build-x86; cd build-x86 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A Win32 -DOpenCV_DIR="$env:GITHUB_WORKSPACE\${{ env.PACKAGE_NAME }}\x86" -DOpenCV_STATIC=ON .. + cmake --build . --config Release -j 4 + - name: test-x64 + run: | + cd test + mkdir build-x64; cd build-x64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A x64 -DOpenCV_DIR="$env:GITHUB_WORKSPACE\${{ env.PACKAGE_NAME }}\x64" -DOpenCV_STATIC=ON .. + cmake --build . --config Release -j 4 + - name: test-arm + if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' + run: | + cd test + mkdir build-arm; cd build-arm + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A arm -DOpenCV_DIR="$env:GITHUB_WORKSPACE\${{ env.PACKAGE_NAME }}\arm" -DOpenCV_STATIC=ON .. + cmake --build . --config Release -j 4 + - name: test-arm64 + if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' + run: | + cd test + mkdir build-arm64; cd build-arm64 + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A arm64 -DOpenCV_DIR="$env:GITHUB_WORKSPACE\${{ env.PACKAGE_NAME }}\arm64" -DOpenCV_STATIC=ON .. + cmake --build . --config Release -j 4 + - name: upload-zip + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.zip + + release: + permissions: + contents: write # for softprops/action-gh-release to create a release + needs: [windows] + runs-on: ubuntu-latest + steps: + - name: download + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: create-release + uses: softprops/action-gh-release@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag_name: ${{ needs.setup.outputs.VERSION }} + name: Release ${{ needs.setup.outputs.VERSION }} + files: artifacts/*/*.zip diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 06d8cb3..e6aae79 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,6 +4,10 @@ cmake_minimum_required(VERSION 3.5) # opencv4 requires c++11 set(CMAKE_CXX_STANDARD 11) +if(LINUX OR APPLE) + find_package(Iconv REQUIRED) +endif() + if(APPLE OR IOS) # set OpenCV_DIR to where opencv2.framework resides find_library(OpenCV_LIBS NAMES opencv2 PATHS ${OpenCV_DIR}) From 56dcffa89a02160d4e3e9afbe36ba886f92b5c9a Mon Sep 17 00:00:00 2001 From: rainy liu Date: Mon, 26 Aug 2024 17:23:56 +0800 Subject: [PATCH 06/41] fix --- .github/workflows/android.yml | 15 ------ .github/workflows/apple.yml | 98 +++-------------------------------- .github/workflows/linux.yml | 48 ++++------------- .github/workflows/wasm.yml | 32 ++++++------ .github/workflows/windows.yml | 34 ------------ 5 files changed, 35 insertions(+), 192 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 6016d69..f602b1c 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -51,14 +51,6 @@ jobs: `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON -DOPENCV_EXTRA_FLAGS="-mno-outline-atomics" .. cmake --build . -j $(nproc) cmake --build . --target install - - name: build-x86 - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-x86 && cd build-x86 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="x86" \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. - cmake --build . -j $(nproc) - cmake --build . --target install - name: build-x86_64 run: | cd ${{ env.SOURCE_DIR }} @@ -89,13 +81,6 @@ jobs: cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="arm64-v8a" \ -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/sdk/native/jni .. cmake --build . -j $(nproc) - - name: test-x86 - run: | - cd test - mkdir build-x86 && cd build-x86 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="x86" \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/sdk/native/jni .. - cmake --build . -j $(nproc) - name: test-x86_64 run: | cd test diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml index c09009f..e292ea0 100644 --- a/.github/workflows/apple.yml +++ b/.github/workflows/apple.yml @@ -11,7 +11,6 @@ env: DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer IOS_DEPLOYMENT_TARGET: '13.0' MAC_DEPLOYMENT_TARGET: '11.0' - MAC_CATALYST_DEPLOYMENT_TARGET: '13.1' ENABLE_BITCODE: OFF ENABLE_ARC: OFF ENABLE_VISIBILITY: OFF @@ -29,7 +28,7 @@ jobs: env: COMMON_CMAKE_OPTIONS: | -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ - -DPLATFORM=OS \ + -DPLATFORM=OS64 \ -DDEPLOYMENT_TARGET=$IOS_DEPLOYMENT_TARGET \ -DENABLE_BITCODE=$ENABLE_BITCODE \ -DENABLE_ARC=$ENABLE_ARC \ @@ -50,7 +49,7 @@ jobs: cd ${{ env.SOURCE_DIR }} mkdir build-arm64 && cd build-arm64 cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="arm64" \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF -DWITH_OPENCL=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + `cat ../../options.txt` -DBUILD_opencv_world=ON -DWITH_OPENCL=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. # workaround ar @list issue on macos cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } cmake --build . --target install @@ -113,7 +112,7 @@ jobs: cd ${{ env.SOURCE_DIR }} mkdir build-x86_64 && cd build-x86_64 cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="x86_64" \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + `cat ../../options.txt` -DBUILD_opencv_world=ON -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. # workaround ar @list issue on macos cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } cmake --build . --target install @@ -122,7 +121,7 @@ jobs: cd ${{ env.SOURCE_DIR }} mkdir build-arm64 && cd build-arm64 cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="arm64" \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF -DWITH_OPENCL=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + `cat ../../options.txt` -DBUILD_opencv_world=ON -DWITH_OPENCL=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. # workaround ar @list issue on macos cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } cmake --build . --target install @@ -185,7 +184,7 @@ jobs: cd ${{ env.SOURCE_DIR }} mkdir build-x86_64 && cd build-x86_64 cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=MAC -DARCHS="x86_64" \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF .. + `cat ../../options.txt` -DBUILD_opencv_world=ON .. # workaround ar @list issue on macos cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } cmake --build . --target install @@ -194,7 +193,7 @@ jobs: cd ${{ env.SOURCE_DIR }} mkdir build-arm64 && cd build-arm64 cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=MAC_ARM64 -DARCHS="arm64" \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF .. + `cat ../../options.txt` -DBUILD_opencv_world=ON .. # workaround ar @list issue on macos cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } cmake --build . --target install @@ -236,81 +235,8 @@ jobs: name: ${{ env.PACKAGE_NAME }} path: ${{ env.PACKAGE_NAME }}.zip - mac-catalyst: - runs-on: macos-13 - strategy: - matrix: - opencv-version: [4.10.0] - env: - COMMON_CMAKE_OPTIONS: | - -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ - -DPLATFORM=MAC_CATALYST \ - -DDEPLOYMENT_TARGET=$MAC_CATALYST_DEPLOYMENT_TARGET \ - -DENABLE_BITCODE=$ENABLE_BITCODE \ - -DENABLE_ARC=$ENABLE_ARC \ - -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ - -DCMAKE_INSTALL_PREFIX=install \ - -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ - steps: - - uses: actions/checkout@v4 - - name: setup-opencv-source - run: | - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} - echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-mac-catalyst" >> $GITHUB_ENV - - name: build-x86_64 - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-x86_64 && cd build-x86_64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="x86_64" \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF .. - # workaround ar @list issue on macos - cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } - cmake --build . --target install - - name: build-arm64 - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-arm64 && cd build-arm64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="arm64" \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF .. - # workaround ar @list issue on macos - cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } - cmake --build . --target install - - name: package - run: | - rm -rf opencv2.framework - mkdir -p opencv2.framework/Versions/A/Headers - mkdir -p opencv2.framework/Versions/A/Resources - ln -s A opencv2.framework/Versions/Current - ln -s Versions/Current/Headers opencv2.framework/Headers - ln -s Versions/Current/Resources opencv2.framework/Resources - ln -s Versions/Current/opencv2 opencv2.framework/opencv2 - lipo -create \ - ${{ env.SOURCE_DIR }}/build-x86_64/install/lib/libopencv_world.a \ - ${{ env.SOURCE_DIR }}/build-arm64/install/lib/libopencv_world.a \ - -o opencv2.framework/Versions/A/opencv2 - cp -r ${{ env.SOURCE_DIR }}/build-arm64/install/include/opencv4/opencv2/* opencv2.framework/Versions/A/Headers/ || : - cp -r ${{ env.SOURCE_DIR }}/build-arm64/install/include/opencv2/* opencv2.framework/Versions/A/Headers/ || : - cp ${{ env.SOURCE_DIR }}/Info.plist opencv2.framework/Versions/A/Resources/ - rm -f ${{ env.PACKAGE_NAME }}.zip - zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip opencv2.framework - - name: test - run: | - cd test - mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="x86_64;arm64" \ - -DOpenCV_DIR=$GITHUB_WORKSPACE .. - cmake --build . -j 4 - - name: upload-zip - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PACKAGE_NAME }} - path: ${{ env.PACKAGE_NAME }}.zip - apple: - needs: [macos, ios, ios-simulator, mac-catalyst] + needs: [macos, ios, ios-simulator] runs-on: macos-13 strategy: matrix: @@ -323,7 +249,6 @@ jobs: echo "MACOS_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-macos" >> $GITHUB_ENV echo "IOS_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-ios" >> $GITHUB_ENV echo "IOS_SIMULATOR_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-ios-simulator" >> $GITHUB_ENV - echo "MAC_CATALYST_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-mac-catalyst" >> $GITHUB_ENV echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-apple" >> $GITHUB_ENV - name: download-macos-package uses: actions/download-artifact@v4 @@ -337,25 +262,18 @@ jobs: uses: actions/download-artifact@v4 with: name: ${{ env.IOS_SIMULATOR_PACKAGE_NAME }} - - name: download-mac-catalyst-package - uses: actions/download-artifact@v4 - with: - name: ${{ env.MAC_CATALYST_PACKAGE_NAME }} - name: create-xcframwork run: | mkdir -p ${{ env.MACOS_PACKAGE_NAME }} mkdir -p ${{ env.IOS_PACKAGE_NAME }} mkdir -p ${{ env.IOS_SIMULATOR_PACKAGE_NAME }} - mkdir -p ${{ env.MAC_CATALYST_PACKAGE_NAME }} unzip -q ${{ env.MACOS_PACKAGE_NAME }}.zip -d ${{ env.MACOS_PACKAGE_NAME }} unzip -q ${{ env.IOS_PACKAGE_NAME }}.zip -d ${{ env.IOS_PACKAGE_NAME }} unzip -q ${{ env.IOS_SIMULATOR_PACKAGE_NAME }}.zip -d ${{ env.IOS_SIMULATOR_PACKAGE_NAME }} - unzip -q ${{ env.MAC_CATALYST_PACKAGE_NAME }}.zip -d ${{ env.MAC_CATALYST_PACKAGE_NAME }} xcodebuild -create-xcframework \ -framework ${{ env.MACOS_PACKAGE_NAME }}/opencv2.framework \ -framework ${{ env.IOS_PACKAGE_NAME }}/opencv2.framework \ -framework ${{ env.IOS_SIMULATOR_PACKAGE_NAME }}/opencv2.framework \ - -framework ${{ env.MAC_CATALYST_PACKAGE_NAME }}/opencv2.framework \ -output opencv2.xcframework rm -f ${{ env.PACKAGE_NAME }}.zip zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip opencv2.xcframework @@ -368,7 +286,7 @@ jobs: release: permissions: contents: write # for softprops/action-gh-release to create a release - needs: [ios, ios-simulator, macos, mac-catalyst, apple] + needs: [ios, ios-simulator, macos, apple] runs-on: ubuntu-latest steps: - name: download diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 94c5ad5..d2613fb 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -25,7 +25,9 @@ jobs: - name: arm-gnu-toolchain run: | sudo apt-get update - sudo apt-get install g++-arm-linux-gnueabi g++-arm-linux-gnueabihf g++-aarch64-linux-gnu + sudo apt-get install g++-arm-linux-gnueabi g++-arm-linux-gnueabihf g++-aarch64-linux-gnu \ + libgtk-3-dev ffmpeg libavcodec-dev libavformat-dev libavutil-dev \ + libswscale-dev libgflags-dev \ - uses: actions/checkout@v4 - name: setup-opencv-source @@ -34,57 +36,23 @@ jobs: git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-armlinux" >> $GITHUB_ENV - - name: build-arm-linux-gnueabi - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-arm-linux-gnueabi && cd build-arm-linux-gnueabi - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/arm-linux-gnueabi.toolchain.cmake \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF .. - cmake --build . -j $(nproc) - cmake --build . --target install - - name: build-arm-linux-gnueabihf - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-arm-linux-gnueabihf && cd build-arm-linux-gnueabihf - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/arm-linux-gnueabihf.toolchain.cmake \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF .. - cmake --build . -j $(nproc) - cmake --build . --target install - name: build-aarch64-linux-gnu run: | cd ${{ env.SOURCE_DIR }} mkdir build-aarch64-linux-gnu && cd build-aarch64-linux-gnu cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/aarch64-linux-gnu.toolchain.cmake \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF .. + `cat ../../options.txt` .. cmake --build . -j $(nproc) cmake --build . --target install - name: package run: | mkdir ${{ env.PACKAGE_NAME }} - mkdir ${{ env.PACKAGE_NAME }}/arm-linux-gnueabi - mkdir ${{ env.PACKAGE_NAME }}/arm-linux-gnueabihf mkdir ${{ env.PACKAGE_NAME }}/aarch64-linux-gnu - cp -rf ${{ env.SOURCE_DIR }}/build-arm-linux-gnueabi/install/* ${{ env.PACKAGE_NAME }}/arm-linux-gnueabi/ - cp -rf ${{ env.SOURCE_DIR }}/build-arm-linux-gnueabihf/install/* ${{ env.PACKAGE_NAME }}/arm-linux-gnueabihf/ cp -rf ${{ env.SOURCE_DIR }}/build-aarch64-linux-gnu/install/* ${{ env.PACKAGE_NAME }}/aarch64-linux-gnu/ zip -9 -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} - name: set-opencv-dir if: matrix.opencv-version == '4.10.0' run: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV - - name: test-arm-linux-gnueabi - run: | - cd test - mkdir build-arm-linux-gnueabi && cd build-arm-linux-gnueabi - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/arm-linux-gnueabi.toolchain.cmake \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/arm-linux-gnueabi/${{ env.OPENCV_SUBDIR }} .. - cmake --build . -j $(nproc) - - name: test-arm-linux-gnueabihf - run: | - cd test - mkdir build-arm-linux-gnueabihf && cd build-arm-linux-gnueabihf - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/arm-linux-gnueabihf.toolchain.cmake \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/arm-linux-gnueabihf/${{ env.OPENCV_SUBDIR }} .. - cmake --build . -j $(nproc) - name: test-aarch64-linux-gnu run: | cd test @@ -105,11 +73,17 @@ jobs: os-ubuntu: - { ubuntu-id: 2004, ubuntu-version: 20.04 } - { ubuntu-id: 2204, ubuntu-version: 22.04 } + - { ubuntu-id: 2404, ubuntu-version: 24.04 } runs-on: ubuntu-${{ matrix.os-ubuntu.ubuntu-version }} env: COMMON_CMAKE_OPTIONS: -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" steps: - uses: actions/checkout@v4 + - name: setup + run: | + sudo apt-get update + sudo apt-get install libgtk-3-dev ffmpeg libavcodec-dev libavformat-dev libavutil-dev \ + libswscale-dev libgflags-dev \ - name: setup-opencv-source run: | git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} @@ -120,7 +94,7 @@ jobs: run: | cd ${{ env.SOURCE_DIR }} mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} `cat ../../options.txt` -DBUILD_opencv_world=OFF .. + cmake ${{ env.COMMON_CMAKE_OPTIONS }} `cat ../../options.txt` .. cmake --build . -j $(nproc) cmake --build . --target install - name: package diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index e7d65dc..a5af99d 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -47,8 +47,8 @@ jobs: mkdir build && cd build cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=OFF -DCV_ENABLE_INTRINSICS=OFF -DBUILD_WASM_INTRIN_TESTS=OFF \ - -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0" \ - -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0" \ + -DCMAKE_C_FLAGS="-s WASM=1 -s USE_PTHREADS=0" \ + -DCMAKE_CXX_FLAGS="-s WASM=1 -s USE_PTHREADS=0" \ `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. cmake --build . -j $(nproc) cmake --build . --target install @@ -59,8 +59,8 @@ jobs: mkdir build-simd && cd build-simd cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=OFF -DCV_ENABLE_INTRINSICS=ON -DBUILD_WASM_INTRIN_TESTS=OFF \ - -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0 -msimd128" \ - -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0 -msimd128" \ + -DCMAKE_C_FLAGS="-s WASM=1 -s USE_PTHREADS=0 -msimd128" \ + -DCMAKE_CXX_FLAGS="-s WASM=1 -s USE_PTHREADS=0 -msimd128" \ `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. cmake --build . -j $(nproc) cmake --build . --target install @@ -72,8 +72,8 @@ jobs: mkdir build-threads && cd build-threads cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=ON -DCV_ENABLE_INTRINSICS=OFF -DBUILD_WASM_INTRIN_TESTS=OFF \ - -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ - -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ + -DCMAKE_C_FLAGS="-s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ + -DCMAKE_CXX_FLAGS="-s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. cmake --build . -j $(nproc) cmake --build . --target install @@ -84,8 +84,8 @@ jobs: mkdir build-simd-threads && cd build-simd-threads cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=ON -DCV_ENABLE_INTRINSICS=ON -DBUILD_WASM_INTRIN_TESTS=OFF \ - -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ - -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ + -DCMAKE_C_FLAGS="-s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ + -DCMAKE_CXX_FLAGS="-s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. cmake --build . -j $(nproc) cmake --build . --target install @@ -107,8 +107,8 @@ jobs: cd test mkdir build && cd build cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0" \ - -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0" \ + -DCMAKE_C_FLAGS="-s WASM=1 -s USE_PTHREADS=0" \ + -DCMAKE_CXX_FLAGS="-s WASM=1 -s USE_PTHREADS=0" \ -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/basic/${{ env.OPENCV_SUBDIR }} .. cmake --build . -j $(nproc) - name: test-simd @@ -116,8 +116,8 @@ jobs: cd test mkdir build-simd && cd build-simd cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0 -msimd128" \ - -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=0 -msimd128" \ + -DCMAKE_C_FLAGS="-s WASM=1 -s USE_PTHREADS=0 -msimd128" \ + -DCMAKE_CXX_FLAGS="-s WASM=1 -s USE_PTHREADS=0 -msimd128" \ -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/simd/${{ env.OPENCV_SUBDIR }} .. cmake --build . -j $(nproc) - name: test-threads @@ -125,8 +125,8 @@ jobs: cd test mkdir build-threads && cd build-threads cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ - -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ + -DCMAKE_C_FLAGS="-s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ + -DCMAKE_CXX_FLAGS="-s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/threads/${{ env.OPENCV_SUBDIR }} .. cmake --build . -j $(nproc) - name: test-simd-threads @@ -134,8 +134,8 @@ jobs: cd test mkdir build-simd-threads && cd build-simd-threads cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ - -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ + -DCMAKE_C_FLAGS="-s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ + -DCMAKE_CXX_FLAGS="-s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/simd-threads/${{ env.OPENCV_SUBDIR }} .. cmake --build . -j $(nproc) - name: upload diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index fabf75f..71bbc38 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -30,13 +30,6 @@ jobs: git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $env:GITHUB_ENV echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-windows-${{ matrix.os-compiler.msvc-version }}" >> $env:GITHUB_ENV - - name: build-x86 - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-x86; cd build-x86 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A Win32 $(type ../../options.txt) -DBUILD_opencv_world=OFF .. - cmake --build . --config Release -j 4 - cmake --build . --config Release --target install - name: build-x64 run: | cd ${{ env.SOURCE_DIR }} @@ -44,14 +37,6 @@ jobs: cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A x64 $(type ../../options.txt) -DBUILD_opencv_world=OFF .. cmake --build . --config Release -j 4 cmake --build . --config Release --target install - - name: build-arm - if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-arm; cd build-arm - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A arm -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=ARM $(type ../../options.txt) -DBUILD_opencv_world=OFF .. - cmake --build . --config Release -j 4 - cmake --build . --config Release --target install - name: build-arm64 if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' run: | @@ -64,43 +49,24 @@ jobs: if: matrix.os-compiler.msvc-version == 'vs2015' || matrix.os-compiler.msvc-version == 'vs2017' run: | mkdir ${{ env.PACKAGE_NAME }} - mkdir ${{ env.PACKAGE_NAME }}/x86 mkdir ${{ env.PACKAGE_NAME }}/x64 - Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-x86\install\*" -Destination "${{ env.PACKAGE_NAME }}\x86" Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-x64\install\*" -Destination "${{ env.PACKAGE_NAME }}\x64" 7z a -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} - name: package if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' run: | mkdir ${{ env.PACKAGE_NAME }} - mkdir ${{ env.PACKAGE_NAME }}/x86 mkdir ${{ env.PACKAGE_NAME }}/x64 - mkdir ${{ env.PACKAGE_NAME }}/arm mkdir ${{ env.PACKAGE_NAME }}/arm64 - Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-x86\install\*" -Destination "${{ env.PACKAGE_NAME }}\x86" Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-x64\install\*" -Destination "${{ env.PACKAGE_NAME }}\x64" - Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-arm\install\*" -Destination "${{ env.PACKAGE_NAME }}\arm" Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-arm64\install\*" -Destination "${{ env.PACKAGE_NAME }}\arm64" 7z a -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} - - name: test-x86 - run: | - cd test - mkdir build-x86; cd build-x86 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A Win32 -DOpenCV_DIR="$env:GITHUB_WORKSPACE\${{ env.PACKAGE_NAME }}\x86" -DOpenCV_STATIC=ON .. - cmake --build . --config Release -j 4 - name: test-x64 run: | cd test mkdir build-x64; cd build-x64 cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A x64 -DOpenCV_DIR="$env:GITHUB_WORKSPACE\${{ env.PACKAGE_NAME }}\x64" -DOpenCV_STATIC=ON .. cmake --build . --config Release -j 4 - - name: test-arm - if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' - run: | - cd test - mkdir build-arm; cd build-arm - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A arm -DOpenCV_DIR="$env:GITHUB_WORKSPACE\${{ env.PACKAGE_NAME }}\arm" -DOpenCV_STATIC=ON .. - cmake --build . --config Release -j 4 - name: test-arm64 if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' run: | From 0dbddfe29ee310d7bf57d052e612b6424ba4d2ec Mon Sep 17 00:00:00 2001 From: rainy liu Date: Mon, 26 Aug 2024 18:41:17 +0800 Subject: [PATCH 07/41] fix --- .github/workflows/android.yml | 7 ++++--- .github/workflows/apple.yml | 15 +++++++++------ .github/workflows/linux.yml | 5 +++-- .github/workflows/wasm.yml | 6 ++++-- .github/workflows/windows.yml | 5 +++-- test/CMakeLists.txt | 2 ++ toolchains/ios.toolchain.cmake | 20 +++++++++++++++----- 7 files changed, 40 insertions(+), 20 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index f602b1c..d803c09 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -24,6 +24,7 @@ jobs: -DANDROID_PLATFORM=android-24 \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ + -DANDROID_STL=c++_static \ -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ steps: - uses: actions/checkout@v4 @@ -62,7 +63,6 @@ jobs: - name: package run: | mkdir ${{ env.PACKAGE_NAME }} - cp -rf ${{ env.SOURCE_DIR }}/build-x86/install/* ${{ env.PACKAGE_NAME }}/ cp -rf ${{ env.SOURCE_DIR }}/build-x86_64/install/* ${{ env.PACKAGE_NAME }}/ cp -rf ${{ env.SOURCE_DIR }}/build-armeabi-v7a/install/* ${{ env.PACKAGE_NAME }}/ cp -rf ${{ env.SOURCE_DIR }}/build-arm64-v8a/install/* ${{ env.PACKAGE_NAME }}/ @@ -107,8 +107,9 @@ jobs: - name: create-release uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') with: + draft: true + prerelease: false token: ${{ secrets.GITHUB_TOKEN }} - tag_name: ${{ needs.setup.outputs.VERSION }} - name: Release ${{ needs.setup.outputs.VERSION }} files: artifacts/*/*.zip diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml index e292ea0..9e41736 100644 --- a/.github/workflows/apple.yml +++ b/.github/workflows/apple.yml @@ -28,7 +28,7 @@ jobs: env: COMMON_CMAKE_OPTIONS: | -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ - -DPLATFORM=OS64 \ + -DPLATFORM=OS64COMBINED \ -DDEPLOYMENT_TARGET=$IOS_DEPLOYMENT_TARGET \ -DENABLE_BITCODE=$ENABLE_BITCODE \ -DENABLE_ARC=$ENABLE_ARC \ @@ -48,8 +48,9 @@ jobs: run: | cd ${{ env.SOURCE_DIR }} mkdir build-arm64 && cd build-arm64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="arm64" \ - `cat ../../options.txt` -DBUILD_opencv_world=ON -DWITH_OPENCL=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + `cat ../../options.txt` -DBUILD_opencv_world=ON \ + -DWITH_OPENCL=OFF -DWITH_OPENCL_SVM=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. # workaround ar @list issue on macos cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } cmake --build . --target install @@ -121,7 +122,8 @@ jobs: cd ${{ env.SOURCE_DIR }} mkdir build-arm64 && cd build-arm64 cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="arm64" \ - `cat ../../options.txt` -DBUILD_opencv_world=ON -DWITH_OPENCL=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + `cat ../../options.txt` -DBUILD_opencv_world=ON \ + -DWITH_OPENCL=OFF -DWITH_OPENCL_SVM=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. # workaround ar @list issue on macos cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } cmake --build . --target install @@ -296,8 +298,9 @@ jobs: - name: create-release uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') with: + draft: true + prerelease: false token: ${{ secrets.GITHUB_TOKEN }} - tag_name: ${{ needs.setup.outputs.VERSION }} - name: Release ${{ needs.setup.outputs.VERSION }} files: artifacts/*/*.zip diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index d2613fb..078df26 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -132,8 +132,9 @@ jobs: - name: create-release uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') with: + draft: true + prerelease: false token: ${{ secrets.GITHUB_TOKEN }} - tag_name: ${{ needs.setup.outputs.VERSION }} - name: Release ${{ needs.setup.outputs.VERSION }} files: artifacts/*/*.zip diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index a5af99d..f3cbf0a 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -24,6 +24,7 @@ jobs: -DCMAKE_TOOLCHAIN_FILE=../emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ + -DWITH_VULKAN=OFF \ -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ steps: - uses: actions/checkout@v4 @@ -157,8 +158,9 @@ jobs: - name: create-release uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') with: + draft: true + prerelease: false token: ${{ secrets.GITHUB_TOKEN }} - tag_name: ${{ needs.setup.outputs.VERSION }} - name: Release ${{ needs.setup.outputs.VERSION }} files: artifacts/*/*.zip diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 71bbc38..c130718 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -93,8 +93,9 @@ jobs: - name: create-release uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') with: + draft: true + prerelease: false token: ${{ secrets.GITHUB_TOKEN }} - tag_name: ${{ needs.setup.outputs.VERSION }} - name: Release ${{ needs.setup.outputs.VERSION }} files: artifacts/*/*.zip diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e6aae79..58c3904 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,6 +4,8 @@ cmake_minimum_required(VERSION 3.5) # opencv4 requires c++11 set(CMAKE_CXX_STANDARD 11) +set(OpenCV_STATIC ON) + if(LINUX OR APPLE) find_package(Iconv REQUIRED) endif() diff --git a/toolchains/ios.toolchain.cmake b/toolchains/ios.toolchain.cmake index db2a327..a235cd0 100644 --- a/toolchains/ios.toolchain.cmake +++ b/toolchains/ios.toolchain.cmake @@ -81,6 +81,7 @@ # Note: The build argument "MACOSX_DEPLOYMENT_TARGET" can be used to control min-version of macOS # MAC_CATALYST_ARM64 = Build for Apple Silicon macOS with Catalyst support (iOS toolchain on macOS). # Note: The build argument "MACOSX_DEPLOYMENT_TARGET" can be used to control min-version of macOS +# MAC_CATALYST_UNIVERSAL = Combined build for x86_64 and Apple Silicon on Catalyst. # # CMAKE_OSX_SYSROOT: Path to the SDK to use. By default this is # automatically determined from PLATFORM and xcodebuild, but @@ -123,6 +124,7 @@ # MAC_UNIVERSAL = x86_64 arm64 # MAC_CATALYST = x86_64 # MAC_CATALYST_ARM64 = arm64 +# MAC_CATALYST_UNIVERSAL = x86_64 arm64 # # NOTE: When manually specifying ARCHS, put a semi-colon between the entries. E.g., -DARCHS="armv7;arm64" # @@ -154,7 +156,8 @@ cmake_minimum_required(VERSION 3.8.0) # CMake invokes the toolchain file twice during the first build, but only once during subsequent rebuilds. -if(DEFINED ENV{_IOS_TOOLCHAIN_HAS_RUN}) +# NOTE: To improve single-library build-times, provide the flag "OS_SINGLE_BUILD" as a build argument. +if(DEFINED OS_SINGLE_BUILD AND DEFINED ENV{_IOS_TOOLCHAIN_HAS_RUN}) return() endif() set(ENV{_IOS_TOOLCHAIN_HAS_RUN} true) @@ -166,7 +169,7 @@ list(APPEND _supported_platforms "WATCHOS" "WATCHOSCOMBINED" "SIMULATOR_WATCHOS" "SIMULATORARM64_WATCHOS" "MAC" "MAC_ARM64" "MAC_UNIVERSAL" "VISIONOS" "SIMULATOR_VISIONOS" "VISIONOSCOMBINED" - "MAC_CATALYST" "MAC_CATALYST_ARM64") + "MAC_CATALYST" "MAC_CATALYST_ARM64" "MAC_CATALYST_UNIVERSAL") # Cache what generator is used set(USED_CMAKE_GENERATOR "${CMAKE_GENERATOR}") @@ -230,7 +233,7 @@ if("${contains_PLATFORM}" EQUAL "-1") endif() # Check if Apple Silicon is supported -if(PLATFORM MATCHES "^(MAC_ARM64)$|^(MAC_CATALYST_ARM64)$|^(MAC_UNIVERSAL)$" AND ${CMAKE_VERSION} VERSION_LESS "3.19.5") +if(PLATFORM MATCHES "^(MAC_ARM64)$|^(MAC_CATALYST_ARM64)$|^(MAC_UNIVERSAL)$|^(MAC_CATALYST_UNIVERSAL)$" AND ${CMAKE_VERSION} VERSION_LESS "3.19.5") message(FATAL_ERROR "Apple Silicon builds requires a minimum of CMake 3.19.5") endif() @@ -275,7 +278,7 @@ if(NOT DEFINED DEPLOYMENT_TARGET) elseif(PLATFORM STREQUAL "MAC_UNIVERSAL") # Unless specified, SDK version 11.0 (Big Sur) is used by default as minimum target version for universal builds. set(DEPLOYMENT_TARGET "11.0") - elseif(PLATFORM STREQUAL "MAC_CATALYST" OR PLATFORM STREQUAL "MAC_CATALYST_ARM64") + elseif(PLATFORM STREQUAL "MAC_CATALYST" OR PLATFORM STREQUAL "MAC_CATALYST_ARM64" OR PLATFORM STREQUAL "MAC_CATALYST_UNIVERSAL") # Unless specified, SDK version 13.0 is used by default as the minimum target version (mac catalyst minimum requirement). set(DEPLOYMENT_TARGET "13.1") else() @@ -553,6 +556,13 @@ elseif(PLATFORM_INT STREQUAL "MAC_UNIVERSAL") endif() string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}") set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-macosx${DEPLOYMENT_TARGET}) +elseif(PLATFORM_INT STREQUAL "MAC_CATALYST_UNIVERSAL") + set(SDK_NAME macosx) + if(NOT ARCHS) + set(ARCHS "x86_64;arm64") + endif() + string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}") + set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-macabi) else() message(FATAL_ERROR "Invalid PLATFORM: ${PLATFORM_INT}") endif() @@ -761,7 +771,7 @@ set(APPLE ON CACHE BOOL "") if(PLATFORM STREQUAL "MAC" OR PLATFORM STREQUAL "MAC_ARM64" OR PLATFORM STREQUAL "MAC_UNIVERSAL") set(IOS OFF CACHE BOOL "") set(MACOS ON CACHE BOOL "") -elseif(PLATFORM STREQUAL "MAC_CATALYST" OR PLATFORM STREQUAL "MAC_CATALYST_ARM64") +elseif(PLATFORM STREQUAL "MAC_CATALYST" OR PLATFORM STREQUAL "MAC_CATALYST_ARM64" OR PLATFORM STREQUAL "MAC_CATALYST_UNIVERSAL") set(IOS ON CACHE BOOL "") set(MACOS ON CACHE BOOL "") elseif(PLATFORM STREQUAL "VISIONOS" OR PLATFORM STREQUAL "SIMULATOR_VISIONOS" OR PLATFORM STREQUAL "VISIONOSCOMBINED") From 549dac301a1f4e5c1fc7913f8094cd45b264a0f5 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Mon, 26 Aug 2024 20:33:44 +0800 Subject: [PATCH 08/41] fix --- .github/workflows/apple.yml | 246 +++++++++++++----------------------- .github/workflows/wasm.yml | 13 +- test/CMakeLists.txt | 9 +- 3 files changed, 104 insertions(+), 164 deletions(-) diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml index 9e41736..b6d53e4 100644 --- a/.github/workflows/apple.yml +++ b/.github/workflows/apple.yml @@ -28,54 +28,39 @@ jobs: env: COMMON_CMAKE_OPTIONS: | -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ - -DPLATFORM=OS64COMBINED \ -DDEPLOYMENT_TARGET=$IOS_DEPLOYMENT_TARGET \ -DENABLE_BITCODE=$ENABLE_BITCODE \ -DENABLE_ARC=$ENABLE_ARC \ -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ + -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib/modules" \ steps: - uses: actions/checkout@v4 - name: setup-opencv-source run: | - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} - echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-ios" >> $GITHUB_ENV + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib + echo "SOURCE_DIR=opencv" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-ios" >> $GITHUB_ENV - name: build-arm64 run: | cd ${{ env.SOURCE_DIR }} mkdir build-arm64 && cd build-arm64 cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - `cat ../../options.txt` -DBUILD_opencv_world=ON \ - -DWITH_OPENCL=OFF -DWITH_OPENCL_SVM=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. - # workaround ar @list issue on macos - cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } + `cat ../../options.txt` -DPLATFORM=OS64 \ + -DWITH_OPENCL=OFF -DWITH_OPENCL_SVM=OFF .. + cmake --build . -j 4 cmake --build . --target install - name: package run: | - rm -rf opencv2.framework - mkdir -p opencv2.framework/Versions/A/Headers - mkdir -p opencv2.framework/Versions/A/Resources - ln -s A opencv2.framework/Versions/Current - ln -s Versions/Current/Headers opencv2.framework/Headers - ln -s Versions/Current/Resources opencv2.framework/Resources - ln -s Versions/Current/opencv2 opencv2.framework/opencv2 - lipo -create \ - ${{ env.SOURCE_DIR }}/build-arm64/install/lib/libopencv_world.a \ - -o opencv2.framework/Versions/A/opencv2 - cp -r ${{ env.SOURCE_DIR }}/build-arm64/install/include/opencv4/opencv2/* opencv2.framework/Versions/A/Headers/ || : - cp -r ${{ env.SOURCE_DIR }}/build-arm64/install/include/opencv2/* opencv2.framework/Versions/A/Headers/ || : - cp ${{ env.SOURCE_DIR }}/Info.plist opencv2.framework/Versions/A/Resources/ rm -f ${{ env.PACKAGE_NAME }}.zip - zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip opencv2.framework + zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip ${{ env.SOURCE_DIR }}/build-arm64/install/ - name: test run: | cd test mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="arm64" \ + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ -DOpenCV_DIR=$GITHUB_WORKSPACE .. cmake --build . -j 4 - name: upload-zip @@ -89,62 +74,39 @@ jobs: strategy: matrix: opencv-version: [4.10.0] + platform: [SIMULATOR64, SIMULATORARM64] env: COMMON_CMAKE_OPTIONS: | -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ - -DPLATFORM=SIMULATOR \ -DDEPLOYMENT_TARGET=$IOS_DEPLOYMENT_TARGET \ -DENABLE_BITCODE=$ENABLE_BITCODE \ -DENABLE_ARC=$ENABLE_ARC \ -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ + -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib/modules" \ steps: - uses: actions/checkout@v4 - name: setup-opencv-source run: | - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} - echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-ios-simulator" >> $GITHUB_ENV - - name: build-x86_64 - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-x86_64 && cd build-x86_64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="x86_64" \ - `cat ../../options.txt` -DBUILD_opencv_world=ON -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. - # workaround ar @list issue on macos - cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } - cmake --build . --target install - - name: build-arm64 + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib + echo "SOURCE_DIR=opencv" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-ios-${{ matrix.platform }}" >> $GITHUB_ENV + - name: build run: | cd ${{ env.SOURCE_DIR }} - mkdir build-arm64 && cd build-arm64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="arm64" \ - `cat ../../options.txt` -DBUILD_opencv_world=ON \ - -DWITH_OPENCL=OFF -DWITH_OPENCL_SVM=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. - # workaround ar @list issue on macos - cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + `cat ../../options.txt` -DPLATFORM=${{ matrix.platform }} \ + -DWITH_OPENCL=OFF -DWITH_OPENCL_SVM=OFF \ + -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + cmake --build . -j 4 cmake --build . --target install - name: package run: | - rm -rf opencv2.framework - mkdir -p opencv2.framework/Versions/A/Headers - mkdir -p opencv2.framework/Versions/A/Resources - ln -s A opencv2.framework/Versions/Current - ln -s Versions/Current/Headers opencv2.framework/Headers - ln -s Versions/Current/Resources opencv2.framework/Resources - ln -s Versions/Current/opencv2 opencv2.framework/opencv2 - lipo -create \ - ${{ env.SOURCE_DIR }}/build-x86_64/install/lib/libopencv_world.a \ - ${{ env.SOURCE_DIR }}/build-arm64/install/lib/libopencv_world.a \ - -o opencv2.framework/Versions/A/opencv2 - cp -r ${{ env.SOURCE_DIR }}/build-x86_64/install/include/opencv4/opencv2/* opencv2.framework/Versions/A/Headers/ || : - cp -r ${{ env.SOURCE_DIR }}/build-x86_64/install/include/opencv2/* opencv2.framework/Versions/A/Headers/ || : - cp ${{ env.SOURCE_DIR }}/Info.plist opencv2.framework/Versions/A/Resources/ rm -f ${{ env.PACKAGE_NAME }}.zip - zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip opencv2.framework + zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip ${{ env.SOURCE_DIR }}/build/install/ - name: test run: | cd test @@ -159,10 +121,13 @@ jobs: path: ${{ env.PACKAGE_NAME }}.zip macos: - runs-on: macos-13 strategy: matrix: opencv-version: [4.10.0] + osname: + - {os: macos-13, name: x86_64, platform: MAC} + - {os: macos-14, name: arm64, platform: MAC_ARM64} + runs-on: ${{ matrix.osname.os }} env: COMMON_CMAKE_OPTIONS: | -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ @@ -172,63 +137,32 @@ jobs: -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ + -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib/modules" \ steps: - uses: actions/checkout@v4 - name: setup-opencv-source run: | - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} - echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-macos" >> $GITHUB_ENV - - name: build-x86_64 + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib + echo "SOURCE_DIR=opencv" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-${{ matrix.osname.platform }}" >> $GITHUB_ENV + - name: build run: | cd ${{ env.SOURCE_DIR }} - mkdir build-x86_64 && cd build-x86_64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=MAC -DARCHS="x86_64" \ - `cat ../../options.txt` -DBUILD_opencv_world=ON .. - # workaround ar @list issue on macos - cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } - cmake --build . --target install - - name: build-arm64 - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-arm64 && cd build-arm64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=MAC_ARM64 -DARCHS="arm64" \ - `cat ../../options.txt` -DBUILD_opencv_world=ON .. - # workaround ar @list issue on macos - cmake --build . -j 4 || { cd modules/world; $DEVELOPER_DIR/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc ../../lib/libopencv_world.a `cat world_objects.rsp` CMakeFiles/opencv_world.dir/src/world_init.cpp.o; cd ../..; } + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=${{ matrix.osname.platform }} \ + `cat ../../options.txt` .. + cmake --build . -j 4 cmake --build . --target install - name: package run: | - rm -rf opencv2.framework - mkdir -p opencv2.framework/Versions/A/Headers - mkdir -p opencv2.framework/Versions/A/Resources - ln -s A opencv2.framework/Versions/Current - ln -s Versions/Current/Headers opencv2.framework/Headers - ln -s Versions/Current/Resources opencv2.framework/Resources - ln -s Versions/Current/opencv2 opencv2.framework/opencv2 - lipo -create \ - ${{ env.SOURCE_DIR }}/build-x86_64/install/lib/libopencv_world.a \ - ${{ env.SOURCE_DIR }}/build-arm64/install/lib/libopencv_world.a \ - -o opencv2.framework/Versions/A/opencv2 - cp -r ${{ env.SOURCE_DIR }}/build-x86_64/install/include/opencv4/opencv2/* opencv2.framework/Versions/A/Headers/ || : - cp -r ${{ env.SOURCE_DIR }}/build-x86_64/install/include/opencv2/* opencv2.framework/Versions/A/Headers/ || : - cp ${{ env.SOURCE_DIR }}/Info.plist opencv2.framework/Versions/A/Resources/ rm -f ${{ env.PACKAGE_NAME }}.zip - zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip opencv2.framework - - name: test-x86_64 - run: | - cd test - mkdir build-x86_64 && cd build-x86_64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=MAC -DARCHS="x86_64" \ - -DOpenCV_DIR=$GITHUB_WORKSPACE .. - cmake --build . -j 4 - - name: test-arm64 + zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip ${{ env.SOURCE_DIR }}/build/install/ + - name: test run: | cd test - mkdir build-arm64 && cd build-arm64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=MAC_ARM64 -DARCHS="arm64" \ + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=${{ matrix.osname.platform }} \ -DOpenCV_DIR=$GITHUB_WORKSPACE .. cmake --build . -j 4 - name: upload-zip @@ -237,58 +171,58 @@ jobs: name: ${{ env.PACKAGE_NAME }} path: ${{ env.PACKAGE_NAME }}.zip - apple: - needs: [macos, ios, ios-simulator] - runs-on: macos-13 - strategy: - matrix: - opencv-version: [4.10.0] - steps: - - run: sudo xcode-select --switch /Applications/Xcode_15.2.app - - uses: actions/checkout@v4 - - name: setup-opencv-package - run: | - echo "MACOS_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-macos" >> $GITHUB_ENV - echo "IOS_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-ios" >> $GITHUB_ENV - echo "IOS_SIMULATOR_PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-ios-simulator" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-apple" >> $GITHUB_ENV - - name: download-macos-package - uses: actions/download-artifact@v4 - with: - name: ${{ env.MACOS_PACKAGE_NAME }} - - name: download-ios-package - uses: actions/download-artifact@v4 - with: - name: ${{ env.IOS_PACKAGE_NAME }} - - name: download-ios-simulator-package - uses: actions/download-artifact@v4 - with: - name: ${{ env.IOS_SIMULATOR_PACKAGE_NAME }} - - name: create-xcframwork - run: | - mkdir -p ${{ env.MACOS_PACKAGE_NAME }} - mkdir -p ${{ env.IOS_PACKAGE_NAME }} - mkdir -p ${{ env.IOS_SIMULATOR_PACKAGE_NAME }} - unzip -q ${{ env.MACOS_PACKAGE_NAME }}.zip -d ${{ env.MACOS_PACKAGE_NAME }} - unzip -q ${{ env.IOS_PACKAGE_NAME }}.zip -d ${{ env.IOS_PACKAGE_NAME }} - unzip -q ${{ env.IOS_SIMULATOR_PACKAGE_NAME }}.zip -d ${{ env.IOS_SIMULATOR_PACKAGE_NAME }} - xcodebuild -create-xcframework \ - -framework ${{ env.MACOS_PACKAGE_NAME }}/opencv2.framework \ - -framework ${{ env.IOS_PACKAGE_NAME }}/opencv2.framework \ - -framework ${{ env.IOS_SIMULATOR_PACKAGE_NAME }}/opencv2.framework \ - -output opencv2.xcframework - rm -f ${{ env.PACKAGE_NAME }}.zip - zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip opencv2.xcframework - - name: upload-zip - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PACKAGE_NAME }} - path: ${{ env.PACKAGE_NAME }}.zip + # apple: + # needs: [macos, ios, ios-simulator] + # runs-on: macos-13 + # strategy: + # matrix: + # opencv-version: [4.10.0] + # steps: + # - run: sudo xcode-select --switch /Applications/Xcode_15.2.app + # - uses: actions/checkout@v4 + # - name: setup-opencv-package + # run: | + # echo "MACOS_PACKAGE_NAME=opencv-macos" >> $GITHUB_ENV + # echo "IOS_PACKAGE_NAME=opencv-ios" >> $GITHUB_ENV + # echo "IOS_SIMULATOR_PACKAGE_NAME=opencv-ios-simulator" >> $GITHUB_ENV + # echo "PACKAGE_NAME=opencv-apple" >> $GITHUB_ENV + # - name: download-macos-package + # uses: actions/download-artifact@v4 + # with: + # name: ${{ env.MACOS_PACKAGE_NAME }} + # - name: download-ios-package + # uses: actions/download-artifact@v4 + # with: + # name: ${{ env.IOS_PACKAGE_NAME }} + # - name: download-ios-simulator-package + # uses: actions/download-artifact@v4 + # with: + # name: ${{ env.IOS_SIMULATOR_PACKAGE_NAME }} + # - name: create-xcframwork + # run: | + # mkdir -p ${{ env.MACOS_PACKAGE_NAME }} + # mkdir -p ${{ env.IOS_PACKAGE_NAME }} + # mkdir -p ${{ env.IOS_SIMULATOR_PACKAGE_NAME }} + # unzip -q ${{ env.MACOS_PACKAGE_NAME }}.zip -d ${{ env.MACOS_PACKAGE_NAME }} + # unzip -q ${{ env.IOS_PACKAGE_NAME }}.zip -d ${{ env.IOS_PACKAGE_NAME }} + # unzip -q ${{ env.IOS_SIMULATOR_PACKAGE_NAME }}.zip -d ${{ env.IOS_SIMULATOR_PACKAGE_NAME }} + # xcodebuild -create-xcframework \ + # -framework ${{ env.MACOS_PACKAGE_NAME }}/opencv2.framework \ + # -framework ${{ env.IOS_PACKAGE_NAME }}/opencv2.framework \ + # -framework ${{ env.IOS_SIMULATOR_PACKAGE_NAME }}/opencv2.framework \ + # -output opencv2.xcframework + # rm -f ${{ env.PACKAGE_NAME }}.zip + # zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip opencv2.xcframework + # - name: upload-zip + # uses: actions/upload-artifact@v4 + # with: + # name: ${{ env.PACKAGE_NAME }} + # path: ${{ env.PACKAGE_NAME }}.zip release: permissions: contents: write # for softprops/action-gh-release to create a release - needs: [ios, ios-simulator, macos, apple] + needs: [ios, ios-simulator, macos] runs-on: ubuntu-latest steps: - name: download diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index f3cbf0a..b3fcb37 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -24,7 +24,6 @@ jobs: -DCMAKE_TOOLCHAIN_FILE=../emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ - -DWITH_VULKAN=OFF \ -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ steps: - uses: actions/checkout@v4 @@ -50,7 +49,8 @@ jobs: -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=OFF -DCV_ENABLE_INTRINSICS=OFF -DBUILD_WASM_INTRIN_TESTS=OFF \ -DCMAKE_C_FLAGS="-s WASM=1 -s USE_PTHREADS=0" \ -DCMAKE_CXX_FLAGS="-s WASM=1 -s USE_PTHREADS=0" \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DWITH_VULKAN=OFF \ + -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. cmake --build . -j $(nproc) cmake --build . --target install - name: build-simd @@ -62,7 +62,8 @@ jobs: -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=OFF -DCV_ENABLE_INTRINSICS=ON -DBUILD_WASM_INTRIN_TESTS=OFF \ -DCMAKE_C_FLAGS="-s WASM=1 -s USE_PTHREADS=0 -msimd128" \ -DCMAKE_CXX_FLAGS="-s WASM=1 -s USE_PTHREADS=0 -msimd128" \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DWITH_VULKAN=OFF \ + -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. cmake --build . -j $(nproc) cmake --build . --target install - name: build-threads @@ -75,7 +76,8 @@ jobs: -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=ON -DCV_ENABLE_INTRINSICS=OFF -DBUILD_WASM_INTRIN_TESTS=OFF \ -DCMAKE_C_FLAGS="-s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ -DCMAKE_CXX_FLAGS="-s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DWITH_VULKAN=OFF \ + -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. cmake --build . -j $(nproc) cmake --build . --target install - name: build-simd-threads @@ -87,7 +89,8 @@ jobs: -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=ON -DCV_ENABLE_INTRINSICS=ON -DBUILD_WASM_INTRIN_TESTS=OFF \ -DCMAKE_C_FLAGS="-s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ -DCMAKE_CXX_FLAGS="-s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + `cat ../../options.txt` -DBUILD_opencv_world=OFF -DWITH_VULKAN=OFF \ + -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. cmake --build . -j $(nproc) cmake --build . --target install - name: package diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 58c3904..5b5e8fa 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,11 +1,13 @@ project(opencv-mobile-test) cmake_minimum_required(VERSION 3.5) +if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_options(/MT) +endif() + # opencv4 requires c++11 set(CMAKE_CXX_STANDARD 11) -set(OpenCV_STATIC ON) - if(LINUX OR APPLE) find_package(Iconv REQUIRED) endif() @@ -19,5 +21,6 @@ else() endif() add_executable(opencv-mobile-test main.cpp) +target_include_directories(opencv-mobile-test PRIVATE ${OpenCV_INCLUDE_DIRS}) -target_link_libraries(opencv-mobile-test ${OpenCV_LIBS}) +target_link_libraries(opencv-mobile-test opencv_highgui opencv_core opencv_imgproc) From 4a536bb2d801ab327c46992156593c802b8d2ebb Mon Sep 17 00:00:00 2001 From: rainyl Date: Mon, 26 Aug 2024 22:40:52 +0800 Subject: [PATCH 09/41] fix ios --- .github/workflows/apple.yml | 13 ++++++++----- .github/workflows/wasm.yml | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml index b6d53e4..585d480 100644 --- a/.github/workflows/apple.yml +++ b/.github/workflows/apple.yml @@ -43,6 +43,7 @@ jobs: git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib echo "SOURCE_DIR=opencv" >> $GITHUB_ENV echo "PACKAGE_NAME=opencv-ios" >> $GITHUB_ENV + echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV - name: build-arm64 run: | cd ${{ env.SOURCE_DIR }} @@ -60,8 +61,8 @@ jobs: run: | cd test mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - -DOpenCV_DIR=$GITHUB_WORKSPACE .. + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=OS64 \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.SOURCE_DIR }}/build/install/${{ env.OPENCV_SUBDIR }} .. cmake --build . -j 4 - name: upload-zip uses: actions/upload-artifact@v4 @@ -93,6 +94,7 @@ jobs: git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib echo "SOURCE_DIR=opencv" >> $GITHUB_ENV echo "PACKAGE_NAME=opencv-ios-${{ matrix.platform }}" >> $GITHUB_ENV + echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV - name: build run: | cd ${{ env.SOURCE_DIR }} @@ -111,8 +113,8 @@ jobs: run: | cd test mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DARCHS="x86_64;arm64" \ - -DOpenCV_DIR=$GITHUB_WORKSPACE .. + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=${{ matrix.platform }} \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.SOURCE_DIR }}/build/install/${{ env.OPENCV_SUBDIR }} .. cmake --build . -j 4 - name: upload-zip uses: actions/upload-artifact@v4 @@ -146,6 +148,7 @@ jobs: git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib echo "SOURCE_DIR=opencv" >> $GITHUB_ENV echo "PACKAGE_NAME=opencv-${{ matrix.osname.platform }}" >> $GITHUB_ENV + echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV - name: build run: | cd ${{ env.SOURCE_DIR }} @@ -163,7 +166,7 @@ jobs: cd test mkdir build && cd build cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=${{ matrix.osname.platform }} \ - -DOpenCV_DIR=$GITHUB_WORKSPACE .. + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.SOURCE_DIR }}/build/install/${{ env.OPENCV_SUBDIR }} .. cmake --build . -j 4 - name: upload-zip uses: actions/upload-artifact@v4 diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index b3fcb37..a75c2fe 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -43,7 +43,7 @@ jobs: run: | source emsdk/emsdk_env.sh cd ${{ env.SOURCE_DIR }} - patch -p1 -i ../patches/opencv-${{ matrix.opencv-version }}-unsafe-xadd.patch + # patch -p1 -i ../patches/opencv-${{ matrix.opencv-version }}-unsafe-xadd.patch mkdir build && cd build cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=OFF -DCV_ENABLE_INTRINSICS=OFF -DBUILD_WASM_INTRIN_TESTS=OFF \ @@ -70,7 +70,7 @@ jobs: run: | source emsdk/emsdk_env.sh cd ${{ env.SOURCE_DIR }} - patch -p1 -R -i ../patches/opencv-${{ matrix.opencv-version }}-unsafe-xadd.patch + # patch -p1 -R -i ../patches/opencv-${{ matrix.opencv-version }}-unsafe-xadd.patch mkdir build-threads && cd build-threads cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=ON -DCV_ENABLE_INTRINSICS=OFF -DBUILD_WASM_INTRIN_TESTS=OFF \ From 0e92261276512b000c5f0b59a14eaede4c077d9b Mon Sep 17 00:00:00 2001 From: rainyl Date: Mon, 26 Aug 2024 23:47:39 +0800 Subject: [PATCH 10/41] fix --- .github/workflows/android.yml | 5 ++--- .github/workflows/apple.yml | 6 +++--- .github/workflows/linux.yml | 5 ++--- .github/workflows/windows.yml | 5 ++--- options.txt | 2 +- test/CMakeLists.txt | 8 +------- 6 files changed, 11 insertions(+), 20 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index d803c09..5ca83c6 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -1,11 +1,10 @@ name: android -# on: pull_request on: push: tags: - '*' - pull_request: - branches: ["main"] + # pull_request: + # branches: ["main"] permissions: contents: read diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml index 585d480..00f5bfb 100644 --- a/.github/workflows/apple.yml +++ b/.github/workflows/apple.yml @@ -127,8 +127,8 @@ jobs: matrix: opencv-version: [4.10.0] osname: - - {os: macos-13, name: x86_64, platform: MAC} - - {os: macos-14, name: arm64, platform: MAC_ARM64} + - {os: macos-13, arch: x86_64, platform: MAC} + - {os: macos-14, arch: arm64, platform: MAC_ARM64} runs-on: ${{ matrix.osname.os }} env: COMMON_CMAKE_OPTIONS: | @@ -147,7 +147,7 @@ jobs: git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib echo "SOURCE_DIR=opencv" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-${{ matrix.osname.platform }}" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-${{ matrix.osname.arch }}" >> $GITHUB_ENV echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV - name: build run: | diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 078df26..4bb4f5f 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -1,11 +1,10 @@ name: linux -# on: pull_request on: push: tags: - '*' - pull_request: - branches: ["main"] + # pull_request: + # branches: ["main"] permissions: contents: read diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index c130718..0d8057b 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -1,11 +1,10 @@ name: windows -# on: pull_request on: push: tags: - '*' - pull_request: - branches: ["main"] + # pull_request: + # branches: ["main"] permissions: contents: read diff --git a/options.txt b/options.txt index d889c9c..879d403 100644 --- a/options.txt +++ b/options.txt @@ -30,7 +30,7 @@ -DWITH_PTHREADS_PF=OFF -DWITH_CLP=OFF -DWITH_OPENCL=ON --DWITH_OPENCL_SVM=ON +-DWITH_OPENCL_SVM=OFF -DWITH_VA=OFF -DWITH_VA_INTEL=OFF -DWITH_ITT=OFF diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5b5e8fa..a52aafc 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -12,13 +12,7 @@ if(LINUX OR APPLE) find_package(Iconv REQUIRED) endif() -if(APPLE OR IOS) - # set OpenCV_DIR to where opencv2.framework resides - find_library(OpenCV_LIBS NAMES opencv2 PATHS ${OpenCV_DIR}) -else() - # set OpenCV_DIR to where OpenCVConfig.cmake resides - find_package(OpenCV REQUIRED) -endif() +find_package(OpenCV REQUIRED) add_executable(opencv-mobile-test main.cpp) target_include_directories(opencv-mobile-test PRIVATE ${OpenCV_INCLUDE_DIRS}) From 5f877e2ebe2cf88836d552d95a97dc2a737cf4bd Mon Sep 17 00:00:00 2001 From: rainyl Date: Tue, 27 Aug 2024 00:21:27 +0800 Subject: [PATCH 11/41] fix --- .github/workflows/android.yml | 2 +- .github/workflows/apple.yml | 73 +- .github/workflows/build_test_release.yaml | 243 ---- .github/workflows/linux.yml | 5 +- .github/workflows/wasm.yml | 8 +- .github/workflows/windows.yml | 2 +- conanfile.py | 467 ------- profiles/android-armv7 | 13 - profiles/android-armv8 | 13 - profiles/android-x86_64 | 13 - .../test_package/CMakeUserPresets.json | 9 - profiles/ios-armv8 | 13 - profiles/ios-x86_64 | 13 - profiles/ios.toolchain.cmake | 1135 ----------------- 14 files changed, 21 insertions(+), 1988 deletions(-) delete mode 100644 .github/workflows/build_test_release.yaml delete mode 100644 conanfile.py delete mode 100644 profiles/android-armv7 delete mode 100644 profiles/android-armv8 delete mode 100644 profiles/android-x86_64 delete mode 100644 profiles/arm-toolchain/test_package/CMakeUserPresets.json delete mode 100644 profiles/ios-armv8 delete mode 100644 profiles/ios-x86_64 delete mode 100644 profiles/ios.toolchain.cmake diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 5ca83c6..72e7384 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -34,7 +34,7 @@ jobs: git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-android" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-android" >> $GITHUB_ENV - name: build-armeabi-v7a run: | cd ${{ env.SOURCE_DIR }} diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml index 00f5bfb..ad2c3dd 100644 --- a/.github/workflows/apple.yml +++ b/.github/workflows/apple.yml @@ -14,7 +14,6 @@ env: ENABLE_BITCODE: OFF ENABLE_ARC: OFF ENABLE_VISIBILITY: OFF - EMSCRIPTEN_VERSION: 3.1.28 permissions: contents: read @@ -42,12 +41,12 @@ jobs: git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib echo "SOURCE_DIR=opencv" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-ios" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-ios-arm64" >> $GITHUB_ENV echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV - - name: build-arm64 + - name: build run: | cd ${{ env.SOURCE_DIR }} - mkdir build-arm64 && cd build-arm64 + mkdir build && cd build cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ `cat ../../options.txt` -DPLATFORM=OS64 \ -DWITH_OPENCL=OFF -DWITH_OPENCL_SVM=OFF .. @@ -56,7 +55,7 @@ jobs: - name: package run: | rm -f ${{ env.PACKAGE_NAME }}.zip - zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip ${{ env.SOURCE_DIR }}/build-arm64/install/ + zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip ${{ env.SOURCE_DIR }}/build/install/ - name: test run: | cd test @@ -75,7 +74,9 @@ jobs: strategy: matrix: opencv-version: [4.10.0] - platform: [SIMULATOR64, SIMULATORARM64] + platform: + - {arch: x64, name: SIMULATOR64} + - {arch: arm64, name: SIMULATORARM64} env: COMMON_CMAKE_OPTIONS: | -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ @@ -93,14 +94,14 @@ jobs: git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib echo "SOURCE_DIR=opencv" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-ios-${{ matrix.platform }}" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-ios-simulator-${{ matrix.platform.arch }}" >> $GITHUB_ENV echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV - name: build run: | cd ${{ env.SOURCE_DIR }} mkdir build && cd build cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - `cat ../../options.txt` -DPLATFORM=${{ matrix.platform }} \ + `cat ../../options.txt` -DPLATFORM=${{ matrix.platform.name }} \ -DWITH_OPENCL=OFF -DWITH_OPENCL_SVM=OFF \ -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. cmake --build . -j 4 @@ -113,7 +114,7 @@ jobs: run: | cd test mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=${{ matrix.platform }} \ + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=${{ matrix.platform.name }} \ -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.SOURCE_DIR }}/build/install/${{ env.OPENCV_SUBDIR }} .. cmake --build . -j 4 - name: upload-zip @@ -126,8 +127,8 @@ jobs: strategy: matrix: opencv-version: [4.10.0] - osname: - - {os: macos-13, arch: x86_64, platform: MAC} + osname: + - {os: macos-13, arch: x64, platform: MAC} - {os: macos-14, arch: arm64, platform: MAC_ARM64} runs-on: ${{ matrix.osname.os }} env: @@ -147,7 +148,7 @@ jobs: git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib echo "SOURCE_DIR=opencv" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-${{ matrix.osname.arch }}" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-macos-${{ matrix.osname.arch }}" >> $GITHUB_ENV echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV - name: build run: | @@ -174,54 +175,6 @@ jobs: name: ${{ env.PACKAGE_NAME }} path: ${{ env.PACKAGE_NAME }}.zip - # apple: - # needs: [macos, ios, ios-simulator] - # runs-on: macos-13 - # strategy: - # matrix: - # opencv-version: [4.10.0] - # steps: - # - run: sudo xcode-select --switch /Applications/Xcode_15.2.app - # - uses: actions/checkout@v4 - # - name: setup-opencv-package - # run: | - # echo "MACOS_PACKAGE_NAME=opencv-macos" >> $GITHUB_ENV - # echo "IOS_PACKAGE_NAME=opencv-ios" >> $GITHUB_ENV - # echo "IOS_SIMULATOR_PACKAGE_NAME=opencv-ios-simulator" >> $GITHUB_ENV - # echo "PACKAGE_NAME=opencv-apple" >> $GITHUB_ENV - # - name: download-macos-package - # uses: actions/download-artifact@v4 - # with: - # name: ${{ env.MACOS_PACKAGE_NAME }} - # - name: download-ios-package - # uses: actions/download-artifact@v4 - # with: - # name: ${{ env.IOS_PACKAGE_NAME }} - # - name: download-ios-simulator-package - # uses: actions/download-artifact@v4 - # with: - # name: ${{ env.IOS_SIMULATOR_PACKAGE_NAME }} - # - name: create-xcframwork - # run: | - # mkdir -p ${{ env.MACOS_PACKAGE_NAME }} - # mkdir -p ${{ env.IOS_PACKAGE_NAME }} - # mkdir -p ${{ env.IOS_SIMULATOR_PACKAGE_NAME }} - # unzip -q ${{ env.MACOS_PACKAGE_NAME }}.zip -d ${{ env.MACOS_PACKAGE_NAME }} - # unzip -q ${{ env.IOS_PACKAGE_NAME }}.zip -d ${{ env.IOS_PACKAGE_NAME }} - # unzip -q ${{ env.IOS_SIMULATOR_PACKAGE_NAME }}.zip -d ${{ env.IOS_SIMULATOR_PACKAGE_NAME }} - # xcodebuild -create-xcframework \ - # -framework ${{ env.MACOS_PACKAGE_NAME }}/opencv2.framework \ - # -framework ${{ env.IOS_PACKAGE_NAME }}/opencv2.framework \ - # -framework ${{ env.IOS_SIMULATOR_PACKAGE_NAME }}/opencv2.framework \ - # -output opencv2.xcframework - # rm -f ${{ env.PACKAGE_NAME }}.zip - # zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip opencv2.xcframework - # - name: upload-zip - # uses: actions/upload-artifact@v4 - # with: - # name: ${{ env.PACKAGE_NAME }} - # path: ${{ env.PACKAGE_NAME }}.zip - release: permissions: contents: write # for softprops/action-gh-release to create a release diff --git a/.github/workflows/build_test_release.yaml b/.github/workflows/build_test_release.yaml deleted file mode 100644 index 8fbe25d..0000000 --- a/.github/workflows/build_test_release.yaml +++ /dev/null @@ -1,243 +0,0 @@ -name: build release - -on: - push: - tags: - - "*.*.*" - # branches: - # - main - # pull_request: - # branches: ["main"] - -env: - ANDROID_NDK_VERSION: r26c - -jobs: - build-android: - name: build-android - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - name: setup - run: | - sudo apt-get update - - sudo apt-get install -y build-essential libgtk-3-dev ffmpeg libavcodec-dev \ - cmake ninja-build libavformat-dev libavutil-dev libswscale-dev \ - libgflags-dev python3 unzip tree python3-pip - - python3 -m pip install conan - conan profile detect -f - - cd ${{github.workspace}} - mkdir -p build/android - - wget -q -O build/android-ndk-$ANDROID_NDK_VERSION-linux.zip \ - https://dl.google.com/android/repository/android-ndk-$ANDROID_NDK_VERSION-linux.zip - unzip -q -o build/android-ndk-$ANDROID_NDK_VERSION-linux.zip -d build/ - - name: build-android - run: | - conan build . -b missing -pr:h profiles/android-x86_64 \ - -c tools.android:ndk_path="`pwd`/build/android-ndk-$ANDROID_NDK_VERSION" - conan build . -b missing -pr:h profiles/android-armv8 \ - -c tools.android:ndk_path="`pwd`/build/android-ndk-$ANDROID_NDK_VERSION" - conan build . -b missing -pr:h profiles/android-armv7 \ - -c tools.android:ndk_path="`pwd`/build/android-ndk-$ANDROID_NDK_VERSION" - - uses: actions/upload-artifact@v4 - name: upload-android-x86_64 - with: - path: build/publish/libopencv-android-x86_64.tar.gz - name: libopencv-android-x86_64.tar.gz - - - uses: actions/upload-artifact@v4 - name: upload-android-arm64-v8a - with: - path: build/publish/libopencv-android-arm64-v8a.tar.gz - name: libopencv-android-arm64-v8a.tar.gz - - - uses: actions/upload-artifact@v4 - name: upload-android-armeabi-v7a - with: - path: build/publish/libopencv-android-armeabi-v7a.tar.gz - name: libopencv-android-armeabi-v7a.tar.gz - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - draft: true - prerelease: false - files: | - build/publish/libopencv-android-arm64-v8a.tar.gz - build/publish/libopencv-android-armeabi-v7a.tar.gz - build/publish/libopencv-android-x86_64.tar.gz - - build-ubuntu: - name: build-ubuntu - runs-on: ubuntu-22.04 - - steps: - - name: setup - run: | - sudo apt-get update - sudo apt-get install -y curl git wget python3 unzip build-essential \ - libgtk-3-dev ffmpeg libavcodec-dev \ - cmake ninja-build libavformat-dev libavutil-dev \ - libswscale-dev libgflags-dev \ - libjpeg-dev libpng-dev libtiff-dev python3-pip - - python3 -m pip install conan - conan profile detect -f - - - uses: actions/checkout@v4 - with: - submodules: true - - name: build - run: | - conan build . -b missing -c tools.cmake.cmaketoolchain:generator=Ninja - - uses: actions/upload-artifact@v4 - name: upload-linux-x64 - with: - path: build/publish/libopencv-linux-x64.tar.gz - name: libopencv-linux-x64.tar.gz - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - draft: true - prerelease: false - files: | - build/publish/libopencv-linux-x64.tar.gz - - build-windows: - name: build-windows - runs-on: windows-2019 - - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - uses: actions/setup-python@v5 - with: - python-version: "3.11" - - name: build - run: | - python3 -m pip install conan - conan profile detect -f - conan build . -b missing -s compiler.cppstd=20 - - uses: actions/upload-artifact@v4 - name: upload-windows-x64 - with: - path: build/publish/libopencv-windows-x64.tar.gz - name: libopencv-windows-x64.tar.gz - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - draft: true - prerelease: false - files: | - build/publish/libopencv-windows-x64.tar.gz - build-macos: - name: build-macos - runs-on: macos-13 - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - name: setup - run: | - brew install --force --overwrite ninja ccache ffmpeg@6 nasm python@3.12 - brew link --overwrite ffmpeg@6 - brew link --overwrite python@3.12 - brew install --force --overwrite conan - conan profile detect -f - cd ${{github.workspace}} - - name: build - run: | - conan build . -b missing -c tools.cmake.cmaketoolchain:generator=Ninja - - - uses: actions/upload-artifact@v4 - name: upload-macos-x64 - with: - path: build/publish/libopencv-macos-x64.tar.gz - name: libopencv-macos-x64.tar.gz - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - draft: true - prerelease: false - files: | - build/publish/libopencv-macos-x64.tar.gz - build-macos-arm64: - name: build-macos-arm64 - runs-on: macos-14 - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - name: setup - run: | - brew install --force --overwrite ninja ccache ffmpeg@6 conan - brew link --overwrite ffmpeg@6 - conan profile detect -f - cd ${{github.workspace}} - - name: build - run: | - conan build . -b missing -c tools.cmake.cmaketoolchain:generator=Ninja - ls -alh build/Macos - - - uses: actions/upload-artifact@v4 - name: upload-macos-arm64 - with: - path: build/publish/libopencv-macos-arm64.tar.gz - name: libopencv-macos-arm64.tar.gz - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - draft: true - prerelease: false - files: | - build/publish/libopencv-macos-arm64.tar.gz - build-ios: - name: build-ios - runs-on: macos-14 - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - name: setup - run: | - brew install --force --overwrite ninja ccache ffmpeg@6 conan - conan profile detect -f - cd ${{github.workspace}} - - name: build - run: | - echo "tools.cmake.cmaketoolchain:user_toolchain=[\"`pwd`/profiles/ios.toolchain.cmake\"]" >> profiles/ios-armv8 - conan build . -b missing -pr:h profiles/ios-armv8 - - echo "tools.cmake.cmaketoolchain:user_toolchain=[\"`pwd`/profiles/ios.toolchain.cmake\"]" >> profiles/ios-x86_64 - conan build . -b missing -pr:h profiles/ios-x86_64 - - - uses: actions/upload-artifact@v4 - name: upload - with: - path: build/publish/libopencv-ios-arm64.tar.gz - name: libopencv-ios-arm64.tar.gz - - uses: actions/upload-artifact@v4 - name: upload x64 - with: - path: build/publish/libopencv-ios-x64.tar.gz - name: libopencv-ios-x64.tar.gz - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - draft: true - prerelease: false - files: | - build/publish/libopencv-ios-arm64.tar.gz - build/publish/libopencv-ios-x64.tar.gz diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 4bb4f5f..c660be4 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -34,7 +34,7 @@ jobs: git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-armlinux" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-armlinux" >> $GITHUB_ENV - name: build-aarch64-linux-gnu run: | cd ${{ env.SOURCE_DIR }} @@ -70,7 +70,6 @@ jobs: matrix: opencv-version: [4.10.0] os-ubuntu: - - { ubuntu-id: 2004, ubuntu-version: 20.04 } - { ubuntu-id: 2204, ubuntu-version: 22.04 } - { ubuntu-id: 2404, ubuntu-version: 24.04 } runs-on: ubuntu-${{ matrix.os-ubuntu.ubuntu-version }} @@ -88,7 +87,7 @@ jobs: git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-ubuntu-${{ matrix.os-ubuntu.ubuntu-id }}" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-ubuntu-${{ matrix.os-ubuntu.ubuntu-id }}" >> $GITHUB_ENV - name: build run: | cd ${{ env.SOURCE_DIR }} diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index a75c2fe..6aa2bb1 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -74,8 +74,8 @@ jobs: mkdir build-threads && cd build-threads cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=ON -DCV_ENABLE_INTRINSICS=OFF -DBUILD_WASM_INTRIN_TESTS=OFF \ - -DCMAKE_C_FLAGS="-s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ - -DCMAKE_CXX_FLAGS="-s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ + -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ + -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4" \ `cat ../../options.txt` -DBUILD_opencv_world=OFF -DWITH_VULKAN=OFF \ -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. cmake --build . -j $(nproc) @@ -87,8 +87,8 @@ jobs: mkdir build-simd-threads && cd build-simd-threads cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ -DCPU_BASELINE="" -DCPU_DISPATCH="" -DWITH_PTHREADS_PF=ON -DCV_ENABLE_INTRINSICS=ON -DBUILD_WASM_INTRIN_TESTS=OFF \ - -DCMAKE_C_FLAGS="-s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ - -DCMAKE_CXX_FLAGS="-s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ + -DCMAKE_C_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ + -DCMAKE_CXX_FLAGS="-fno-rtti -fno-exceptions -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -msimd128" \ `cat ../../options.txt` -DBUILD_opencv_world=OFF -DWITH_VULKAN=OFF \ -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. cmake --build . -j $(nproc) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 0d8057b..1afff9a 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -28,7 +28,7 @@ jobs: git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $env:GITHUB_ENV - echo "PACKAGE_NAME=opencv-${{ matrix.opencv-version }}-windows-${{ matrix.os-compiler.msvc-version }}" >> $env:GITHUB_ENV + echo "PACKAGE_NAME=opencv-windows-${{ matrix.os-compiler.msvc-version }}" >> $env:GITHUB_ENV - name: build-x64 run: | cd ${{ env.SOURCE_DIR }} diff --git a/conanfile.py b/conanfile.py deleted file mode 100644 index ab5eb65..0000000 --- a/conanfile.py +++ /dev/null @@ -1,467 +0,0 @@ -import os -from conan import ConanFile -from conan.api.output import ConanOutput, Color -from conan.errors import ConanInvalidConfiguration, ConanException -from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain, CMakeDeps -from conan.tools.files import chdir, mkdir, copy -from conan.tools.scm import Git -from conan.tools.microsoft import is_msvc, is_msvc_static_runtime -import tarfile -from pathlib import Path - -OPENCV_VERSION = "4.10.0" - -# for compatibility -arch_map = { - "windows": { - "x86_64": "x64", - }, - "linux": { - "x86_64": "x64", - }, - "android": { - "x86_64": "x86_64", - "armv8": "arm64-v8a", - "armv7": "armeabi-v7a", - }, - "macos": { - "x86_64": "x64", - "armv8": "arm64", - }, - "ios": { - "x86_64": "x64", - "armv8": "arm64", - }, -} - -# (name, enabled) -OCV_MODULES = { - "calib3d": True, - "dnn": True, - "features2d": True, - "flann": True, - "gapi": True, # not implemented - "highgui": True, - "imgcodecs": True, - "imgproc": True, - "ml": True, # not implemented - "objdetect": True, - "photo": True, - "stitching": True, - "video": True, - "videoio": True, - # contrib - "aruco": True, - "img_hash": True, - # not implemented - "wechat_qrcode": True, - "bgsegm": True, - "bioinspired": False, - "ccalib": True, - "dnn_objdetect": True, - "dnn_superres": True, - "dpm": False, - "face": True, - "fuzzy": False, - "hfs": False, - "intensity_transform": False, - "line_descriptor": False, - "mcc": False, - "optflow": False, - "phase_unwrapping": False, - "plot": False, - "rapid": False, - "reg": False, - "rgbd": False, - "saliency": False, - "shape": False, - "signal": False, - "stereo": False, - "structured_light": False, - "superres": True, - "surface_matching": False, - "tracking": False, - "videostab": False, - "xfeatures2d": True, - "ximgproc": True, - "xobjdetect": True, - "xphoto": True, - "alphamat": False, - "cannops": False, - "cudaarithm": False, - "cudabgsegm": False, - "cudacodec": False, - "cudafeatures2d": False, - "cudafilters": False, - "cudaimgproc": False, - "cudalegacy": False, - "cudaobjdetect": False, - "cudaoptflow": False, - "cudastereo": False, - "cudawarping": False, - "cudev": False, - "cvv": False, - "freetype": False, - "hdf": False, - "java": False, - "julia": False, - "matlab": False, - "ovis": False, - "python2": False, - "python3": False, - "sfm": False, - "ts": False, - "viz": False, - "quality":True, -} - - -class OcvDartDesktop(ConanFile): - name = "opencv" - settings = "os", "compiler", "build_type", "arch" - # generators = "CMakeToolchain", "CMakeDeps" - options = { - "build_opencv": [True, False], - "shared": [True, False], - "with_cuda": [True, False], - "with_cublas": [True, False], - "with_cufft": [True, False], - "with_cudnn": [True, False], - "with_eigen": [True, False], - "with_opencl": [True, False], - "with_openvino": [True, False], - "with_obsensor": [True, False], - "with_ipp": [False, "intel-ipp", "opencv-icv"], - "with_protobuf": [True, False], - "with_vulkan": [True, False], - # imgcodecs module options - "with_avif": [True, False], - "with_jpeg": [False, "libjpeg", "libjpeg-turbo", "mozjpeg"], - "with_png": [True, False], - "with_tiff": [True, False], - "with_jpeg2000": [False, "jasper", "openjpeg"], - "with_openexr": [True, False], - "with_webp": [True, False], - "with_gdal": [True, False], - "with_gdcm": [True, False], - "with_imgcodec_hdr": [True, False], - "with_imgcodec_pfm": [True, False], - "with_imgcodec_pxm": [True, False], - "with_imgcodec_sunraster": [True, False], - "with_msmf": [True, False], - "with_msmf_dxva": [True, False], - # objdetect module options - "with_quirc": [True, False], - # videoio module options - "with_ffmpeg": [True, False], - "with_openni2": [True, False], - "with_v4l": [True, False], - # text module options - "with_tesseract": [True, False], - "with_gtk": [True, False], - "nonfree": [True, False], - } - options.update({k: [True, False] for k in OCV_MODULES}) - default_build_options = { - "ffmpeg/*:with_vaapi": False, - "ffmpeg/*:with_vdpau": False, - "ffmpeg/*:with_xcb": False, - "pulseaudio/*:with_x11": False, - } - default_options = { - "ffmpeg/*:with_vaapi": False, - "ffmpeg/*:with_vdpau": False, - "ffmpeg/*:with_xcb": False, - "build_opencv": True, - "shared": False, - "with_cuda": False, - "with_cublas": False, - "with_cufft": False, - "with_cudnn": False, - "with_eigen": False, - "with_opencl": True, - "with_openvino": False, - "with_obsensor": False, - "with_ipp": "opencv-icv", - "with_protobuf": True, - "with_vulkan": True, - # imgcodecs module options - "with_avif": False, - "with_jpeg": "libjpeg-turbo", - "with_png": True, - "with_tiff": True, - "with_jpeg2000": "openjpeg", - "with_openexr": True, - "with_webp": True, - "with_gdal": False, - "with_gdcm": False, - "with_imgcodec_hdr": True, - "with_imgcodec_pfm": True, - "with_imgcodec_pxm": True, - "with_imgcodec_sunraster": True, - "with_msmf": True, - "with_msmf_dxva": True, - # objdetect module options - "with_quirc": True, - # videoio module options - "with_ffmpeg": True, - "with_openni2": False, - "with_v4l": True, - # text module options - "with_tesseract": False, - "with_gtk": True, - "nonfree": False, - } - default_options.update(OCV_MODULES) - - opencv_repo: str - opencv_contrib_repo: str - - def __init__(self, display_name=""): - super().__init__(display_name) - - self.version = OPENCV_VERSION - - def generate(self): - tc: CMakeToolchain = CMakeToolchain(self) - if self.settings.os == "iOS": - platform_map = { - "armv8": "OS64", - "x86_64": "SIMULATOR64", - # TODO: maybe need a conf var to support "SIMULATORARM64" and more - } - platform = platform_map[str(self.settings.arch)] - block = tc.blocks["user_toolchain"] - block.template = ( - f"set(PLATFORM {platform})\n" - "set(ENABLE_ARC FALSE)\n" - "set(ENABLE_BITCODE FALSE)\n" - f"{block.template}" - ) - # tc.variables["CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM"] = "rainyl" - # tc.variables["CODE_SIGNING_ALLOWED"] = "NO" - tc.variables["BUILD_CUDA_STUBS"] = False - tc.variables["BUILD_DOCS"] = False - tc.variables["BUILD_EXAMPLES"] = False - tc.variables["BUILD_FAT_JAVA_LIB"] = False - tc.variables["BUILD_IPP_IW"] = self.options.with_ipp == "opencv-icv" - tc.variables["BUILD_ITT"] = False - tc.variables["BUILD_JASPER"] = False - tc.variables["BUILD_JAVA"] = False - tc.variables["BUILD_JPEG"] = True - tc.variables["BUILD_OPENEXR"] = True - tc.variables["BUILD_OPENJPEG"] = True - tc.variables["BUILD_TESTS"] = False - tc.variables["BUILD_PROTOBUF"] = True - tc.variables["BUILD_PERF_TESTS"] = False - tc.variables["BUILD_USE_SYMLINKS"] = False - tc.variables["BUILD_opencv_apps"] = False - tc.variables["BUILD_opencv_java"] = False - tc.variables["BUILD_opencv_java_bindings_gen"] = False - tc.variables["BUILD_opencv_js"] = False - tc.variables["BUILD_ZLIB"] = True - tc.variables["BUILD_PNG"] = True - tc.variables["BUILD_TIFF"] = True - tc.variables["BUILD_WEBP"] = True - tc.variables["BUILD_TBB"] = False - tc.variables["OPENCV_FORCE_3RDPARTY_BUILD"] = False - tc.variables["OPENCV_PYTHON_SKIP_DETECTION"] = True - tc.variables["BUILD_opencv_python2"] = False - tc.variables["BUILD_opencv_python3"] = False - tc.variables["BUILD_opencv_python_bindings_g"] = False - tc.variables["BUILD_opencv_python_tests"] = False - tc.variables["BUILD_opencv_ts"] = False - - tc.variables["WITH_1394"] = True - tc.variables["WITH_ARAVIS"] = False - tc.variables["WITH_CLP"] = False - tc.variables["WITH_NVCUVID"] = False - - tc.variables["WITH_FFMPEG"] = self.get_bool("with_ffmpeg", False) - tc.variables["WITH_GSTREAMER"] = False - tc.variables["WITH_HALIDE"] = False - tc.variables["WITH_HPX"] = False - tc.variables["WITH_IMGCODEC_HDR"] = self.get_bool("with_imgcodec_hdr", False) - tc.variables["WITH_IMGCODEC_PFM"] = self.get_bool("with_imgcodec_pfm", False) - tc.variables["WITH_IMGCODEC_PXM"] = self.get_bool("with_imgcodec_pxm", False) - tc.variables["WITH_IMGCODEC_SUNRASTER"] = self.get_bool( - "with_imgcodec_sunraster", False - ) - tc.variables["WITH_IPP"] = bool(self.options.get_safe("with_ipp", False)) - tc.variables["WITH_ITT"] = False - tc.variables["WITH_LIBREALSENSE"] = False - tc.variables["WITH_MFX"] = False - # opencl fails on ios - tc.variables["WITH_OPENCL"] = ( - False if self.settings.os == "iOS" else self.get_bool("with_opencl", False) - ) - tc.variables["WITH_OPENCLAMDBLAS"] = False - tc.variables["WITH_OPENCLAMDFFT"] = False - tc.variables["WITH_OPENCL_SVM"] = False - tc.variables["WITH_OPENGL"] = False - tc.variables["WITH_OPENNI"] = False - tc.variables["WITH_OPENNI2"] = self.get_bool("with_openni2", False) - tc.variables["WITH_OPENVX"] = False - tc.variables["WITH_CAROTENE"] = False - tc.variables["WITH_PLAIDML"] = False - tc.variables["WITH_PVAPI"] = False - tc.variables["WITH_QT"] = self.get_bool("with_qt", False) - tc.variables["WITH_QUIRC"] = self.get_bool("with_quirc", False) - tc.variables["WITH_V4L"] = self.get_bool("with_v4l", False) - tc.variables["WITH_VA"] = False - tc.variables["WITH_VA_INTEL"] = False - tc.variables["WITH_VTK"] = self.get_bool("viz", False) - tc.variables["WITH_VULKAN"] = self.get_bool("with_vulkan", False) - tc.variables["WITH_XIMEA"] = False - tc.variables["WITH_XINE"] = False - tc.variables["WITH_LAPACK"] = False - - tc.variables["WITH_GTK"] = self.get_bool("with_gtk", False) - tc.variables["WITH_WEBP"] = self.get_bool("with_webp", False) - tc.variables["WITH_JPEG"] = bool(self.options.get_safe("with_jpeg", False)) - tc.variables["WITH_PNG"] = self.get_bool("with_png", False) - tc.variables["WITH_TIFF"] = self.get_bool("with_tiff", False) - tc.variables["WITH_JASPER"] = self.options.get_safe("with_jpeg2000") == "jasper" - tc.variables["WITH_OPENJPEG"] = ( - self.options.get_safe("with_jpeg2000") == "openjpeg" - ) - tc.variables["WITH_OPENEXR"] = self.get_bool("with_openexr", False) - tc.variables["WITH_GDAL"] = self.get_bool("with_gdal", False) - tc.variables["WITH_GDCM"] = self.get_bool("with_gdcm", False) - tc.variables["WITH_EIGEN"] = self.get_bool("with_eigen") - tc.variables["WITH_DSHOW"] = is_msvc(self) - tc.variables["WITH_MSMF"] = self.get_bool("with_msmf", False) - tc.variables["WITH_MSMF_DXVA"] = self.get_bool("with_msmf_dxva", False) - tc.variables["OPENCV_ENABLE_NONFREE"] = self.get_bool("nonfree", False) - tc.variables["ENABLE_NEON"] = self.get_bool("neon", False) - tc.variables["OPENCV_DNN_CUDA"] = self.get_bool("dnn_cuda", False) - tc.variables["WITH_OPENVINO"] = False - tc.variables["WITH_OBSENSOR"] = self.get_bool("with_obsensor", False) - tc.variables["WITH_AVIF"] = self.get_bool("with_avif", False) - tc.variables["BUILD_opencv_world"] = self.get_bool("world", False) - tc.variables["BUILD_opencv_core"] = True - for module in OCV_MODULES: - tc.variables[f"BUILD_opencv_{module}"] = self.get_bool(module, False) - tc.variables["WITH_PROTOBUF"] = self.get_bool("with_protobuf", False) - tc.variables["WITH_ADE"] = self.get_bool("gapi", False) - tc.variables["BUILD_opencv_julia"] = False - tc.variables["BUILD_opencv_matlab"] = False - tc.variables["WITH_TESSERACT"] = self.get_bool("with_tesseract", False) - tc.variables["WITH_CUDA"] = self.get_bool("with_cuda", False) - tc.variables["WITH_CUBLAS"] = self.get_bool("with_cublas", False) - tc.variables["WITH_CUFFT"] = self.get_bool("with_cufft", False) - tc.variables["WITH_CUDNN"] = self.get_bool("with_cudnn", False) - tc.variables["BUILD_WITH_STATIC_CRT"] = is_msvc_static_runtime(self) - if is_msvc(self): - tc.variables["BUILD_WITH_STATIC_CRT"] = is_msvc_static_runtime(self) - - if self.settings.os == "Android": - tc.variables["BUILD_ANDROID_EXAMPLES"] = False - - tc.variables["OPENCV_EXTRA_MODULES_PATH"] = os.path.join( - self.opencv_contrib_repo, "modules" - ).replace("\\", "/") - tc.generate() - - CMakeDeps(self).generate() - - def requirements(self): - root = os.path.abspath(".") - self.opencv_repo = os.path.join(root, "build", "opencv") - self.opencv_contrib_repo = os.path.join(root, "build", "opencv_contrib") - git = Git(self) - if not os.path.exists(self.opencv_repo): - git.clone("https://github.com/opencv/opencv.git", self.opencv_repo, [f"-b {OPENCV_VERSION}"]) - if not os.path.exists(self.opencv_contrib_repo): - git.clone( - "https://github.com/opencv/opencv_contrib.git", - self.opencv_contrib_repo, - [f"-b {OPENCV_VERSION}"] - ) - - def build_requirements(self): - self.tool_requires("cmake/3.28.1") - # self.tool_requires("nasm/2.16.01") - # self.tool_requires("ccache/4.9.1") - - # build ffmpeg only for linux, on macos, install with brew, - # on windows use prebuilt dll - # android and ios are unsupported - # if self.settings.os == "Linux": - # self.tool_requires("ffmpeg/6.1") - if self.settings.os != "Windows": - self.tool_requires("ninja/1.11.1") - - def layout(self): - base = Path("build") / str(self.settings.os) / str(self.settings.arch) - self.folders.generators = str((base / "generators").absolute()) - self.folders.build = str((base / "opencv").absolute()) - self.folders.source = "build/opencv" - - def layout_dart(self): - # self.build_folder: build/{os}/{arch}/opencv - base = Path(self.build_folder).parent # build/{os}/{arch} - self.folders.generators = str((base / "generators").absolute()) - self.folders.build = str(base.absolute()) - self.folders.source = "." - - def build(self): - cmake = CMake(self) - - if self.get_bool("build_opencv", True): - # build opencv - cmake.configure( - variables={ - "CMAKE_INSTALL_PREFIX": self.install_folder, - } - ) - cmake.build(target="install") - else: - ConanOutput().writeln("Skipping opencv build...", fg=Color.YELLOW) - ocv_install_dir = self.opencv_dir(self.install_folder) - - self.post_build() - - def post_build(self): - # archive - install_dir = Path(self.install_folder) - os = str(self.settings.os).lower() - arch = arch_map[os][str(self.settings.arch)] - new_name = f"lib{self.name}-{os}-{arch}.tar.gz" - fname = self.publish_folder / new_name - print(fname) - if not fname.parent.exists(): - fname.parent.mkdir(parents=True) - with tarfile.open(fname, mode="w:gz") as tar: - for file in install_dir.glob("*"): - print(f"Adding {file}...") - tar.add(file, arcname=file.name) - print(f"published: {fname}") - - @property - def install_folder(self) -> Path: - return Path(f"{os.path.join(self.build_folder, 'install')}") - - @property - def publish_folder(self) -> Path: - p = Path(self.install_folder).absolute().parent.parent.parent.parent - return p / "publish" - - def opencv_dir(self, dir: Path) -> str: - if self.settings.os == "Windows": - return str(dir) - elif self.settings.os in ["Linux", "Macos", "iOS"]: - return str(dir / "lib" / "cmake" / "opencv4") - elif self.settings.os == "Android": - return str(dir / "sdk" / "native" / "jni") - else: - raise ConanInvalidConfiguration - - def get_bool(self, name: str, default=False): - value = str(self.options.get_safe(name, default)) - if isinstance(value, str): - return value == "True" - elif isinstance(value, bool): - return value - else: - raise ValueError(f"value: {value=} of {name=} error") diff --git a/profiles/android-armv7 b/profiles/android-armv7 deleted file mode 100644 index 2521f96..0000000 --- a/profiles/android-armv7 +++ /dev/null @@ -1,13 +0,0 @@ -include(default) - -[settings] -os=Android -os.api_level=24 -arch=armv7 -compiler=clang -compiler.version=12 -compiler.libcxx=c++_static -compiler.cppstd=14 - -[conf] -tools.cmake.cmaketoolchain:generator=Ninja diff --git a/profiles/android-armv8 b/profiles/android-armv8 deleted file mode 100644 index 50bdc9a..0000000 --- a/profiles/android-armv8 +++ /dev/null @@ -1,13 +0,0 @@ -include(default) - -[settings] -os=Android -os.api_level=24 -arch=armv8 -compiler=clang -compiler.version=12 -compiler.libcxx=c++_static -compiler.cppstd=14 - -[conf] -tools.cmake.cmaketoolchain:generator=Ninja diff --git a/profiles/android-x86_64 b/profiles/android-x86_64 deleted file mode 100644 index 5dd70ad..0000000 --- a/profiles/android-x86_64 +++ /dev/null @@ -1,13 +0,0 @@ -include(default) - -[settings] -os=Android -os.api_level=24 -arch=x86_64 -compiler=clang -compiler.version=12 -compiler.libcxx=c++_static -compiler.cppstd=14 - -[conf] -tools.cmake.cmaketoolchain:generator=Ninja diff --git a/profiles/arm-toolchain/test_package/CMakeUserPresets.json b/profiles/arm-toolchain/test_package/CMakeUserPresets.json deleted file mode 100644 index e6e4188..0000000 --- a/profiles/arm-toolchain/test_package/CMakeUserPresets.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "version": 4, - "vendor": { - "conan": {} - }, - "include": [ - "build/gcc-13-armv8-gnu17-release/generators/CMakePresets.json" - ] -} \ No newline at end of file diff --git a/profiles/ios-armv8 b/profiles/ios-armv8 deleted file mode 100644 index cea6f01..0000000 --- a/profiles/ios-armv8 +++ /dev/null @@ -1,13 +0,0 @@ -include(default) - -[settings] -os=iOS -os.version=12.0 -os.sdk=iphoneos -arch=armv8 -build_type=Release - -[conf] -tools.apple:enable_arc=False -tools.apple:enable_visibility=False -tools.cmake.cmaketoolchain:generator=Xcode diff --git a/profiles/ios-x86_64 b/profiles/ios-x86_64 deleted file mode 100644 index 3aee0d0..0000000 --- a/profiles/ios-x86_64 +++ /dev/null @@ -1,13 +0,0 @@ -include(default) - -[settings] -os=iOS -os.version=12.0 -os.sdk=iphonesimulator -arch=x86_64 -build_type=Release - -[conf] -tools.apple:enable_arc=False -tools.apple:enable_visibility=False -tools.cmake.cmaketoolchain:generator=Xcode diff --git a/profiles/ios.toolchain.cmake b/profiles/ios.toolchain.cmake deleted file mode 100644 index db2a327..0000000 --- a/profiles/ios.toolchain.cmake +++ /dev/null @@ -1,1135 +0,0 @@ -# This file is part of the ios-cmake project. It was retrieved from -# https://github.com/leetal/ios-cmake.git, which is a fork of -# https://github.com/gerstrong/ios-cmake.git, which is a fork of -# https://github.com/cristeab/ios-cmake.git, which is a fork of -# https://code.google.com/p/ios-cmake/. Which in turn is based off of -# the Platform/Darwin.cmake and Platform/UnixPaths.cmake files which -# are included with CMake 2.8.4 -# -# The ios-cmake project is licensed under the new BSD license. -# -# Copyright (c) 2014, Bogdan Cristea and LTE Engineering Software, -# Kitware, Inc., Insight Software Consortium. All rights reserved. -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# This file is based on the Platform/Darwin.cmake and -# Platform/UnixPaths.cmake files which are included with CMake 2.8.4 -# It has been altered for iOS development. -# -# Updated by Alex Stewart (alexs.mac@gmail.com) -# -# ***************************************************************************** -# Now maintained by Alexander Widerberg (widerbergaren [at] gmail.com) -# under the BSD-3-Clause license -# https://github.com/leetal/ios-cmake -# ***************************************************************************** -# -# INFORMATION / HELP -# -############################################################################### -# OPTIONS # -############################################################################### -# -# PLATFORM: (default "OS64") -# OS = Build for iPhoneOS. -# OS64 = Build for arm64 iphoneOS. -# OS64COMBINED = Build for arm64 x86_64 iphoneOS + iphoneOS Simulator. Combined into FAT STATIC lib (only supported on 3.14+ of CMake with "-G Xcode" argument in combination with the "cmake --install" CMake build step) -# SIMULATOR = Build for x86 i386 iphoneOS Simulator. -# SIMULATOR64 = Build for x86_64 iphoneOS Simulator. -# SIMULATORARM64 = Build for arm64 iphoneOS Simulator. -# SIMULATOR64COMBINED = Build for arm64 x86_64 iphoneOS Simulator. Combined into FAT STATIC lib (supported on 3.14+ of CMakewith "-G Xcode" argument ONLY) -# TVOS = Build for arm64 tvOS. -# TVOSCOMBINED = Build for arm64 x86_64 tvOS + tvOS Simulator. Combined into FAT STATIC lib (only supported on 3.14+ of CMake with "-G Xcode" argument in combination with the "cmake --install" CMake build step) -# SIMULATOR_TVOS = Build for x86_64 tvOS Simulator. -# SIMULATORARM64_TVOS = Build for arm64 tvOS Simulator. -# VISIONOSCOMBINED = Build for arm64 visionOS + visionOS Simulator. Combined into FAT STATIC lib (only supported on 3.14+ of CMake with "-G Xcode" argument in combination with the "cmake --install" CMake build step) -# VISIONOS = Build for arm64 visionOS. -# SIMULATOR_VISIONOS = Build for arm64 visionOS Simulator. -# WATCHOS = Build for armv7k arm64_32 for watchOS. -# WATCHOSCOMBINED = Build for armv7k arm64_32 x86_64 watchOS + watchOS Simulator. Combined into FAT STATIC lib (only supported on 3.14+ of CMake with "-G Xcode" argument in combination with the "cmake --install" CMake build step) -# SIMULATOR_WATCHOS = Build for x86_64 for watchOS Simulator. -# SIMULATORARM64_WATCHOS = Build for arm64 for watchOS Simulator. -# MAC = Build for x86_64 macOS. -# MAC_ARM64 = Build for Apple Silicon macOS. -# MAC_UNIVERSAL = Combined build for x86_64 and Apple Silicon on macOS. -# MAC_CATALYST = Build for x86_64 macOS with Catalyst support (iOS toolchain on macOS). -# Note: The build argument "MACOSX_DEPLOYMENT_TARGET" can be used to control min-version of macOS -# MAC_CATALYST_ARM64 = Build for Apple Silicon macOS with Catalyst support (iOS toolchain on macOS). -# Note: The build argument "MACOSX_DEPLOYMENT_TARGET" can be used to control min-version of macOS -# -# CMAKE_OSX_SYSROOT: Path to the SDK to use. By default this is -# automatically determined from PLATFORM and xcodebuild, but -# can also be manually specified (although this should not be required). -# -# CMAKE_DEVELOPER_ROOT: Path to the Developer directory for the platform -# being compiled for. By default, this is automatically determined from -# CMAKE_OSX_SYSROOT, but can also be manually specified (although this should -# not be required). -# -# DEPLOYMENT_TARGET: Minimum SDK version to target. Default 6.0 on watchOS, 13.0 on tvOS+iOS/iPadOS, 11.0 on macOS, 1.0 on visionOS -# -# NAMED_LANGUAGE_SUPPORT: -# ON (default) = Will require "enable_language(OBJC) and/or enable_language(OBJCXX)" for full OBJC|OBJCXX support -# OFF = Will embed the OBJC and OBJCXX flags into the CMAKE_C_FLAGS and CMAKE_CXX_FLAGS (legacy behavior, CMake version < 3.16) -# -# ENABLE_BITCODE: (ON|OFF) Enables or disables bitcode support. Default OFF -# -# ENABLE_ARC: (ON|OFF) Enables or disables ARC support. Default ON (ARC enabled by default) -# -# ENABLE_VISIBILITY: (ON|OFF) Enables or disables symbol visibility support. Default OFF (visibility hidden by default) -# -# ENABLE_STRICT_TRY_COMPILE: (ON|OFF) Enables or disables strict try_compile() on all Check* directives (will run linker -# to actually check if linking is possible). Default OFF (will set CMAKE_TRY_COMPILE_TARGET_TYPE to STATIC_LIBRARY) -# -# ARCHS: (armv7 armv7s armv7k arm64 arm64_32 i386 x86_64) If specified, will override the default architectures for the given PLATFORM -# OS = armv7 armv7s arm64 (if applicable) -# OS64 = arm64 (if applicable) -# SIMULATOR = i386 -# SIMULATOR64 = x86_64 -# SIMULATORARM64 = arm64 -# TVOS = arm64 -# SIMULATOR_TVOS = x86_64 (i386 has since long been deprecated) -# SIMULATORARM64_TVOS = arm64 -# WATCHOS = armv7k arm64_32 (if applicable) -# SIMULATOR_WATCHOS = x86_64 (i386 has since long been deprecated) -# SIMULATORARM64_WATCHOS = arm64 -# MAC = x86_64 -# MAC_ARM64 = arm64 -# MAC_UNIVERSAL = x86_64 arm64 -# MAC_CATALYST = x86_64 -# MAC_CATALYST_ARM64 = arm64 -# -# NOTE: When manually specifying ARCHS, put a semi-colon between the entries. E.g., -DARCHS="armv7;arm64" -# -############################################################################### -# END OPTIONS # -############################################################################### -# -# This toolchain defines the following properties (available via get_property()) for use externally: -# -# PLATFORM: The currently targeted platform. -# XCODE_VERSION: Version number (not including Build version) of Xcode detected. -# SDK_VERSION: Version of SDK being used. -# OSX_ARCHITECTURES: Architectures being compiled for (generated from PLATFORM). -# APPLE_TARGET_TRIPLE: Used by autoconf build systems. NOTE: If "ARCHS" is overridden, this will *NOT* be set! -# -# This toolchain defines the following macros for use externally: -# -# set_xcode_property (TARGET XCODE_PROPERTY XCODE_VALUE XCODE_VARIANT) -# A convenience macro for setting xcode specific properties on targets. -# Available variants are: All, Release, RelWithDebInfo, Debug, MinSizeRel -# example: set_xcode_property (myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1" "all"). -# -# find_host_package (PROGRAM ARGS) -# A macro used to find executable programs on the host system, not within the -# environment. Thanks to the android-cmake project for providing the -# command. -# - -cmake_minimum_required(VERSION 3.8.0) - -# CMake invokes the toolchain file twice during the first build, but only once during subsequent rebuilds. -if(DEFINED ENV{_IOS_TOOLCHAIN_HAS_RUN}) - return() -endif() -set(ENV{_IOS_TOOLCHAIN_HAS_RUN} true) - -# List of supported platform values -list(APPEND _supported_platforms - "OS" "OS64" "OS64COMBINED" "SIMULATOR" "SIMULATOR64" "SIMULATORARM64" "SIMULATOR64COMBINED" - "TVOS" "TVOSCOMBINED" "SIMULATOR_TVOS" "SIMULATORARM64_TVOS" - "WATCHOS" "WATCHOSCOMBINED" "SIMULATOR_WATCHOS" "SIMULATORARM64_WATCHOS" - "MAC" "MAC_ARM64" "MAC_UNIVERSAL" - "VISIONOS" "SIMULATOR_VISIONOS" "VISIONOSCOMBINED" - "MAC_CATALYST" "MAC_CATALYST_ARM64") - -# Cache what generator is used -set(USED_CMAKE_GENERATOR "${CMAKE_GENERATOR}") - -# Check if using a CMake version capable of building combined FAT builds (simulator and target slices combined in one static lib) -if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14") - set(MODERN_CMAKE YES) -endif() - -# Get the Xcode version being used. -# Problem: CMake runs toolchain files multiple times, but can't read cache variables on some runs. -# Workaround: On the first run (in which cache variables are always accessible), set an intermediary environment variable. -# -# NOTE: This pattern is used in many places in this toolchain to speed up checks of all sorts -if(DEFINED XCODE_VERSION_INT) - # Environment variables are always preserved. - set(ENV{_XCODE_VERSION_INT} "${XCODE_VERSION_INT}") -elseif(DEFINED ENV{_XCODE_VERSION_INT}) - set(XCODE_VERSION_INT "$ENV{_XCODE_VERSION_INT}") -elseif(NOT DEFINED XCODE_VERSION_INT) - find_program(XCODEBUILD_EXECUTABLE xcodebuild) - if(NOT XCODEBUILD_EXECUTABLE) - message(FATAL_ERROR "xcodebuild not found. Please install either the standalone commandline tools or Xcode.") - endif() - execute_process(COMMAND ${XCODEBUILD_EXECUTABLE} -version - OUTPUT_VARIABLE XCODE_VERSION_INT - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REGEX MATCH "Xcode [0-9\\.]+" XCODE_VERSION_INT "${XCODE_VERSION_INT}") - string(REGEX REPLACE "Xcode ([0-9\\.]+)" "\\1" XCODE_VERSION_INT "${XCODE_VERSION_INT}") - set(XCODE_VERSION_INT "${XCODE_VERSION_INT}" CACHE INTERNAL "") -endif() - -# Assuming that xcode 12.0 is installed you most probably have ios sdk 14.0 or later installed (tested on Big Sur) -# if you don't set a deployment target it will be set the way you only get 64-bit builds -#if(NOT DEFINED DEPLOYMENT_TARGET AND XCODE_VERSION_INT VERSION_GREATER 12.0) -# Temporarily fix the arm64 issues in CMake install-combined by excluding arm64 for simulator builds (needed for Apple Silicon...) -# set(CMAKE_XCODE_ATTRIBUTE_EXCLUDED_ARCHS[sdk=iphonesimulator*] "arm64") -#endif() - -# Check if the platform variable is set -if(DEFINED PLATFORM) - # Environment variables are always preserved. - set(ENV{_PLATFORM} "${PLATFORM}") -elseif(DEFINED ENV{_PLATFORM}) - set(PLATFORM "$ENV{_PLATFORM}") -elseif(NOT DEFINED PLATFORM) - message(FATAL_ERROR "PLATFORM argument not set. Bailing configure since I don't know what target you want to build for!") -endif () - -if(PLATFORM MATCHES ".*COMBINED" AND NOT CMAKE_GENERATOR MATCHES "Xcode") - message(FATAL_ERROR "The combined builds support requires Xcode to be used as a generator via '-G Xcode' command-line argument in CMake") -endif() - -# Safeguard that the platform value is set and is one of the supported values -list(FIND _supported_platforms ${PLATFORM} contains_PLATFORM) -if("${contains_PLATFORM}" EQUAL "-1") - string(REPLACE ";" "\n * " _supported_platforms_formatted "${_supported_platforms}") - message(FATAL_ERROR " Invalid PLATFORM specified! Current value: ${PLATFORM}.\n" - " Supported PLATFORM values: \n * ${_supported_platforms_formatted}") -endif() - -# Check if Apple Silicon is supported -if(PLATFORM MATCHES "^(MAC_ARM64)$|^(MAC_CATALYST_ARM64)$|^(MAC_UNIVERSAL)$" AND ${CMAKE_VERSION} VERSION_LESS "3.19.5") - message(FATAL_ERROR "Apple Silicon builds requires a minimum of CMake 3.19.5") -endif() - -# Touch the toolchain variable to suppress the "unused variable" warning. -# This happens if CMake is invoked with the same command line the second time. -if(CMAKE_TOOLCHAIN_FILE) -endif() - -# Fix for PThread library not in path -set(CMAKE_THREAD_LIBS_INIT "-lpthread") -set(CMAKE_HAVE_THREADS_LIBRARY 1) -set(CMAKE_USE_WIN32_THREADS_INIT 0) -set(CMAKE_USE_PTHREADS_INIT 1) - -# Specify named language support defaults. -if(NOT DEFINED NAMED_LANGUAGE_SUPPORT AND ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16") - set(NAMED_LANGUAGE_SUPPORT ON) - message(STATUS "[DEFAULTS] Using explicit named language support! E.g., enable_language(CXX) is needed in the project files.") -elseif(NOT DEFINED NAMED_LANGUAGE_SUPPORT AND ${CMAKE_VERSION} VERSION_LESS "3.16") - set(NAMED_LANGUAGE_SUPPORT OFF) - message(STATUS "[DEFAULTS] Disabling explicit named language support. Falling back to legacy behavior.") -elseif(DEFINED NAMED_LANGUAGE_SUPPORT AND ${CMAKE_VERSION} VERSION_LESS "3.16") - message(FATAL_ERROR "CMake named language support for OBJC and OBJCXX was added in CMake 3.16.") -endif() -set(NAMED_LANGUAGE_SUPPORT_INT ${NAMED_LANGUAGE_SUPPORT} CACHE BOOL - "Whether or not to enable explicit named language support" FORCE) - -# Specify the minimum version of the deployment target. -if(NOT DEFINED DEPLOYMENT_TARGET) - if (PLATFORM MATCHES "WATCHOS") - # Unless specified, SDK version 4.0 is used by default as minimum target version (watchOS). - set(DEPLOYMENT_TARGET "6.0") - elseif(PLATFORM STREQUAL "MAC") - # Unless specified, SDK version 10.13 (High Sierra) is used by default as the minimum target version (macos). - set(DEPLOYMENT_TARGET "11.0") - elseif(PLATFORM STREQUAL "VISIONOS" OR PLATFORM STREQUAL "SIMULATOR_VISIONOS" OR PLATFORM STREQUAL "VISIONOSCOMBINED") - # Unless specified, SDK version 1.0 is used by default as minimum target version (visionOS). - set(DEPLOYMENT_TARGET "1.0") - elseif(PLATFORM STREQUAL "MAC_ARM64") - # Unless specified, SDK version 11.0 (Big Sur) is used by default as the minimum target version (macOS on arm). - set(DEPLOYMENT_TARGET "11.0") - elseif(PLATFORM STREQUAL "MAC_UNIVERSAL") - # Unless specified, SDK version 11.0 (Big Sur) is used by default as minimum target version for universal builds. - set(DEPLOYMENT_TARGET "11.0") - elseif(PLATFORM STREQUAL "MAC_CATALYST" OR PLATFORM STREQUAL "MAC_CATALYST_ARM64") - # Unless specified, SDK version 13.0 is used by default as the minimum target version (mac catalyst minimum requirement). - set(DEPLOYMENT_TARGET "13.1") - else() - # Unless specified, SDK version 11.0 is used by default as the minimum target version (iOS, tvOS). - set(DEPLOYMENT_TARGET "13.0") - endif() - message(STATUS "[DEFAULTS] Using the default min-version since DEPLOYMENT_TARGET not provided!") -elseif(DEFINED DEPLOYMENT_TARGET AND PLATFORM MATCHES "^MAC_CATALYST" AND ${DEPLOYMENT_TARGET} VERSION_LESS "13.1") - message(FATAL_ERROR "Mac Catalyst builds requires a minimum deployment target of 13.1!") -endif() - -# Store the DEPLOYMENT_TARGET in the cache -set(DEPLOYMENT_TARGET "${DEPLOYMENT_TARGET}" CACHE INTERNAL "") - -# Handle the case where we are targeting iOS and a version above 10.3.4 (32-bit support dropped officially) -if(PLATFORM STREQUAL "OS" AND DEPLOYMENT_TARGET VERSION_GREATER_EQUAL 10.3.4) - set(PLATFORM "OS64") - message(STATUS "Targeting minimum SDK version ${DEPLOYMENT_TARGET}. Dropping 32-bit support.") -elseif(PLATFORM STREQUAL "SIMULATOR" AND DEPLOYMENT_TARGET VERSION_GREATER_EQUAL 10.3.4) - set(PLATFORM "SIMULATOR64") - message(STATUS "Targeting minimum SDK version ${DEPLOYMENT_TARGET}. Dropping 32-bit support.") -endif() - -set(PLATFORM_INT "${PLATFORM}") - -if(DEFINED ARCHS) - string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}") -endif() - -# Determine the platform name and architectures for use in xcodebuild commands -# from the specified PLATFORM_INT name. -if(PLATFORM_INT STREQUAL "OS") - set(SDK_NAME iphoneos) - if(NOT ARCHS) - set(ARCHS armv7 armv7s arm64) - set(APPLE_TARGET_TRIPLE_INT arm-apple-ios${DEPLOYMENT_TARGET}) - else() - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}) - endif() -elseif(PLATFORM_INT STREQUAL "OS64") - set(SDK_NAME iphoneos) - if(NOT ARCHS) - if (XCODE_VERSION_INT VERSION_GREATER 10.0) - set(ARCHS arm64) # FIXME: Add arm64e when Apple has fixed the integration issues with it, libarclite_iphoneos.a is currently missing bitcode markers for example - else() - set(ARCHS arm64) - endif() - set(APPLE_TARGET_TRIPLE_INT arm64-apple-ios${DEPLOYMENT_TARGET}) - else() - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}) - endif() -elseif(PLATFORM_INT STREQUAL "OS64COMBINED") - set(SDK_NAME iphoneos) - if(MODERN_CMAKE) - if(NOT ARCHS) - if (XCODE_VERSION_INT VERSION_GREATER 12.0) - set(ARCHS arm64 x86_64) - set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphoneos*] "arm64") - set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphonesimulator*] "x86_64 arm64") - set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphoneos*] "arm64") - set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphonesimulator*] "x86_64 arm64") - else() - set(ARCHS arm64 x86_64) - set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphoneos*] "arm64") - set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphonesimulator*] "x86_64") - set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphoneos*] "arm64") - set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphonesimulator*] "x86_64") - endif() - set(APPLE_TARGET_TRIPLE_INT arm64-x86_64-apple-ios${DEPLOYMENT_TARGET}) - else() - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}) - endif() - else() - message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the OS64COMBINED setting work") - endif() -elseif(PLATFORM_INT STREQUAL "SIMULATOR64COMBINED") - set(SDK_NAME iphonesimulator) - if(MODERN_CMAKE) - if(NOT ARCHS) - if (XCODE_VERSION_INT VERSION_GREATER 12.0) - set(ARCHS arm64 x86_64) # FIXME: Add arm64e when Apple have fixed the integration issues with it, libarclite_iphoneos.a is currently missing bitcode markers for example - set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphoneos*] "") - set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphonesimulator*] "x86_64 arm64") - set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphoneos*] "") - set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphonesimulator*] "x86_64 arm64") - else() - set(ARCHS arm64 x86_64) - set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphoneos*] "") - set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphonesimulator*] "x86_64") - set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphoneos*] "") - set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphonesimulator*] "x86_64") - endif() - set(APPLE_TARGET_TRIPLE_INT aarch64-x86_64-apple-ios${DEPLOYMENT_TARGET}-simulator) - else() - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-simulator) - endif() - else() - message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the SIMULATOR64COMBINED setting work") - endif() -elseif(PLATFORM_INT STREQUAL "SIMULATOR") - set(SDK_NAME iphonesimulator) - if(NOT ARCHS) - set(ARCHS i386) - set(APPLE_TARGET_TRIPLE_INT i386-apple-ios${DEPLOYMENT_TARGET}-simulator) - else() - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-simulator) - endif() - message(DEPRECATION "SIMULATOR IS DEPRECATED. Consider using SIMULATOR64 instead.") -elseif(PLATFORM_INT STREQUAL "SIMULATOR64") - set(SDK_NAME iphonesimulator) - if(NOT ARCHS) - set(ARCHS x86_64) - set(APPLE_TARGET_TRIPLE_INT x86_64-apple-ios${DEPLOYMENT_TARGET}-simulator) - else() - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-simulator) - endif() -elseif(PLATFORM_INT STREQUAL "SIMULATORARM64") - set(SDK_NAME iphonesimulator) - if(NOT ARCHS) - set(ARCHS arm64) - set(APPLE_TARGET_TRIPLE_INT arm64-apple-ios${DEPLOYMENT_TARGET}-simulator) - else() - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-simulator) - endif() -elseif(PLATFORM_INT STREQUAL "TVOS") - set(SDK_NAME appletvos) - if(NOT ARCHS) - set(ARCHS arm64) - set(APPLE_TARGET_TRIPLE_INT arm64-apple-tvos${DEPLOYMENT_TARGET}) - else() - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-tvos${DEPLOYMENT_TARGET}) - endif() -elseif (PLATFORM_INT STREQUAL "TVOSCOMBINED") - set(SDK_NAME appletvos) - if(MODERN_CMAKE) - if(NOT ARCHS) - set(ARCHS arm64 x86_64) - set(APPLE_TARGET_TRIPLE_INT arm64-x86_64-apple-tvos${DEPLOYMENT_TARGET}) - set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=appletvos*] "arm64") - set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=appletvsimulator*] "x86_64 arm64") - set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=appletvos*] "arm64") - set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=appletvsimulator*] "x86_64 arm64") - else() - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-tvos${DEPLOYMENT_TARGET}) - endif() - else() - message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the TVOSCOMBINED setting work") - endif() -elseif(PLATFORM_INT STREQUAL "SIMULATOR_TVOS") - set(SDK_NAME appletvsimulator) - if(NOT ARCHS) - set(ARCHS x86_64) - set(APPLE_TARGET_TRIPLE_INT x86_64-apple-tvos${DEPLOYMENT_TARGET}-simulator) - else() - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-tvos${DEPLOYMENT_TARGET}-simulator) - endif() -elseif(PLATFORM_INT STREQUAL "SIMULATORARM64_TVOS") - set(SDK_NAME appletvsimulator) - if(NOT ARCHS) - set(ARCHS arm64) - set(APPLE_TARGET_TRIPLE_INT arm64-apple-tvos${DEPLOYMENT_TARGET}-simulator) - else() - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-tvos${DEPLOYMENT_TARGET}-simulator) - endif() -elseif(PLATFORM_INT STREQUAL "WATCHOS") - set(SDK_NAME watchos) - if(NOT ARCHS) - if (XCODE_VERSION_INT VERSION_GREATER 10.0) - set(ARCHS armv7k arm64_32) - set(APPLE_TARGET_TRIPLE_INT arm64_32-apple-watchos${DEPLOYMENT_TARGET}) - else() - set(ARCHS armv7k) - set(APPLE_TARGET_TRIPLE_INT arm-apple-watchos${DEPLOYMENT_TARGET}) - endif() - else() - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos${DEPLOYMENT_TARGET}) - endif() -elseif(PLATFORM_INT STREQUAL "WATCHOSCOMBINED") - set(SDK_NAME watchos) - if(MODERN_CMAKE) - if(NOT ARCHS) - if (XCODE_VERSION_INT VERSION_GREATER 10.0) - set(ARCHS armv7k arm64_32 i386) - set(APPLE_TARGET_TRIPLE_INT arm64_32-i386-apple-watchos${DEPLOYMENT_TARGET}) - set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchos*] "armv7k arm64_32") - set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchsimulator*] "i386") - set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchos*] "armv7k arm64_32") - set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchsimulator*] "i386") - else() - set(ARCHS armv7k i386) - set(APPLE_TARGET_TRIPLE_INT arm-i386-apple-watchos${DEPLOYMENT_TARGET}) - set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchos*] "armv7k") - set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchsimulator*] "i386") - set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchos*] "armv7k") - set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchsimulator*] "i386") - endif() - else() - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos${DEPLOYMENT_TARGET}) - endif() - else() - message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the WATCHOSCOMBINED setting work") - endif() -elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS") - set(SDK_NAME watchsimulator) - if(NOT ARCHS) - set(ARCHS i386) - set(APPLE_TARGET_TRIPLE_INT i386-apple-watchos${DEPLOYMENT_TARGET}-simulator) - else() - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos${DEPLOYMENT_TARGET}-simulator) - endif() -elseif(PLATFORM_INT STREQUAL "SIMULATORARM64_WATCHOS") - set(SDK_NAME watchsimulator) - if(NOT ARCHS) - set(ARCHS arm64) - set(APPLE_TARGET_TRIPLE_INT arm64-apple-watchos${DEPLOYMENT_TARGET}-simulator) - else() - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos${DEPLOYMENT_TARGET}-simulator) - endif() -elseif(PLATFORM_INT STREQUAL "SIMULATOR_VISIONOS") - set(SDK_NAME xrsimulator) - if(NOT ARCHS) - set(ARCHS arm64) - set(APPLE_TARGET_TRIPLE_INT arm64-apple-xros${DEPLOYMENT_TARGET}-simulator) - else() - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-xros${DEPLOYMENT_TARGET}-simulator) - endif() -elseif(PLATFORM_INT STREQUAL "VISIONOS") - set(SDK_NAME xros) - if(NOT ARCHS) - set(ARCHS arm64) - set(APPLE_TARGET_TRIPLE_INT arm64-apple-xros${DEPLOYMENT_TARGET}) - else() - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-xros${DEPLOYMENT_TARGET}) - endif() -elseif(PLATFORM_INT STREQUAL "VISIONOSCOMBINED") - set(SDK_NAME xros) - if(MODERN_CMAKE) - if(NOT ARCHS) - set(ARCHS arm64) - set(APPLE_TARGET_TRIPLE_INT arm64-apple-xros${DEPLOYMENT_TARGET}) - set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=xros*] "arm64") - set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=xrsimulator*] "arm64") - else() - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-xros${DEPLOYMENT_TARGET}) - endif() - else() - message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the VISIONOSCOMBINED setting work") - endif() -elseif(PLATFORM_INT STREQUAL "MAC" OR PLATFORM_INT STREQUAL "MAC_CATALYST") - set(SDK_NAME macosx) - if(NOT ARCHS) - set(ARCHS x86_64) - endif() - string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}") - if(PLATFORM_INT STREQUAL "MAC") - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-macosx${DEPLOYMENT_TARGET}) - elseif(PLATFORM_INT STREQUAL "MAC_CATALYST") - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-macabi) - endif() -elseif(PLATFORM_INT MATCHES "^(MAC_ARM64)$|^(MAC_CATALYST_ARM64)$") - set(SDK_NAME macosx) - if(NOT ARCHS) - set(ARCHS arm64) - endif() - string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}") - if(PLATFORM_INT STREQUAL "MAC_ARM64") - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-macosx${DEPLOYMENT_TARGET}) - elseif(PLATFORM_INT STREQUAL "MAC_CATALYST_ARM64") - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-macabi) - endif() -elseif(PLATFORM_INT STREQUAL "MAC_UNIVERSAL") - set(SDK_NAME macosx) - if(NOT ARCHS) - set(ARCHS "x86_64;arm64") - endif() - string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}") - set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-macosx${DEPLOYMENT_TARGET}) -else() - message(FATAL_ERROR "Invalid PLATFORM: ${PLATFORM_INT}") -endif() - -string(REPLACE ";" " " ARCHS_SPACED "${ARCHS}") - -if(MODERN_CMAKE AND PLATFORM_INT MATCHES ".*COMBINED" AND NOT CMAKE_GENERATOR MATCHES "Xcode") - message(FATAL_ERROR "The COMBINED options only work with Xcode generator, -G Xcode") -endif() - -if(CMAKE_GENERATOR MATCHES "Xcode" AND PLATFORM_INT MATCHES "^MAC_CATALYST") - set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") - set(CMAKE_XCODE_ATTRIBUTE_SUPPORTED_PLATFORMS "macosx") - set(CMAKE_XCODE_ATTRIBUTE_SUPPORTS_MACCATALYST "YES") - if(NOT DEFINED MACOSX_DEPLOYMENT_TARGET) - set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "10.15") - else() - set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "${MACOSX_DEPLOYMENT_TARGET}") - endif() -elseif(CMAKE_GENERATOR MATCHES "Xcode") - set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") - set(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "${DEPLOYMENT_TARGET}") - if(NOT PLATFORM_INT MATCHES ".*COMBINED") - set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=${SDK_NAME}*] "${ARCHS_SPACED}") - set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=${SDK_NAME}*] "${ARCHS_SPACED}") - endif() -endif() - -# If the user did not specify the SDK root to use, then query xcodebuild for it. -if(DEFINED CMAKE_OSX_SYSROOT_INT) - # Environment variables are always preserved. - set(ENV{_CMAKE_OSX_SYSROOT_INT} "${CMAKE_OSX_SYSROOT_INT}") -elseif(DEFINED ENV{_CMAKE_OSX_SYSROOT_INT}) - set(CMAKE_OSX_SYSROOT_INT "$ENV{_CMAKE_OSX_SYSROOT_INT}") -elseif(NOT DEFINED CMAKE_OSX_SYSROOT_INT) - execute_process(COMMAND ${XCODEBUILD_EXECUTABLE} -version -sdk ${SDK_NAME} Path - OUTPUT_VARIABLE CMAKE_OSX_SYSROOT_INT - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) -endif() - -if (NOT DEFINED CMAKE_OSX_SYSROOT_INT AND NOT DEFINED CMAKE_OSX_SYSROOT) - message(SEND_ERROR "Please make sure that Xcode is installed and that the toolchain" - "is pointing to the correct path. Please run:" - "sudo xcode-select -s /Applications/Xcode.app/Contents/Developer" - "and see if that fixes the problem for you.") - message(FATAL_ERROR "Invalid CMAKE_OSX_SYSROOT: ${CMAKE_OSX_SYSROOT} " - "does not exist.") -elseif(DEFINED CMAKE_OSX_SYSROOT_INT) - set(CMAKE_OSX_SYSROOT_INT "${CMAKE_OSX_SYSROOT_INT}" CACHE INTERNAL "") - # Specify the location or name of the platform SDK to be used in CMAKE_OSX_SYSROOT. - set(CMAKE_OSX_SYSROOT "${CMAKE_OSX_SYSROOT_INT}" CACHE INTERNAL "") -endif() - -# Use bitcode or not -if(NOT DEFINED ENABLE_BITCODE) - message(STATUS "[DEFAULTS] Disabling bitcode support by default. ENABLE_BITCODE not provided for override!") - set(ENABLE_BITCODE OFF) -endif() -set(ENABLE_BITCODE_INT ${ENABLE_BITCODE} CACHE BOOL - "Whether or not to enable bitcode" FORCE) -# Use ARC or not -if(NOT DEFINED ENABLE_ARC) - # Unless specified, enable ARC support by default - set(ENABLE_ARC ON) - message(STATUS "[DEFAULTS] Enabling ARC support by default. ENABLE_ARC not provided!") -endif() -set(ENABLE_ARC_INT ${ENABLE_ARC} CACHE BOOL "Whether or not to enable ARC" FORCE) -# Use hidden visibility or not -if(NOT DEFINED ENABLE_VISIBILITY) - # Unless specified, disable symbols visibility by default - set(ENABLE_VISIBILITY OFF) - message(STATUS "[DEFAULTS] Hiding symbols visibility by default. ENABLE_VISIBILITY not provided!") -endif() -set(ENABLE_VISIBILITY_INT ${ENABLE_VISIBILITY} CACHE BOOL "Whether or not to hide symbols from the dynamic linker (-fvisibility=hidden)" FORCE) -# Set strict compiler checks or not -if(NOT DEFINED ENABLE_STRICT_TRY_COMPILE) - # Unless specified, disable strict try_compile() - set(ENABLE_STRICT_TRY_COMPILE OFF) - message(STATUS "[DEFAULTS] Using NON-strict compiler checks by default. ENABLE_STRICT_TRY_COMPILE not provided!") -endif() -set(ENABLE_STRICT_TRY_COMPILE_INT ${ENABLE_STRICT_TRY_COMPILE} CACHE BOOL - "Whether or not to use strict compiler checks" FORCE) - -# Get the SDK version information. -if(DEFINED SDK_VERSION) - # Environment variables are always preserved. - set(ENV{_SDK_VERSION} "${SDK_VERSION}") -elseif(DEFINED ENV{_SDK_VERSION}) - set(SDK_VERSION "$ENV{_SDK_VERSION}") -elseif(NOT DEFINED SDK_VERSION) - execute_process(COMMAND ${XCODEBUILD_EXECUTABLE} -sdk ${CMAKE_OSX_SYSROOT_INT} -version SDKVersion - OUTPUT_VARIABLE SDK_VERSION - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) -endif() - -# Find the Developer root for the specific iOS platform being compiled for -# from CMAKE_OSX_SYSROOT. Should be ../../ from SDK specified in -# CMAKE_OSX_SYSROOT. There does not appear to be a direct way to obtain -# this information from xcrun or xcodebuild. -if (NOT DEFINED CMAKE_DEVELOPER_ROOT AND NOT CMAKE_GENERATOR MATCHES "Xcode") - get_filename_component(PLATFORM_SDK_DIR ${CMAKE_OSX_SYSROOT_INT} PATH) - get_filename_component(CMAKE_DEVELOPER_ROOT ${PLATFORM_SDK_DIR} PATH) - if (NOT EXISTS "${CMAKE_DEVELOPER_ROOT}") - message(FATAL_ERROR "Invalid CMAKE_DEVELOPER_ROOT: ${CMAKE_DEVELOPER_ROOT} does not exist.") - endif() -endif() - -# Find the C & C++ compilers for the specified SDK. -if(DEFINED CMAKE_C_COMPILER) - # Environment variables are always preserved. - set(ENV{_CMAKE_C_COMPILER} "${CMAKE_C_COMPILER}") -elseif(DEFINED ENV{_CMAKE_C_COMPILER}) - set(CMAKE_C_COMPILER "$ENV{_CMAKE_C_COMPILER}") - set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) -elseif(NOT DEFINED CMAKE_C_COMPILER) - execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT_INT} -find clang - OUTPUT_VARIABLE CMAKE_C_COMPILER - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) -endif() -if(DEFINED CMAKE_CXX_COMPILER) - # Environment variables are always preserved. - set(ENV{_CMAKE_CXX_COMPILER} "${CMAKE_CXX_COMPILER}") -elseif(DEFINED ENV{_CMAKE_CXX_COMPILER}) - set(CMAKE_CXX_COMPILER "$ENV{_CMAKE_CXX_COMPILER}") -elseif(NOT DEFINED CMAKE_CXX_COMPILER) - execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT_INT} -find clang++ - OUTPUT_VARIABLE CMAKE_CXX_COMPILER - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) -endif() -# Find (Apple's) libtool. -if(DEFINED BUILD_LIBTOOL) - # Environment variables are always preserved. - set(ENV{_BUILD_LIBTOOL} "${BUILD_LIBTOOL}") -elseif(DEFINED ENV{_BUILD_LIBTOOL}) - set(BUILD_LIBTOOL "$ENV{_BUILD_LIBTOOL}") -elseif(NOT DEFINED BUILD_LIBTOOL) - execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT_INT} -find libtool - OUTPUT_VARIABLE BUILD_LIBTOOL - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) -endif() -# Find the toolchain's provided install_name_tool if none is found on the host -if(DEFINED CMAKE_INSTALL_NAME_TOOL) - # Environment variables are always preserved. - set(ENV{_CMAKE_INSTALL_NAME_TOOL} "${CMAKE_INSTALL_NAME_TOOL}") -elseif(DEFINED ENV{_CMAKE_INSTALL_NAME_TOOL}) - set(CMAKE_INSTALL_NAME_TOOL "$ENV{_CMAKE_INSTALL_NAME_TOOL}") -elseif(NOT DEFINED CMAKE_INSTALL_NAME_TOOL) - execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT_INT} -find install_name_tool - OUTPUT_VARIABLE CMAKE_INSTALL_NAME_TOOL_INT - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - set(CMAKE_INSTALL_NAME_TOOL ${CMAKE_INSTALL_NAME_TOOL_INT} CACHE INTERNAL "") -endif() - -# Configure libtool to be used instead of ar + ranlib to build static libraries. -# This is required on Xcode 7+, but should also work on previous versions of -# Xcode. -get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES) -foreach(lang ${languages}) - set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "${BUILD_LIBTOOL} -static -o " CACHE INTERNAL "") -endforeach() - -# CMake 3.14+ support building for iOS, watchOS, and tvOS out of the box. -if(MODERN_CMAKE) - if(SDK_NAME MATCHES "iphone") - set(CMAKE_SYSTEM_NAME iOS) - elseif(SDK_NAME MATCHES "xros") - set(CMAKE_SYSTEM_NAME visionOS) - elseif(SDK_NAME MATCHES "xrsimulator") - set(CMAKE_SYSTEM_NAME visionOS) - elseif(SDK_NAME MATCHES "macosx") - set(CMAKE_SYSTEM_NAME Darwin) - elseif(SDK_NAME MATCHES "appletv") - set(CMAKE_SYSTEM_NAME tvOS) - elseif(SDK_NAME MATCHES "watch") - set(CMAKE_SYSTEM_NAME watchOS) - endif() - # Provide flags for a combined FAT library build on newer CMake versions - if(PLATFORM_INT MATCHES ".*COMBINED") - set(CMAKE_IOS_INSTALL_COMBINED YES) - if(CMAKE_GENERATOR MATCHES "Xcode") - # Set the SDKROOT Xcode properties to a Xcode-friendly value (the SDK_NAME, E.g, iphoneos) - # This way, Xcode will automatically switch between the simulator and device SDK when building. - set(CMAKE_XCODE_ATTRIBUTE_SDKROOT "${SDK_NAME}") - # Force to not build just one ARCH, but all! - set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH "NO") - endif() - endif() -elseif(NOT DEFINED CMAKE_SYSTEM_NAME AND ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.10") - # Legacy code path prior to CMake 3.14 or fallback if no CMAKE_SYSTEM_NAME specified - set(CMAKE_SYSTEM_NAME iOS) -elseif(NOT DEFINED CMAKE_SYSTEM_NAME) - # Legacy code path before CMake 3.14 or fallback if no CMAKE_SYSTEM_NAME specified - set(CMAKE_SYSTEM_NAME Darwin) -endif() -# Standard settings. -set(CMAKE_SYSTEM_VERSION ${SDK_VERSION} CACHE INTERNAL "") -set(UNIX ON CACHE BOOL "") -set(APPLE ON CACHE BOOL "") -if(PLATFORM STREQUAL "MAC" OR PLATFORM STREQUAL "MAC_ARM64" OR PLATFORM STREQUAL "MAC_UNIVERSAL") - set(IOS OFF CACHE BOOL "") - set(MACOS ON CACHE BOOL "") -elseif(PLATFORM STREQUAL "MAC_CATALYST" OR PLATFORM STREQUAL "MAC_CATALYST_ARM64") - set(IOS ON CACHE BOOL "") - set(MACOS ON CACHE BOOL "") -elseif(PLATFORM STREQUAL "VISIONOS" OR PLATFORM STREQUAL "SIMULATOR_VISIONOS" OR PLATFORM STREQUAL "VISIONOSCOMBINED") - set(IOS OFF CACHE BOOL "") - set(VISIONOS ON CACHE BOOL "") -else() - set(IOS ON CACHE BOOL "") -endif() -# Set the architectures for which to build. -set(CMAKE_OSX_ARCHITECTURES ${ARCHS} CACHE INTERNAL "") -# Change the type of target generated for try_compile() so it'll work when cross-compiling, weak compiler checks -if(NOT ENABLE_STRICT_TRY_COMPILE_INT) - set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) -endif() -# All iOS/Darwin specific settings - some may be redundant. -if (NOT DEFINED CMAKE_MACOSX_BUNDLE) - set(CMAKE_MACOSX_BUNDLE YES) -endif() -set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") -set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") -set(CMAKE_SHARED_LIBRARY_PREFIX "lib") -set(CMAKE_SHARED_LIBRARY_SUFFIX ".dylib") -set(CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES ".tbd" ".so") -set(CMAKE_SHARED_MODULE_PREFIX "lib") -set(CMAKE_SHARED_MODULE_SUFFIX ".so") -set(CMAKE_C_COMPILER_ABI ELF) -set(CMAKE_CXX_COMPILER_ABI ELF) -set(CMAKE_C_HAS_ISYSROOT 1) -set(CMAKE_CXX_HAS_ISYSROOT 1) -set(CMAKE_MODULE_EXISTS 1) -set(CMAKE_DL_LIBS "") -set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ") -set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ") -set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}") -set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}") - -if(ARCHS MATCHES "((^|;|, )(arm64|arm64e|x86_64))+") - set(CMAKE_C_SIZEOF_DATA_PTR 8) - set(CMAKE_CXX_SIZEOF_DATA_PTR 8) - if(ARCHS MATCHES "((^|;|, )(arm64|arm64e))+") - set(CMAKE_SYSTEM_PROCESSOR "aarch64") - else() - set(CMAKE_SYSTEM_PROCESSOR "x86_64") - endif() -else() - set(CMAKE_C_SIZEOF_DATA_PTR 4) - set(CMAKE_CXX_SIZEOF_DATA_PTR 4) - set(CMAKE_SYSTEM_PROCESSOR "arm") -endif() - -# Note that only Xcode 7+ supports the newer more specific: -# -m${SDK_NAME}-version-min flags, older versions of Xcode use: -# -m(ios/ios-simulator)-version-min instead. -if(${CMAKE_VERSION} VERSION_LESS "3.11") - if(PLATFORM_INT STREQUAL "OS" OR PLATFORM_INT STREQUAL "OS64") - if(XCODE_VERSION_INT VERSION_LESS 7.0) - set(SDK_NAME_VERSION_FLAGS - "-mios-version-min=${DEPLOYMENT_TARGET}") - else() - # Xcode 7.0+ uses flags we can build directly from SDK_NAME. - set(SDK_NAME_VERSION_FLAGS - "-m${SDK_NAME}-version-min=${DEPLOYMENT_TARGET}") - endif() - elseif(PLATFORM_INT STREQUAL "TVOS") - set(SDK_NAME_VERSION_FLAGS - "-mtvos-version-min=${DEPLOYMENT_TARGET}") - elseif(PLATFORM_INT STREQUAL "SIMULATOR_TVOS") - set(SDK_NAME_VERSION_FLAGS - "-mtvos-simulator-version-min=${DEPLOYMENT_TARGET}") -elseif(PLATFORM_INT STREQUAL "SIMULATORARM64_TVOS") - set(SDK_NAME_VERSION_FLAGS - "-mtvos-simulator-version-min=${DEPLOYMENT_TARGET}") - elseif(PLATFORM_INT STREQUAL "WATCHOS") - set(SDK_NAME_VERSION_FLAGS - "-mwatchos-version-min=${DEPLOYMENT_TARGET}") - elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS") - set(SDK_NAME_VERSION_FLAGS - "-mwatchos-simulator-version-min=${DEPLOYMENT_TARGET}") - elseif(PLATFORM_INT STREQUAL "SIMULATORARM64_WATCHOS") - set(SDK_NAME_VERSION_FLAGS - "-mwatchos-simulator-version-min=${DEPLOYMENT_TARGET}") - elseif(PLATFORM_INT STREQUAL "MAC") - set(SDK_NAME_VERSION_FLAGS - "-mmacosx-version-min=${DEPLOYMENT_TARGET}") - else() - # SIMULATOR or SIMULATOR64 both use -mios-simulator-version-min. - set(SDK_NAME_VERSION_FLAGS - "-mios-simulator-version-min=${DEPLOYMENT_TARGET}") - endif() -elseif(NOT PLATFORM_INT MATCHES "^MAC_CATALYST") - # Newer versions of CMake sets the version min flags correctly, skip this for Mac Catalyst targets - set(CMAKE_OSX_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET} CACHE INTERNAL "Minimum OS X deployment version") -endif() - -if(DEFINED APPLE_TARGET_TRIPLE_INT) - set(APPLE_TARGET_TRIPLE ${APPLE_TARGET_TRIPLE_INT} CACHE INTERNAL "") - set(CMAKE_C_COMPILER_TARGET ${APPLE_TARGET_TRIPLE}) - set(CMAKE_CXX_COMPILER_TARGET ${APPLE_TARGET_TRIPLE}) - set(CMAKE_ASM_COMPILER_TARGET ${APPLE_TARGET_TRIPLE}) -endif() - -if(PLATFORM_INT MATCHES "^MAC_CATALYST") - set(C_TARGET_FLAGS "-isystem ${CMAKE_OSX_SYSROOT_INT}/System/iOSSupport/usr/include -iframework ${CMAKE_OSX_SYSROOT_INT}/System/iOSSupport/System/Library/Frameworks") -endif() - -if(ENABLE_BITCODE_INT) - set(BITCODE "-fembed-bitcode") - set(CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE "bitcode") - set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") -else() - set(BITCODE "") - set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") -endif() - -if(ENABLE_ARC_INT) - set(FOBJC_ARC "-fobjc-arc") - set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "YES") -else() - set(FOBJC_ARC "-fno-objc-arc") - set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "NO") -endif() - -if(NAMED_LANGUAGE_SUPPORT_INT) - set(OBJC_VARS "-fobjc-abi-version=2 -DOBJC_OLD_DISPATCH_PROTOTYPES=0") - set(OBJC_LEGACY_VARS "") -else() - set(OBJC_VARS "") - set(OBJC_LEGACY_VARS "-fobjc-abi-version=2 -DOBJC_OLD_DISPATCH_PROTOTYPES=0") -endif() - -if(NOT ENABLE_VISIBILITY_INT) - foreach(lang ${languages}) - set(CMAKE_${lang}_VISIBILITY_PRESET "hidden" CACHE INTERNAL "") - endforeach() - set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN "YES") - set(VISIBILITY "-fvisibility=hidden -fvisibility-inlines-hidden") -else() - foreach(lang ${languages}) - set(CMAKE_${lang}_VISIBILITY_PRESET "default" CACHE INTERNAL "") - endforeach() - set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN "NO") - set(VISIBILITY "-fvisibility=default") -endif() - -if(DEFINED APPLE_TARGET_TRIPLE) - set(APPLE_TARGET_TRIPLE_FLAG "-target ${APPLE_TARGET_TRIPLE}") -endif() - -#Check if Xcode generator is used since that will handle these flags automagically -if(CMAKE_GENERATOR MATCHES "Xcode") - message(STATUS "Not setting any manual command-line buildflags, since Xcode is selected as the generator. Modifying the Xcode build-settings directly instead.") -else() - set(CMAKE_C_FLAGS "${C_TARGET_FLAGS} ${APPLE_TARGET_TRIPLE_FLAG} ${SDK_NAME_VERSION_FLAGS} ${OBJC_LEGACY_VARS} ${BITCODE} ${VISIBILITY} ${CMAKE_C_FLAGS}" CACHE INTERNAL - "Flags used by the compiler during all C build types.") - set(CMAKE_C_FLAGS_DEBUG "-O0 -g ${CMAKE_C_FLAGS_DEBUG}") - set(CMAKE_C_FLAGS_MINSIZEREL "-DNDEBUG -Os ${CMAKE_C_FLAGS_MINSIZEREL}") - set(CMAKE_C_FLAGS_RELWITHDEBINFO "-DNDEBUG -O2 -g ${CMAKE_C_FLAGS_RELWITHDEBINFO}") - set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O3 ${CMAKE_C_FLAGS_RELEASE}") - set(CMAKE_CXX_FLAGS "${C_TARGET_FLAGS} ${APPLE_TARGET_TRIPLE_FLAG} ${SDK_NAME_VERSION_FLAGS} ${OBJC_LEGACY_VARS} ${BITCODE} ${VISIBILITY} ${CMAKE_CXX_FLAGS}" CACHE INTERNAL - "Flags used by the compiler during all CXX build types.") - set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g ${CMAKE_CXX_FLAGS_DEBUG}") - set(CMAKE_CXX_FLAGS_MINSIZEREL "-DNDEBUG -Os ${CMAKE_CXX_FLAGS_MINSIZEREL}") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-DNDEBUG -O2 -g ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") - set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3 ${CMAKE_CXX_FLAGS_RELEASE}") - if(NAMED_LANGUAGE_SUPPORT_INT) - set(CMAKE_OBJC_FLAGS "${C_TARGET_FLAGS} ${APPLE_TARGET_TRIPLE_FLAG} ${SDK_NAME_VERSION_FLAGS} ${BITCODE} ${VISIBILITY} ${FOBJC_ARC} ${OBJC_VARS} ${CMAKE_OBJC_FLAGS}" CACHE INTERNAL - "Flags used by the compiler during all OBJC build types.") - set(CMAKE_OBJC_FLAGS_DEBUG "-O0 -g ${CMAKE_OBJC_FLAGS_DEBUG}") - set(CMAKE_OBJC_FLAGS_MINSIZEREL "-DNDEBUG -Os ${CMAKE_OBJC_FLAGS_MINSIZEREL}") - set(CMAKE_OBJC_FLAGS_RELWITHDEBINFO "-DNDEBUG -O2 -g ${CMAKE_OBJC_FLAGS_RELWITHDEBINFO}") - set(CMAKE_OBJC_FLAGS_RELEASE "-DNDEBUG -O3 ${CMAKE_OBJC_FLAGS_RELEASE}") - set(CMAKE_OBJCXX_FLAGS "${C_TARGET_FLAGS} ${APPLE_TARGET_TRIPLE_FLAG} ${SDK_NAME_VERSION_FLAGS} ${BITCODE} ${VISIBILITY} ${FOBJC_ARC} ${OBJC_VARS} ${CMAKE_OBJCXX_FLAGS}" CACHE INTERNAL - "Flags used by the compiler during all OBJCXX build types.") - set(CMAKE_OBJCXX_FLAGS_DEBUG "-O0 -g ${CMAKE_OBJCXX_FLAGS_DEBUG}") - set(CMAKE_OBJCXX_FLAGS_MINSIZEREL "-DNDEBUG -Os ${CMAKE_OBJCXX_FLAGS_MINSIZEREL}") - set(CMAKE_OBJCXX_FLAGS_RELWITHDEBINFO "-DNDEBUG -O2 -g ${CMAKE_OBJCXX_FLAGS_RELWITHDEBINFO}") - set(CMAKE_OBJCXX_FLAGS_RELEASE "-DNDEBUG -O3 ${CMAKE_OBJCXX_FLAGS_RELEASE}") - endif() - set(CMAKE_C_LINK_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}" CACHE INTERNAL - "Flags used by the compiler for all C link types.") - set(CMAKE_CXX_LINK_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}" CACHE INTERNAL - "Flags used by the compiler for all CXX link types.") - if(NAMED_LANGUAGE_SUPPORT_INT) - set(CMAKE_OBJC_LINK_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_OBJC_LINK_FLAGS}" CACHE INTERNAL - "Flags used by the compiler for all OBJC link types.") - set(CMAKE_OBJCXX_LINK_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_OBJCXX_LINK_FLAGS}" CACHE INTERNAL - "Flags used by the compiler for all OBJCXX link types.") - endif() - set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS} -x assembler-with-cpp -arch ${CMAKE_OSX_ARCHITECTURES} ${APPLE_TARGET_TRIPLE_FLAG}" CACHE INTERNAL - "Flags used by the compiler for all ASM build types.") -endif() - -## Print status messages to inform of the current state -message(STATUS "Configuring ${SDK_NAME} build for platform: ${PLATFORM_INT}, architecture(s): ${ARCHS}") -message(STATUS "Using SDK: ${CMAKE_OSX_SYSROOT_INT}") -message(STATUS "Using C compiler: ${CMAKE_C_COMPILER}") -message(STATUS "Using CXX compiler: ${CMAKE_CXX_COMPILER}") -message(STATUS "Using libtool: ${BUILD_LIBTOOL}") -message(STATUS "Using install name tool: ${CMAKE_INSTALL_NAME_TOOL}") -if(DEFINED APPLE_TARGET_TRIPLE) - message(STATUS "Autoconf target triple: ${APPLE_TARGET_TRIPLE}") -endif() -message(STATUS "Using minimum deployment version: ${DEPLOYMENT_TARGET}" - " (SDK version: ${SDK_VERSION})") -if(MODERN_CMAKE) - message(STATUS "Merging integrated CMake 3.14+ iOS,tvOS,watchOS,macOS toolchain(s) with this toolchain!") - if(PLATFORM_INT MATCHES ".*COMBINED") - message(STATUS "Will combine built (static) artifacts into FAT lib...") - endif() -endif() -if(CMAKE_GENERATOR MATCHES "Xcode") - message(STATUS "Using Xcode version: ${XCODE_VERSION_INT}") -endif() -message(STATUS "CMake version: ${CMAKE_VERSION}") -if(DEFINED SDK_NAME_VERSION_FLAGS) - message(STATUS "Using version flags: ${SDK_NAME_VERSION_FLAGS}") -endif() -message(STATUS "Using a data_ptr size of: ${CMAKE_CXX_SIZEOF_DATA_PTR}") -if(ENABLE_BITCODE_INT) - message(STATUS "Bitcode: Enabled") -else() - message(STATUS "Bitcode: Disabled") -endif() - -if(ENABLE_ARC_INT) - message(STATUS "ARC: Enabled") -else() - message(STATUS "ARC: Disabled") -endif() - -if(ENABLE_VISIBILITY_INT) - message(STATUS "Hiding symbols: Disabled") -else() - message(STATUS "Hiding symbols: Enabled") -endif() - -# Set global properties -set_property(GLOBAL PROPERTY PLATFORM "${PLATFORM}") -set_property(GLOBAL PROPERTY APPLE_TARGET_TRIPLE "${APPLE_TARGET_TRIPLE_INT}") -set_property(GLOBAL PROPERTY SDK_VERSION "${SDK_VERSION}") -set_property(GLOBAL PROPERTY XCODE_VERSION "${XCODE_VERSION_INT}") -set_property(GLOBAL PROPERTY OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}") - -# Export configurable variables for the try_compile() command. -set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES - PLATFORM - XCODE_VERSION_INT - SDK_VERSION - NAMED_LANGUAGE_SUPPORT - DEPLOYMENT_TARGET - CMAKE_DEVELOPER_ROOT - CMAKE_OSX_SYSROOT_INT - ENABLE_BITCODE - ENABLE_ARC - CMAKE_ASM_COMPILER - CMAKE_C_COMPILER - CMAKE_C_COMPILER_TARGET - CMAKE_CXX_COMPILER - CMAKE_CXX_COMPILER_TARGET - BUILD_LIBTOOL - CMAKE_INSTALL_NAME_TOOL - CMAKE_C_FLAGS - CMAKE_C_DEBUG - CMAKE_C_MINSIZEREL - CMAKE_C_RELWITHDEBINFO - CMAKE_C_RELEASE - CMAKE_CXX_FLAGS - CMAKE_CXX_FLAGS_DEBUG - CMAKE_CXX_FLAGS_MINSIZEREL - CMAKE_CXX_FLAGS_RELWITHDEBINFO - CMAKE_CXX_FLAGS_RELEASE - CMAKE_C_LINK_FLAGS - CMAKE_CXX_LINK_FLAGS - CMAKE_ASM_FLAGS -) - -if(NAMED_LANGUAGE_SUPPORT_INT) - list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES - CMAKE_OBJC_FLAGS - CMAKE_OBJC_DEBUG - CMAKE_OBJC_MINSIZEREL - CMAKE_OBJC_RELWITHDEBINFO - CMAKE_OBJC_RELEASE - CMAKE_OBJCXX_FLAGS - CMAKE_OBJCXX_DEBUG - CMAKE_OBJCXX_MINSIZEREL - CMAKE_OBJCXX_RELWITHDEBINFO - CMAKE_OBJCXX_RELEASE - CMAKE_OBJC_LINK_FLAGS - CMAKE_OBJCXX_LINK_FLAGS - ) -endif() - -set(CMAKE_PLATFORM_HAS_INSTALLNAME 1) -set(CMAKE_SHARED_LINKER_FLAGS "-rpath @executable_path/Frameworks -rpath @loader_path/Frameworks") -set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names") -set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -Wl,-headerpad_max_install_names") -set(CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,") -set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,") -set(CMAKE_FIND_LIBRARY_SUFFIXES ".tbd" ".dylib" ".so" ".a") -set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name") - -# Set the find root to the SDK developer roots. -# Note: CMAKE_FIND_ROOT_PATH is only useful when cross-compiling. Thus, do not set on macOS builds. -if(NOT PLATFORM_INT MATCHES "^MAC.*$") - list(APPEND CMAKE_FIND_ROOT_PATH "${CMAKE_OSX_SYSROOT_INT}" CACHE INTERNAL "") - set(CMAKE_IGNORE_PATH "/System/Library/Frameworks;/usr/local/lib;/opt/homebrew" CACHE INTERNAL "") -endif() - -# Default to searching for frameworks first. -IF(NOT DEFINED CMAKE_FIND_FRAMEWORK) - set(CMAKE_FIND_FRAMEWORK FIRST) -ENDIF(NOT DEFINED CMAKE_FIND_FRAMEWORK) - -# Set up the default search directories for frameworks. -if(PLATFORM_INT MATCHES "^MAC_CATALYST") - set(CMAKE_FRAMEWORK_PATH - ${CMAKE_DEVELOPER_ROOT}/Library/PrivateFrameworks - ${CMAKE_OSX_SYSROOT_INT}/System/Library/Frameworks - ${CMAKE_OSX_SYSROOT_INT}/System/iOSSupport/System/Library/Frameworks - ${CMAKE_FRAMEWORK_PATH} CACHE INTERNAL "") -else() - set(CMAKE_FRAMEWORK_PATH - ${CMAKE_DEVELOPER_ROOT}/Library/PrivateFrameworks - ${CMAKE_OSX_SYSROOT_INT}/System/Library/Frameworks - ${CMAKE_FRAMEWORK_PATH} CACHE INTERNAL "") -endif() - -# By default, search both the specified iOS SDK and the remainder of the host filesystem. -if(NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM) - set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH CACHE INTERNAL "") -endif() -if(NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY) - set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH CACHE INTERNAL "") -endif() -if(NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE) - set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH CACHE INTERNAL "") -endif() -if(NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE) - set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH CACHE INTERNAL "") -endif() - -# -# Some helper-macros below to simplify and beautify the CMakeFile -# - -# This little macro lets you set any Xcode specific property. -macro(set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE XCODE_RELVERSION) - set(XCODE_RELVERSION_I "${XCODE_RELVERSION}") - if(XCODE_RELVERSION_I STREQUAL "All") - set_property(TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} "${XCODE_VALUE}") - else() - set_property(TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY}[variant=${XCODE_RELVERSION_I}] "${XCODE_VALUE}") - endif() -endmacro(set_xcode_property) - -# This macro lets you find executable programs on the host system. -macro(find_host_package) - set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) - set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER) - set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER) - set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER) - set(_TOOLCHAIN_IOS ${IOS}) - set(IOS OFF) - find_package(${ARGN}) - set(IOS ${_TOOLCHAIN_IOS}) - set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) - set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) - set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) - set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH) -endmacro(find_host_package) From 0286b21c66fac340013fab2db0752470e1dced65 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Tue, 27 Aug 2024 09:54:47 +0800 Subject: [PATCH 12/41] fix --- .github/workflows/android.yml | 4 ++-- .github/workflows/linux.yml | 4 ++-- .github/workflows/windows.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 72e7384..7370a6a 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -3,8 +3,8 @@ on: push: tags: - '*' - # pull_request: - # branches: ["main"] + pull_request: + branches: ["main"] permissions: contents: read diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index c660be4..012ce9b 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -3,8 +3,8 @@ on: push: tags: - '*' - # pull_request: - # branches: ["main"] + pull_request: + branches: ["main"] permissions: contents: read diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 1afff9a..fe68a19 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -3,8 +3,8 @@ on: push: tags: - '*' - # pull_request: - # branches: ["main"] + pull_request: + branches: ["main"] permissions: contents: read From 76a82f8e7a9c9fe72ae1fb246b427b398b8053b8 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Tue, 27 Aug 2024 11:00:21 +0800 Subject: [PATCH 13/41] fix --- .github/workflows/android.yml | 68 ++++++++++++----------------------- .github/workflows/apple.yml | 4 +-- .github/workflows/linux.yml | 4 +-- .github/workflows/wasm.yml | 4 +-- .github/workflows/windows.yml | 4 +-- 5 files changed, 31 insertions(+), 53 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 7370a6a..9f3f7c8 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -15,6 +15,7 @@ jobs: strategy: matrix: opencv-version: [4.10.0] + abi: [armeabi-v7a, arm64-v8a, x86_64] env: COMMON_CMAKE_OPTIONS: | -DCMAKE_POLICY_DEFAULT_CMP0057=NEW \ @@ -24,67 +25,36 @@ jobs: -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ -DANDROID_STL=c++_static \ - -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ + -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib/modules" \ steps: - uses: actions/checkout@v4 - name: ndk-fix-debug run: sed -i -e '/^ -g$/d' $ANDROID_NDK_LATEST_HOME/build/cmake/android-legacy.toolchain.cmake - name: setup-opencv-source run: | - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} - echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-android" >> $GITHUB_ENV - - name: build-armeabi-v7a + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib + echo "SOURCE_DIR=opencv" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-android-${{ matrix.abi }}" >> $GITHUB_ENV + - name: build run: | cd ${{ env.SOURCE_DIR }} - mkdir build-armeabi-v7a && cd build-armeabi-v7a - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="armeabi-v7a" -DANDROID_ARM_NEON=ON \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. - cmake --build . -j $(nproc) - cmake --build . --target install - - name: build-arm64-v8a - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-arm64-v8a && cd build-arm64-v8a - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="arm64-v8a" \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON -DOPENCV_EXTRA_FLAGS="-mno-outline-atomics" .. - cmake --build . -j $(nproc) - cmake --build . --target install - - name: build-x86_64 - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-x86_64 && cd build-x86_64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="x86_64" \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="${{ matrix.abi }}" -DANDROID_ARM_NEON=ON \ + `cat ../../options.txt` -DBUILD_opencv_world=OFF .. cmake --build . -j $(nproc) cmake --build . --target install + - name: package run: | mkdir ${{ env.PACKAGE_NAME }} - cp -rf ${{ env.SOURCE_DIR }}/build-x86_64/install/* ${{ env.PACKAGE_NAME }}/ - cp -rf ${{ env.SOURCE_DIR }}/build-armeabi-v7a/install/* ${{ env.PACKAGE_NAME }}/ - cp -rf ${{ env.SOURCE_DIR }}/build-arm64-v8a/install/* ${{ env.PACKAGE_NAME }}/ + cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ zip -9 -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} - - name: test-armeabi-v7a + - name: test run: | cd test - mkdir build-armeabi-v7a && cd build-armeabi-v7a - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="armeabi-v7a" -DANDROID_ARM_NEON=ON \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/sdk/native/jni .. - cmake --build . -j $(nproc) - - name: test-arm64-v8a - run: | - cd test - mkdir build-arm64-v8a && cd build-arm64-v8a - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="arm64-v8a" \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/sdk/native/jni .. - cmake --build . -j $(nproc) - - name: test-x86_64 - run: | - cd test - mkdir build-x86_64 && cd build-x86_64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="x86_64" \ + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="${{ matrix.abi }}" -DANDROID_ARM_NEON=ON \ -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/sdk/native/jni .. cmake --build . -j $(nproc) - name: upload @@ -103,6 +73,14 @@ jobs: uses: actions/download-artifact@v4 with: path: artifacts + - name: package + run: | + cd artifacts + mkdir opencv-android + for f in *.zip; do + unzip -o $f -d opencv-android + done + tree -L 3 opencv-android - name: create-release uses: softprops/action-gh-release@v2 diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml index ad2c3dd..8ee0f88 100644 --- a/.github/workflows/apple.yml +++ b/.github/workflows/apple.yml @@ -4,8 +4,8 @@ on: push: tags: - '*' - pull_request: - branches: ["main"] + # pull_request: + # branches: ["main"] env: DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 012ce9b..c660be4 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -3,8 +3,8 @@ on: push: tags: - '*' - pull_request: - branches: ["main"] + # pull_request: + # branches: ["main"] permissions: contents: read diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 6aa2bb1..610bc28 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -4,8 +4,8 @@ on: push: tags: - '*' - pull_request: - branches: ["main"] + # pull_request: + # branches: ["main"] env: EMSCRIPTEN_VERSION: 3.1.28 diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index fe68a19..1afff9a 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -3,8 +3,8 @@ on: push: tags: - '*' - pull_request: - branches: ["main"] + # pull_request: + # branches: ["main"] permissions: contents: read From 02cb2e4773732d8534112b3d1770c96f28c58a44 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Tue, 27 Aug 2024 11:19:24 +0800 Subject: [PATCH 14/41] fix --- .github/workflows/android.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 9f3f7c8..21b5840 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -75,12 +75,12 @@ jobs: path: artifacts - name: package run: | + tree -L 3 artifacts cd artifacts mkdir opencv-android - for f in *.zip; do + for f in */*.zip; do unzip -o $f -d opencv-android done - tree -L 3 opencv-android - name: create-release uses: softprops/action-gh-release@v2 From 3acb171b36df565087d5bb1703d15a1accd84277 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Fri, 20 Sep 2024 21:05:24 +0800 Subject: [PATCH 15/41] save --- .github/workflows/windows.yml | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 1afff9a..8473ab4 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -16,18 +16,18 @@ jobs: opencv-version: [4.10.0] os-compiler: - { msvc-version: vs2019, windows-version: 2019, toolset-version: v142 } - - { msvc-version: vs2022, windows-version: 2022, toolset-version: v143 } + # - { msvc-version: vs2022, windows-version: 2022, toolset-version: v143 } runs-on: windows-${{ matrix.os-compiler.windows-version }} env: UseMultiToolTask: true - COMMON_CMAKE_OPTIONS: -T ${{ matrix.os-compiler.toolset-version }},host=x64 -DCMAKE_INSTALL_PREFIX=install -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" + COMMON_CMAKE_OPTIONS: -T ${{ matrix.os-compiler.toolset-version }},host=x64 -DCMAKE_INSTALL_PREFIX=install -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib/modules" steps: - uses: actions/checkout@v4 - name: setup-opencv-source run: | - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} - echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $env:GITHUB_ENV + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib + echo "SOURCE_DIR=opencv" >> $env:GITHUB_ENV echo "PACKAGE_NAME=opencv-windows-${{ matrix.os-compiler.msvc-version }}" >> $env:GITHUB_ENV - name: build-x64 run: | @@ -44,13 +44,6 @@ jobs: cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A arm64 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=ARM64 $(type ../../options.txt) -DBUILD_opencv_world=OFF .. cmake --build . --config Release -j 4 cmake --build . --config Release --target install - - name: package - if: matrix.os-compiler.msvc-version == 'vs2015' || matrix.os-compiler.msvc-version == 'vs2017' - run: | - mkdir ${{ env.PACKAGE_NAME }} - mkdir ${{ env.PACKAGE_NAME }}/x64 - Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-x64\install\*" -Destination "${{ env.PACKAGE_NAME }}\x64" - 7z a -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} - name: package if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' run: | From 33ad2374998f9b4cbb932f4e247acb9268f42509 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Mon, 23 Sep 2024 11:44:35 +0800 Subject: [PATCH 16/41] fix workflow --- .github/workflows/android.yml | 107 +++++-------- .github/workflows/apple.yml | 280 ++++++++++++++++++---------------- .github/workflows/linux.yml | 225 ++++++++++++++------------- .github/workflows/windows.yml | 86 +++++------ 4 files changed, 351 insertions(+), 347 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 21b5840..b7e4948 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -2,13 +2,10 @@ name: android on: push: tags: - - '*' + - "*" pull_request: branches: ["main"] -permissions: - contents: read - jobs: android: runs-on: ubuntu-latest @@ -27,66 +24,44 @@ jobs: -DANDROID_STL=c++_static \ -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib/modules" \ steps: - - uses: actions/checkout@v4 - - name: ndk-fix-debug - run: sed -i -e '/^ -g$/d' $ANDROID_NDK_LATEST_HOME/build/cmake/android-legacy.toolchain.cmake - - name: setup-opencv-source - run: | - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=opencv" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-android-${{ matrix.abi }}" >> $GITHUB_ENV - - name: build - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="${{ matrix.abi }}" -DANDROID_ARM_NEON=ON \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF .. - cmake --build . -j $(nproc) - cmake --build . --target install - - - name: package - run: | - mkdir ${{ env.PACKAGE_NAME }} - cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ - zip -9 -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} - - name: test - run: | - cd test - mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="${{ matrix.abi }}" -DANDROID_ARM_NEON=ON \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/sdk/native/jni .. - cmake --build . -j $(nproc) - - name: upload - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PACKAGE_NAME }} - path: ${{ env.PACKAGE_NAME }}.zip - - release: - permissions: - contents: write # for softprops/action-gh-release to create a release - needs: [android] - runs-on: ubuntu-latest - steps: - - name: download - uses: actions/download-artifact@v4 - with: - path: artifacts - - name: package - run: | - tree -L 3 artifacts - cd artifacts - mkdir opencv-android - for f in */*.zip; do - unzip -o $f -d opencv-android - done + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib + echo "SOURCE_DIR=opencv" >> $GITHUB_ENV + echo "PACKAGE_NAME=libopencv-android-${{ matrix.abi }}" >> $GITHUB_ENV + - name: build + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="${{ matrix.abi }}" -DANDROID_ARM_NEON=ON \ + `cat ../../options.txt` -DBUILD_opencv_world=OFF .. + cmake --build . -j $(nproc) + cmake --build . --target install - - name: create-release - uses: softprops/action-gh-release@v2 - if: startsWith(github.ref, 'refs/tags/') - with: - draft: true - prerelease: false - token: ${{ secrets.GITHUB_TOKEN }} - files: artifacts/*/*.zip + - name: package + run: | + mkdir -p ${{ env.PACKAGE_NAME }}/ + cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ + tar -zcvf ${{ env.PACKAGE_NAME }}.tar.gz ${{ env.PACKAGE_NAME }} + - name: test + run: | + cd test + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="${{ matrix.abi }}" -DANDROID_ARM_NEON=ON \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/sdk/native/jni .. + cmake --build . -j $(nproc) + - name: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.tar.gz + - name: release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: true + prerelease: false + files: | + ${{ env.PACKAGE_NAME }}.tar.gz diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml index 8ee0f88..9285da2 100644 --- a/.github/workflows/apple.yml +++ b/.github/workflows/apple.yml @@ -3,24 +3,21 @@ name: apple on: push: tags: - - '*' - # pull_request: - # branches: ["main"] + - "*" + pull_request: + branches: ["main"] env: DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer - IOS_DEPLOYMENT_TARGET: '13.0' - MAC_DEPLOYMENT_TARGET: '11.0' + IOS_DEPLOYMENT_TARGET: "13.0" + MAC_DEPLOYMENT_TARGET: "11.0" ENABLE_BITCODE: OFF ENABLE_ARC: OFF ENABLE_VISIBILITY: OFF -permissions: - contents: read - jobs: ios: - runs-on: macos-13 + runs-on: macos-14 strategy: matrix: opencv-version: [4.10.0] @@ -35,48 +32,57 @@ jobs: -DCMAKE_BUILD_TYPE=Release \ -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib/modules" \ steps: - - uses: actions/checkout@v4 - - name: setup-opencv-source - run: | - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=opencv" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-ios-arm64" >> $GITHUB_ENV - echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV - - name: build - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - `cat ../../options.txt` -DPLATFORM=OS64 \ + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib + echo "SOURCE_DIR=opencv" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-ios-arm64" >> $GITHUB_ENV + echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV + - name: build + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} `cat ../../options.txt` \ + -DPLATFORM=OS64 \ -DWITH_OPENCL=OFF -DWITH_OPENCL_SVM=OFF .. - cmake --build . -j 4 - cmake --build . --target install - - name: package - run: | - rm -f ${{ env.PACKAGE_NAME }}.zip - zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip ${{ env.SOURCE_DIR }}/build/install/ - - name: test - run: | - cd test - mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=OS64 \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.SOURCE_DIR }}/build/install/${{ env.OPENCV_SUBDIR }} .. - cmake --build . -j 4 - - name: upload-zip - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PACKAGE_NAME }} - path: ${{ env.PACKAGE_NAME }}.zip + cmake --build . -j 4 + cmake --build . --target install + - name: package + run: | + mkdir -p ${{ env.PACKAGE_NAME }}/ + cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ + tar -zcvf ${{ env.PACKAGE_NAME }}.tar.gz ${{ env.PACKAGE_NAME }}/ + - name: test + run: | + cd test + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=OS64 \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j 4 + - name: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.tar.gz + - name: release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: true + prerelease: false + files: | + ${{ env.PACKAGE_NAME }}.tar.gz ios-simulator: - runs-on: macos-13 + runs-on: macos-14 strategy: matrix: opencv-version: [4.10.0] platform: - - {arch: x64, name: SIMULATOR64} - - {arch: arm64, name: SIMULATORARM64} + - { arch: x64, name: SIMULATOR64 } + - { arch: arm64, name: SIMULATORARM64 } env: COMMON_CMAKE_OPTIONS: | -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ @@ -88,48 +94,57 @@ jobs: -DCMAKE_BUILD_TYPE=Release \ -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib/modules" \ steps: - - uses: actions/checkout@v4 - - name: setup-opencv-source - run: | - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=opencv" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-ios-simulator-${{ matrix.platform.arch }}" >> $GITHUB_ENV - echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV - - name: build - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - `cat ../../options.txt` -DPLATFORM=${{ matrix.platform.name }} \ + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib + echo "SOURCE_DIR=opencv" >> $GITHUB_ENV + echo "PACKAGE_NAME=libopencv-ios-simulator-${{ matrix.platform.arch }}" >> $GITHUB_ENV + echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV + - name: build + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} `cat ../../options.txt` \ + -DPLATFORM=${{ matrix.platform.name }} \ -DWITH_OPENCL=OFF -DWITH_OPENCL_SVM=OFF \ -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. - cmake --build . -j 4 - cmake --build . --target install - - name: package - run: | - rm -f ${{ env.PACKAGE_NAME }}.zip - zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip ${{ env.SOURCE_DIR }}/build/install/ - - name: test - run: | - cd test - mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=${{ matrix.platform.name }} \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.SOURCE_DIR }}/build/install/${{ env.OPENCV_SUBDIR }} .. - cmake --build . -j 4 - - name: upload-zip - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PACKAGE_NAME }} - path: ${{ env.PACKAGE_NAME }}.zip + cmake --build . -j 4 + cmake --build . --target install + - name: package + run: | + mkdir -p ${{ env.PACKAGE_NAME }}/ + cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ + tar -zcvf ${{ env.PACKAGE_NAME }}.tar.gz ${{ env.PACKAGE_NAME }}/ + - name: test + run: | + cd test + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=${{ matrix.platform.name }} \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j 4 + - name: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.tar.gz + - name: release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: true + prerelease: false + files: | + ${{ env.PACKAGE_NAME }}.tar.gz macos: strategy: matrix: opencv-version: [4.10.0] osname: - - {os: macos-13, arch: x64, platform: MAC} - - {os: macos-14, arch: arm64, platform: MAC_ARM64} + - { os: macos-13, arch: x64, platform: MAC } + - { os: macos-14, arch: arm64, platform: MAC_ARM64 } runs-on: ${{ matrix.osname.os }} env: COMMON_CMAKE_OPTIONS: | @@ -142,55 +157,64 @@ jobs: -DCMAKE_BUILD_TYPE=Release \ -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib/modules" \ steps: - - uses: actions/checkout@v4 - - name: setup-opencv-source - run: | - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=opencv" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-macos-${{ matrix.osname.arch }}" >> $GITHUB_ENV - echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV - - name: build - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=${{ matrix.osname.platform }} \ - `cat ../../options.txt` .. - cmake --build . -j 4 - cmake --build . --target install - - name: package - run: | - rm -f ${{ env.PACKAGE_NAME }}.zip - zip -9 -y -r ${{ env.PACKAGE_NAME }}.zip ${{ env.SOURCE_DIR }}/build/install/ - - name: test - run: | - cd test - mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=${{ matrix.osname.platform }} \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.SOURCE_DIR }}/build/install/${{ env.OPENCV_SUBDIR }} .. - cmake --build . -j 4 - - name: upload-zip - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PACKAGE_NAME }} - path: ${{ env.PACKAGE_NAME }}.zip + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib + echo "SOURCE_DIR=opencv" >> $GITHUB_ENV + echo "PACKAGE_NAME=libopencv-macos-${{ matrix.osname.arch }}" >> $GITHUB_ENV + echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV + - name: build + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=${{ matrix.osname.platform }} \ + `cat ../../options.txt` .. + cmake --build . -j 4 + cmake --build . --target install + - name: package + run: | + mkdir -p ${{ env.PACKAGE_NAME }}/ + cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ + tar -zcvf ${{ env.PACKAGE_NAME }}.tar.gz ${{ env.PACKAGE_NAME }}/ + - name: test + run: | + cd test + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=${{ matrix.osname.platform }} \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j 4 + - name: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.tar.gz + - name: release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: true + prerelease: false + files: | + ${{ env.PACKAGE_NAME }}.tar.gz - release: - permissions: - contents: write # for softprops/action-gh-release to create a release - needs: [ios, ios-simulator, macos] - runs-on: ubuntu-latest - steps: - - name: download - uses: actions/download-artifact@v4 - with: - path: artifacts + # release: + # permissions: + # contents: write # for softprops/action-gh-release to create a release + # needs: [ios, ios-simulator, macos] + # runs-on: macos-14 + # steps: + # - name: download + # uses: actions/download-artifact@v4 + # with: + # path: artifacts - - name: create-release - uses: softprops/action-gh-release@v2 - if: startsWith(github.ref, 'refs/tags/') - with: - draft: true - prerelease: false - token: ${{ secrets.GITHUB_TOKEN }} - files: artifacts/*/*.zip + # - name: create-release + # uses: softprops/action-gh-release@v2 + # if: startsWith(github.ref, 'refs/tags/') + # with: + # draft: true + # prerelease: false + # token: ${{ secrets.GITHUB_TOKEN }} + # files: artifacts/*/*.tar.gz diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index c660be4..8254109 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -2,12 +2,9 @@ name: linux on: push: tags: - - '*' - # pull_request: - # branches: ["main"] - -permissions: - contents: read + - "*" + pull_request: + branches: ["main"] jobs: armlinux: @@ -19,51 +16,57 @@ jobs: COMMON_CMAKE_OPTIONS: | -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" \ + -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib/modules" \ steps: - - name: arm-gnu-toolchain - run: | - sudo apt-get update - sudo apt-get install g++-arm-linux-gnueabi g++-arm-linux-gnueabihf g++-aarch64-linux-gnu \ - libgtk-3-dev ffmpeg libavcodec-dev libavformat-dev libavutil-dev \ - libswscale-dev libgflags-dev \ + - name: arm-gnu-toolchain + run: | + sudo apt-get update + sudo apt-get install g++-arm-linux-gnueabi g++-arm-linux-gnueabihf g++-aarch64-linux-gnu \ + libgtk-3-dev ffmpeg libavcodec-dev libavformat-dev libavutil-dev \ + libswscale-dev libgflags-dev \ - - uses: actions/checkout@v4 - - name: setup-opencv-source - run: | - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} - echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-armlinux" >> $GITHUB_ENV - - name: build-aarch64-linux-gnu - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-aarch64-linux-gnu && cd build-aarch64-linux-gnu - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/aarch64-linux-gnu.toolchain.cmake \ - `cat ../../options.txt` .. - cmake --build . -j $(nproc) - cmake --build . --target install - - name: package - run: | - mkdir ${{ env.PACKAGE_NAME }} - mkdir ${{ env.PACKAGE_NAME }}/aarch64-linux-gnu - cp -rf ${{ env.SOURCE_DIR }}/build-aarch64-linux-gnu/install/* ${{ env.PACKAGE_NAME }}/aarch64-linux-gnu/ - zip -9 -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} - - name: set-opencv-dir - if: matrix.opencv-version == '4.10.0' - run: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV - - name: test-aarch64-linux-gnu - run: | - cd test - mkdir build-aarch64-linux-gnu && cd build-aarch64-linux-gnu - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/aarch64-linux-gnu.toolchain.cmake \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/aarch64-linux-gnu/${{ env.OPENCV_SUBDIR }} .. - cmake --build . -j $(nproc) - - name: upload-zip - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PACKAGE_NAME }} - path: ${{ env.PACKAGE_NAME }}.zip + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib + echo "SOURCE_DIR=opencv" >> $GITHUB_ENV + echo "PACKAGE_NAME=libopencv-linux-arm" >> $GITHUB_ENV + echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV + - name: build-aarch64-linux-gnu + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build-aarch64-linux-gnu && cd build-aarch64-linux-gnu + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/aarch64-linux-gnu.toolchain.cmake \ + `cat ../../options.txt` .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: package + run: | + mkdir ${{ env.PACKAGE_NAME }} + mkdir ${{ env.PACKAGE_NAME }}/aarch64-linux-gnu + cp -rf ${{ env.SOURCE_DIR }}/build-aarch64-linux-gnu/install/* ${{ env.PACKAGE_NAME }}/aarch64-linux-gnu/ + tar -zcvf ${{ env.PACKAGE_NAME }}.tar.gz ${{ env.PACKAGE_NAME }} + - name: test-aarch64-linux-gnu + run: | + cd test + mkdir build-aarch64-linux-gnu && cd build-aarch64-linux-gnu + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/aarch64-linux-gnu.toolchain.cmake \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/aarch64-linux-gnu/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j $(nproc) + - name: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.tar.gz + - name: release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: true + prerelease: false + files: | + ${{ env.PACKAGE_NAME }}.tar.gz ubuntu: strategy: @@ -74,65 +77,71 @@ jobs: - { ubuntu-id: 2404, ubuntu-version: 24.04 } runs-on: ubuntu-${{ matrix.os-ubuntu.ubuntu-version }} env: - COMMON_CMAKE_OPTIONS: -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-${{ matrix.opencv-version }}/modules" + COMMON_CMAKE_OPTIONS: -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib/modules" steps: - - uses: actions/checkout@v4 - - name: setup - run: | - sudo apt-get update - sudo apt-get install libgtk-3-dev ffmpeg libavcodec-dev libavformat-dev libavutil-dev \ - libswscale-dev libgflags-dev \ - - name: setup-opencv-source - run: | - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv-${{ matrix.opencv-version }} - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib-${{ matrix.opencv-version }} - echo "SOURCE_DIR=opencv-${{ matrix.opencv-version }}" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-ubuntu-${{ matrix.os-ubuntu.ubuntu-id }}" >> $GITHUB_ENV - - name: build - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} `cat ../../options.txt` .. - cmake --build . -j $(nproc) - cmake --build . --target install - - name: package - run: | - rm -rf ${{ env.PACKAGE_NAME }} - mkdir -p ${{ env.PACKAGE_NAME }} - cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ - rm -f ${{ env.PACKAGE_NAME }}.zip - zip -9 -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} - - name: set-opencv-dir - if: matrix.opencv-version == '4.10.0' - run: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV - - name: test - run: | - cd test - mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} .. - cmake --build . -j $(nproc) - - name: upload - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PACKAGE_NAME }} - path: ${{ env.PACKAGE_NAME }}.zip + - uses: actions/checkout@v4 + - name: setup + run: | + sudo apt-get update + sudo apt-get install libgtk-3-dev ffmpeg libavcodec-dev libavformat-dev libavutil-dev \ + libswscale-dev libgflags-dev \ + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib + echo "SOURCE_DIR=opencv" >> $GITHUB_ENV + echo "PACKAGE_NAME=opencv-ubuntu-${{ matrix.os-ubuntu.ubuntu-id }}" >> $GITHUB_ENV + - name: build + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} `cat ../../options.txt` .. + cmake --build . -j $(nproc) + cmake --build . --target install + - name: package + run: | + mkdir -p ${{ env.PACKAGE_NAME }}/x64 + cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/x64 + tar -zcvf ${{ env.PACKAGE_NAME }}.tar.gz ${{ env.PACKAGE_NAME }} + - name: set-opencv-dir + if: matrix.opencv-version == '4.10.0' + run: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV + - name: test + run: | + cd test + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j $(nproc) + - name: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.tar.gz + - name: release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: true + prerelease: false + files: | + ${{ env.PACKAGE_NAME }}.tar.gz - release: - permissions: - contents: write # for softprops/action-gh-release to create a release - needs: [armlinux, ubuntu] - runs-on: ubuntu-latest - steps: - - name: download - uses: actions/download-artifact@v4 - with: - path: artifacts + # release: + # permissions: + # contents: write # for softprops/action-gh-release to create a release + # needs: [armlinux, ubuntu] + # runs-on: ubuntu-latest + # steps: + # - name: download + # uses: actions/download-artifact@v4 + # with: + # path: artifacts - - name: create-release - uses: softprops/action-gh-release@v2 - if: startsWith(github.ref, 'refs/tags/') - with: - draft: true - prerelease: false - token: ${{ secrets.GITHUB_TOKEN }} - files: artifacts/*/*.zip + # - name: create-release + # uses: softprops/action-gh-release@v2 + # if: startsWith(github.ref, 'refs/tags/') + # with: + # draft: true + # prerelease: false + # token: ${{ secrets.GITHUB_TOKEN }} + # files: artifacts/*/*.tar.gz diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 8473ab4..9442fa3 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -3,11 +3,8 @@ on: push: tags: - '*' - # pull_request: - # branches: ["main"] - -permissions: - contents: read + pull_request: + branches: ["main"] jobs: windows: @@ -20,7 +17,9 @@ jobs: runs-on: windows-${{ matrix.os-compiler.windows-version }} env: UseMultiToolTask: true - COMMON_CMAKE_OPTIONS: -T ${{ matrix.os-compiler.toolset-version }},host=x64 -DCMAKE_INSTALL_PREFIX=install -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib/modules" + COMMON_CMAKE_OPTIONS: -T ${{ matrix.os-compiler.toolset-version }},host=x64 ` + -DCMAKE_INSTALL_PREFIX=install ` + -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib/modules" ` steps: - uses: actions/checkout@v4 - name: setup-opencv-source @@ -28,66 +27,63 @@ jobs: git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib echo "SOURCE_DIR=opencv" >> $env:GITHUB_ENV - echo "PACKAGE_NAME=opencv-windows-${{ matrix.os-compiler.msvc-version }}" >> $env:GITHUB_ENV + echo "PACKAGE_NAME=libopencv-windows-${{ matrix.os-compiler.msvc-version }}" >> $env:GITHUB_ENV - name: build-x64 run: | cd ${{ env.SOURCE_DIR }} mkdir build-x64; cd build-x64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A x64 $(type ../../options.txt) -DBUILD_opencv_world=OFF .. - cmake --build . --config Release -j 4 - cmake --build . --config Release --target install - - name: build-arm64 - if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-arm64; cd build-arm64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A arm64 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=ARM64 $(type ../../options.txt) -DBUILD_opencv_world=OFF .. + cmake ${{ env.COMMON_CMAKE_OPTIONS }} ` + -A x64 ` + $(type ../../options.txt) ` + -DBUILD_opencv_world=OFF .. cmake --build . --config Release -j 4 cmake --build . --config Release --target install + # - name: build-arm64 + # if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' + # run: | + # cd ${{ env.SOURCE_DIR }} + # mkdir build-arm64; cd build-arm64 + # cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A arm64 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=ARM64 $(type ../../options.txt) -DBUILD_opencv_world=OFF .. + # cmake --build . --config Release -j 4 + # cmake --build . --config Release --target install - name: package if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' run: | mkdir ${{ env.PACKAGE_NAME }} mkdir ${{ env.PACKAGE_NAME }}/x64 - mkdir ${{ env.PACKAGE_NAME }}/arm64 + # mkdir ${{ env.PACKAGE_NAME }}/arm64 Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-x64\install\*" -Destination "${{ env.PACKAGE_NAME }}\x64" - Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-arm64\install\*" -Destination "${{ env.PACKAGE_NAME }}\arm64" - 7z a -r ${{ env.PACKAGE_NAME }}.zip ${{ env.PACKAGE_NAME }} + # Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-arm64\install\*" -Destination "${{ env.PACKAGE_NAME }}\arm64" + tar -zcvf ${{ env.PACKAGE_NAME }}.tar.gz ${{ env.PACKAGE_NAME }} - name: test-x64 run: | cd test mkdir build-x64; cd build-x64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A x64 -DOpenCV_DIR="$env:GITHUB_WORKSPACE\${{ env.PACKAGE_NAME }}\x64" -DOpenCV_STATIC=ON .. - cmake --build . --config Release -j 4 - - name: test-arm64 - if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' - run: | - cd test - mkdir build-arm64; cd build-arm64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A arm64 -DOpenCV_DIR="$env:GITHUB_WORKSPACE\${{ env.PACKAGE_NAME }}\arm64" -DOpenCV_STATIC=ON .. + cmake ${{ env.COMMON_CMAKE_OPTIONS }} ` + -A x64 ` + -DOpenCV_DIR="$env:GITHUB_WORKSPACE\${{ env.PACKAGE_NAME }}\x64" ` + -DOpenCV_STATIC=ON .. cmake --build . --config Release -j 4 - - name: upload-zip + # - name: test-arm64 + # if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' + # run: | + # cd test + # mkdir build-arm64; cd build-arm64 + # cmake ${{ env.COMMON_CMAKE_OPTIONS }} ` + # -A arm64 ` + # -DOpenCV_DIR="$env:GITHUB_WORKSPACE\${{ env.PACKAGE_NAME }}\arm64" ` + # -DOpenCV_STATIC=ON .. + # cmake --build . --config Release -j 4 + - name: upload uses: actions/upload-artifact@v4 with: name: ${{ env.PACKAGE_NAME }} - path: ${{ env.PACKAGE_NAME }}.zip - - release: - permissions: - contents: write # for softprops/action-gh-release to create a release - needs: [windows] - runs-on: ubuntu-latest - steps: - - name: download - uses: actions/download-artifact@v4 - with: - path: artifacts - - - name: create-release - uses: softprops/action-gh-release@v2 + path: ${{ env.PACKAGE_NAME }}.tar.gz + - name: release + uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') with: draft: true prerelease: false - token: ${{ secrets.GITHUB_TOKEN }} - files: artifacts/*/*.zip + files: | + ${{ env.PACKAGE_NAME }}.tar.gz From f8aab32575d24b9cc09820f503980cc9b9fb48e0 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Mon, 23 Sep 2024 14:59:54 +0800 Subject: [PATCH 17/41] fix linux --- .github/workflows/linux.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 8254109..cb26a90 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -110,7 +110,8 @@ jobs: run: | cd test mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} .. + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/x64/${{ env.OPENCV_SUBDIR }} .. cmake --build . -j $(nproc) - name: upload uses: actions/upload-artifact@v4 From 72985525420a3c2c1024856d8ede0112f7b3ec70 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Tue, 24 Sep 2024 12:17:04 +0800 Subject: [PATCH 18/41] ffmpeg 6.1 on linux --- .github/workflows/apple.yml | 2 +- .github/workflows/linux.yml | 49 ++++++++++++++----- .gitignore | 3 ++ .../aarch64-linux-gnu.toolchain.cmake | 0 .../arm-linux-gnueabi.toolchain.cmake | 0 .../arm-linux-gnueabihf.toolchain.cmake | 0 {toolchains => cmake}/ios.toolchain.cmake | 0 ...riscv64-unknown-linux-musl.toolchain.cmake | 0 8 files changed, 41 insertions(+), 13 deletions(-) rename {toolchains => cmake}/aarch64-linux-gnu.toolchain.cmake (100%) rename {toolchains => cmake}/arm-linux-gnueabi.toolchain.cmake (100%) rename {toolchains => cmake}/arm-linux-gnueabihf.toolchain.cmake (100%) rename {toolchains => cmake}/ios.toolchain.cmake (100%) rename {toolchains => cmake}/riscv64-unknown-linux-musl.toolchain.cmake (100%) diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml index 9285da2..dc67b1e 100644 --- a/.github/workflows/apple.yml +++ b/.github/workflows/apple.yml @@ -38,7 +38,7 @@ jobs: git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib echo "SOURCE_DIR=opencv" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-ios-arm64" >> $GITHUB_ENV + echo "PACKAGE_NAME=libopencv-ios-arm64" >> $GITHUB_ENV echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV - name: build run: | diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index cb26a90..bdb47fd 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -16,29 +16,39 @@ jobs: COMMON_CMAKE_OPTIONS: | -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib/modules" \ + -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" steps: - name: arm-gnu-toolchain run: | sudo apt-get update - sudo apt-get install g++-arm-linux-gnueabi g++-arm-linux-gnueabihf g++-aarch64-linux-gnu \ - libgtk-3-dev ffmpeg libavcodec-dev libavformat-dev libavutil-dev \ - libswscale-dev libgflags-dev \ + sudo apt-get install g++-arm-linux-gnueabi g++-arm-linux-gnueabihf g++-aarch64-linux-gnu - uses: actions/checkout@v4 - name: setup-opencv-source run: | git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=opencv" >> $GITHUB_ENV + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $GITHUB_ENV echo "PACKAGE_NAME=libopencv-linux-arm" >> $GITHUB_ENV echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV + - name: setup ffmpeg + run: | + wget -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-6.1-linux-clang-default.tar.xz + mkdir -p ffmpeg + tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 + echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $GITHUB_ENV - name: build-aarch64-linux-gnu run: | cd ${{ env.SOURCE_DIR }} mkdir build-aarch64-linux-gnu && cd build-aarch64-linux-gnu - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/aarch64-linux-gnu.toolchain.cmake \ - `cat ../../options.txt` .. + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/aarch64-linux-gnu.toolchain.cmake \ + `cat ${{ github.workspace }}/options.txt` \ + -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" \ + -DOPENCV_FFMPEG_USE_FIND_PACKAGE=ON \ + -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ + -DBUILD_opencv_world=OFF \ + -DFFMPEG_ARCH=arm64 .. cmake --build . -j $(nproc) cmake --build . --target install - name: package @@ -77,25 +87,40 @@ jobs: - { ubuntu-id: 2404, ubuntu-version: 24.04 } runs-on: ubuntu-${{ matrix.os-ubuntu.ubuntu-version }} env: - COMMON_CMAKE_OPTIONS: -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib/modules" + COMMON_CMAKE_OPTIONS: | + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" steps: - uses: actions/checkout@v4 - name: setup run: | sudo apt-get update - sudo apt-get install libgtk-3-dev ffmpeg libavcodec-dev libavformat-dev libavutil-dev \ - libswscale-dev libgflags-dev \ + sudo apt-get install libgtk-3-dev - name: setup-opencv-source run: | git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=opencv" >> $GITHUB_ENV + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $GITHUB_ENV echo "PACKAGE_NAME=opencv-ubuntu-${{ matrix.os-ubuntu.ubuntu-id }}" >> $GITHUB_ENV + - name: setup ffmpeg + run: | + wget -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-6.1-linux-clang-default.tar.xz + mkdir -p ffmpeg + tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 + echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $GITHUB_ENV - name: build run: | cd ${{ env.SOURCE_DIR }} mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} `cat ../../options.txt` .. + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/aarch64-linux-gnu.toolchain.cmake \ + `cat ${{ github.workspace }}/options.txt` \ + -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" \ + -DOPENCV_FFMPEG_USE_FIND_PACKAGE=ON \ + -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ + -DBUILD_opencv_world=OFF \ + -DFFMPEG_ARCH=amd64 .. cmake --build . -j $(nproc) cmake --build . --target install - name: package diff --git a/.gitignore b/.gitignore index 31f95aa..4161c9f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ build*/ test/ +ffmpeg* +opencv/ +opencv_contrib/ # Prerequisites *.d .vscode diff --git a/toolchains/aarch64-linux-gnu.toolchain.cmake b/cmake/aarch64-linux-gnu.toolchain.cmake similarity index 100% rename from toolchains/aarch64-linux-gnu.toolchain.cmake rename to cmake/aarch64-linux-gnu.toolchain.cmake diff --git a/toolchains/arm-linux-gnueabi.toolchain.cmake b/cmake/arm-linux-gnueabi.toolchain.cmake similarity index 100% rename from toolchains/arm-linux-gnueabi.toolchain.cmake rename to cmake/arm-linux-gnueabi.toolchain.cmake diff --git a/toolchains/arm-linux-gnueabihf.toolchain.cmake b/cmake/arm-linux-gnueabihf.toolchain.cmake similarity index 100% rename from toolchains/arm-linux-gnueabihf.toolchain.cmake rename to cmake/arm-linux-gnueabihf.toolchain.cmake diff --git a/toolchains/ios.toolchain.cmake b/cmake/ios.toolchain.cmake similarity index 100% rename from toolchains/ios.toolchain.cmake rename to cmake/ios.toolchain.cmake diff --git a/toolchains/riscv64-unknown-linux-musl.toolchain.cmake b/cmake/riscv64-unknown-linux-musl.toolchain.cmake similarity index 100% rename from toolchains/riscv64-unknown-linux-musl.toolchain.cmake rename to cmake/riscv64-unknown-linux-musl.toolchain.cmake From 1beb615dca51e9cea2cdc4ed1d0d1febf958f043 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Tue, 24 Sep 2024 12:20:16 +0800 Subject: [PATCH 19/41] fix linux --- .github/workflows/linux.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index bdb47fd..510a547 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -16,7 +16,7 @@ jobs: COMMON_CMAKE_OPTIONS: | -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" + -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ steps: - name: arm-gnu-toolchain run: | @@ -90,7 +90,7 @@ jobs: COMMON_CMAKE_OPTIONS: | -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" + -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ steps: - uses: actions/checkout@v4 - name: setup From 1e3ddeb8049d4068f900d569cbe37709e37715f4 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Tue, 24 Sep 2024 18:27:46 +0800 Subject: [PATCH 20/41] finish all platforms --- .github/workflows/android.yml | 43 +++++- .github/workflows/apple.yml | 87 +++++++++--- .github/workflows/linux.yml | 69 ++++++--- .github/workflows/windows.yml | 147 +++++++++---------- cmake/ffmpeg-config.cmake | 258 ++++++++++++++++++++++++++++++++++ options.txt | 2 + 6 files changed, 485 insertions(+), 121 deletions(-) create mode 100644 cmake/ffmpeg-config.cmake diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index b7e4948..f22fce8 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -22,7 +22,6 @@ jobs: -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ -DANDROID_STL=c++_static \ - -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib/modules" \ steps: - uses: actions/checkout@v4 - name: setup-opencv-source @@ -31,12 +30,27 @@ jobs: git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib echo "SOURCE_DIR=opencv" >> $GITHUB_ENV echo "PACKAGE_NAME=libopencv-android-${{ matrix.abi }}" >> $GITHUB_ENV + - name: setup ffmpeg + run: | + wget -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-6.1-linux-clang-default.tar.xz + mkdir -p ffmpeg + tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 + mkdir -p ${{ github.workspace }}/ffmpeg/cmake + cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ + echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $GITHUB_ENV - name: build run: | cd ${{ env.SOURCE_DIR }} mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="${{ matrix.abi }}" -DANDROID_ARM_NEON=ON \ - `cat ../../options.txt` -DBUILD_opencv_world=OFF .. + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DANDROID_ABI="${{ matrix.abi }}" \ + -DANDROID_ARM_NEON=ON \ + `cat ${{ github.workspace }}/options.txt` \ + -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ + -DBUILD_opencv_world=OFF \ + -DFFMPEG_ARCH="${{ matrix.abi }}" \ + -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ + .. cmake --build . -j $(nproc) cmake --build . --target install @@ -44,13 +58,30 @@ jobs: run: | mkdir -p ${{ env.PACKAGE_NAME }}/ cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ - tar -zcvf ${{ env.PACKAGE_NAME }}.tar.gz ${{ env.PACKAGE_NAME }} + + mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg + cp -rf ${{ env.FFMPEG_ROOT }}/include ${{ env.PACKAGE_NAME }}/ffmpeg/ + mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg/bin + cp -rf ${{ env.FFMPEG_ROOT }}/bin/${{ matrix.abi }} ${{ env.PACKAGE_NAME }}/ffmpeg/bin + mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg/lib + cp -rf ${{ env.FFMPEG_ROOT }}/lib/${{ matrix.abi }} ${{ env.PACKAGE_NAME }}/ffmpeg/lib + cp -rf ${{ env.FFMPEG_ROOT }}/cmake ${{ env.PACKAGE_NAME }}/ffmpeg/cmake + cp -rf ${{ env.FFMPEG_ROOT }}/Changelog ${{ env.PACKAGE_NAME }}/ffmpeg/Changelog + cp -rf ${{ env.FFMPEG_ROOT }}/config-${{ matrix.abi }}.txt ${{ env.PACKAGE_NAME }}/ffmpeg/config.txt + cp -rf ${{ env.FFMPEG_ROOT }}/COPYING.LGPLv2.1 ${{ env.PACKAGE_NAME }}/ffmpeg/COPYING.LGPLv2.1 + cp -rf ${{ env.FFMPEG_ROOT }}/README.txt ${{ env.PACKAGE_NAME }}/ffmpeg/README.txt + cp -rf ${{ env.FFMPEG_ROOT }}/RELEASE_NOTES ${{ env.PACKAGE_NAME }}/ffmpeg/RELEASE_NOTES + + tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . - name: test run: | cd test mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DANDROID_ABI="${{ matrix.abi }}" -DANDROID_ARM_NEON=ON \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/sdk/native/jni .. + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DANDROID_ABI="${{ matrix.abi }}" \ + -DANDROID_ARM_NEON=ON \ + -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/sdk/native/jni \ + .. cmake --build . -j $(nproc) - name: upload uses: actions/upload-artifact@v4 diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml index dc67b1e..0311841 100644 --- a/.github/workflows/apple.yml +++ b/.github/workflows/apple.yml @@ -9,8 +9,8 @@ on: env: DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer - IOS_DEPLOYMENT_TARGET: "13.0" - MAC_DEPLOYMENT_TARGET: "11.0" + IOS_DEPLOYMENT_TARGET: "11.0" + MAC_DEPLOYMENT_TARGET: "10.15" ENABLE_BITCODE: OFF ENABLE_ARC: OFF ENABLE_VISIBILITY: OFF @@ -23,43 +23,58 @@ jobs: opencv-version: [4.10.0] env: COMMON_CMAKE_OPTIONS: | - -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ + -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/ios.toolchain.cmake \ -DDEPLOYMENT_TARGET=$IOS_DEPLOYMENT_TARGET \ -DENABLE_BITCODE=$ENABLE_BITCODE \ -DENABLE_ARC=$ENABLE_ARC \ -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib/modules" \ + -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ steps: - uses: actions/checkout@v4 - name: setup-opencv-source run: | git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=opencv" >> $GITHUB_ENV + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $GITHUB_ENV echo "PACKAGE_NAME=libopencv-ios-arm64" >> $GITHUB_ENV echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV + - name: setup ffmpeg + run: | + wget -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/iOS/ffmpeg-6.1-iOS-lite-shared.tar.xz + mkdir -p ffmpeg + tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 + mkdir -p ${{ github.workspace }}/ffmpeg/cmake + cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ + echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $GITHUB_ENV - name: build run: | cd ${{ env.SOURCE_DIR }} mkdir build && cd build cmake ${{ env.COMMON_CMAKE_OPTIONS }} `cat ../../options.txt` \ -DPLATFORM=OS64 \ - -DWITH_OPENCL=OFF -DWITH_OPENCL_SVM=OFF .. + -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" \ + -DWITH_TIFF=OFF \ + -DWITH_OPENJPEG=OFF \ + -DWITH_OPENCL=OFF \ + -DWITH_OPENCL_SVM=OFF .. cmake --build . -j 4 cmake --build . --target install - name: package run: | mkdir -p ${{ env.PACKAGE_NAME }}/ cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ - tar -zcvf ${{ env.PACKAGE_NAME }}.tar.gz ${{ env.PACKAGE_NAME }}/ + + cp -rf ${{ env.FFMPEG_ROOT }} ${{ env.PACKAGE_NAME }}/ffmpeg + + tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . - name: test run: | cd test mkdir build && cd build cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=OS64 \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} .. + -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} .. cmake --build . -j 4 - name: upload uses: actions/upload-artifact@v4 @@ -85,30 +100,42 @@ jobs: - { arch: arm64, name: SIMULATORARM64 } env: COMMON_CMAKE_OPTIONS: | - -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ + -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/ios.toolchain.cmake \ -DDEPLOYMENT_TARGET=$IOS_DEPLOYMENT_TARGET \ -DENABLE_BITCODE=$ENABLE_BITCODE \ -DENABLE_ARC=$ENABLE_ARC \ -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib/modules" \ + -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ steps: - uses: actions/checkout@v4 - name: setup-opencv-source run: | git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=opencv" >> $GITHUB_ENV - echo "PACKAGE_NAME=libopencv-ios-simulator-${{ matrix.platform.arch }}" >> $GITHUB_ENV + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $GITHUB_ENV + echo "PACKAGE_NAME=libopencv-iossimulator-${{ matrix.platform.arch }}" >> $GITHUB_ENV echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV + - name: setup ffmpeg + run: | + wget -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/iOSSimulator/ffmpeg-6.1-iOSSimulator-lite-shared.tar.xz + mkdir -p ffmpeg + tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 + mkdir -p ${{ github.workspace }}/ffmpeg/cmake + cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ + echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $GITHUB_ENV - name: build run: | cd ${{ env.SOURCE_DIR }} mkdir build && cd build cmake ${{ env.COMMON_CMAKE_OPTIONS }} `cat ../../options.txt` \ -DPLATFORM=${{ matrix.platform.name }} \ - -DWITH_OPENCL=OFF -DWITH_OPENCL_SVM=OFF \ + -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" \ + -DWITH_TIFF=OFF \ + -DWITH_OPENJPEG=OFF \ + -DWITH_OPENCL=OFF \ + -DWITH_OPENCL_SVM=OFF \ -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. cmake --build . -j 4 cmake --build . --target install @@ -116,13 +143,16 @@ jobs: run: | mkdir -p ${{ env.PACKAGE_NAME }}/ cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ - tar -zcvf ${{ env.PACKAGE_NAME }}.tar.gz ${{ env.PACKAGE_NAME }}/ + + cp -rf ${{ env.FFMPEG_ROOT }} ${{ env.PACKAGE_NAME }}/ffmpeg + + tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . - name: test run: | cd test mkdir build && cd build cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=${{ matrix.platform.name }} \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} .. + -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} .. cmake --build . -j 4 - name: upload uses: actions/upload-artifact@v4 @@ -148,42 +178,57 @@ jobs: runs-on: ${{ matrix.osname.os }} env: COMMON_CMAKE_OPTIONS: | - -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \ + -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/ios.toolchain.cmake \ -DDEPLOYMENT_TARGET=$MAC_DEPLOYMENT_TARGET \ -DENABLE_BITCODE=OFF \ -DENABLE_ARC=$ENABLE_ARC \ -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib/modules" \ + -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ steps: - uses: actions/checkout@v4 - name: setup-opencv-source run: | git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=opencv" >> $GITHUB_ENV + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $GITHUB_ENV echo "PACKAGE_NAME=libopencv-macos-${{ matrix.osname.arch }}" >> $GITHUB_ENV echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV + - name: setup ffmpeg + run: | + wget -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/macOS/ffmpeg-6.1-macOS-default.tar.xz + mkdir -p ffmpeg + tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 + mkdir -p ${{ github.workspace }}/ffmpeg/cmake + cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ + echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $GITHUB_ENV - name: build run: | cd ${{ env.SOURCE_DIR }} mkdir build && cd build cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=${{ matrix.osname.platform }} \ - `cat ../../options.txt` .. + `cat ../../options.txt` \ + -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" \ + -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ + .. cmake --build . -j 4 cmake --build . --target install - name: package run: | mkdir -p ${{ env.PACKAGE_NAME }}/ cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ - tar -zcvf ${{ env.PACKAGE_NAME }}.tar.gz ${{ env.PACKAGE_NAME }}/ + + cp -rf ${{ env.FFMPEG_ROOT }} ${{ env.PACKAGE_NAME }}/ffmpeg + + tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . - name: test run: | cd test mkdir build && cd build cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=${{ matrix.osname.platform }} \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} .. + -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} \ + .. cmake --build . -j 4 - name: upload uses: actions/upload-artifact@v4 diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 510a547..7aa26a9 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -16,9 +16,8 @@ jobs: COMMON_CMAKE_OPTIONS: | -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ steps: - - name: arm-gnu-toolchain + - name: setup run: | sudo apt-get update sudo apt-get install g++-arm-linux-gnueabi g++-arm-linux-gnueabihf g++-aarch64-linux-gnu @@ -29,19 +28,22 @@ jobs: git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $GITHUB_ENV - echo "PACKAGE_NAME=libopencv-linux-arm" >> $GITHUB_ENV + echo "PACKAGE_NAME=libopencv-linux-arm64" >> $GITHUB_ENV echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV - name: setup ffmpeg run: | wget -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-6.1-linux-clang-default.tar.xz mkdir -p ffmpeg tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 + mkdir -p ${{ github.workspace }}/ffmpeg/cmake + cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $GITHUB_ENV - name: build-aarch64-linux-gnu run: | cd ${{ env.SOURCE_DIR }} mkdir build-aarch64-linux-gnu && cd build-aarch64-linux-gnu cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/aarch64-linux-gnu.toolchain.cmake \ `cat ${{ github.workspace }}/options.txt` \ -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" \ @@ -54,15 +56,29 @@ jobs: - name: package run: | mkdir ${{ env.PACKAGE_NAME }} - mkdir ${{ env.PACKAGE_NAME }}/aarch64-linux-gnu - cp -rf ${{ env.SOURCE_DIR }}/build-aarch64-linux-gnu/install/* ${{ env.PACKAGE_NAME }}/aarch64-linux-gnu/ - tar -zcvf ${{ env.PACKAGE_NAME }}.tar.gz ${{ env.PACKAGE_NAME }} + cp -rf ${{ env.SOURCE_DIR }}/build-aarch64-linux-gnu/install/* ${{ env.PACKAGE_NAME }}/ + + mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg + cp -rf ${{ env.FFMPEG_ROOT }}/include ${{ env.PACKAGE_NAME }}/ffmpeg/ + mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg/bin + cp -rf ${{ env.FFMPEG_ROOT }}/bin/arm64 ${{ env.PACKAGE_NAME }}/ffmpeg/bin + mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg/lib + cp -rf ${{ env.FFMPEG_ROOT }}/lib/arm64 ${{ env.PACKAGE_NAME }}/ffmpeg/lib + cp -rf ${{ env.FFMPEG_ROOT }}/cmake ${{ env.PACKAGE_NAME }}/ffmpeg/cmake + cp -rf ${{ env.FFMPEG_ROOT }}/Changelog ${{ env.PACKAGE_NAME }}/ffmpeg/Changelog + cp -rf ${{ env.FFMPEG_ROOT }}/config-arm64.txt ${{ env.PACKAGE_NAME }}/ffmpeg/config.txt + cp -rf ${{ env.FFMPEG_ROOT }}/COPYING.LGPLv2.1 ${{ env.PACKAGE_NAME }}/ffmpeg/COPYING.LGPLv2.1 + cp -rf ${{ env.FFMPEG_ROOT }}/README.txt ${{ env.PACKAGE_NAME }}/ffmpeg/README.txt + cp -rf ${{ env.FFMPEG_ROOT }}/RELEASE_NOTES ${{ env.PACKAGE_NAME }}/ffmpeg/RELEASE_NOTES + + tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . - name: test-aarch64-linux-gnu run: | cd test mkdir build-aarch64-linux-gnu && cd build-aarch64-linux-gnu - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DCMAKE_TOOLCHAIN_FILE=../../toolchains/aarch64-linux-gnu.toolchain.cmake \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/aarch64-linux-gnu/${{ env.OPENCV_SUBDIR }} .. + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/aarch64-linux-gnu.toolchain.cmake \ + -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} .. cmake --build . -j $(nproc) - name: upload uses: actions/upload-artifact@v4 @@ -78,19 +94,15 @@ jobs: files: | ${{ env.PACKAGE_NAME }}.tar.gz - ubuntu: + linux: strategy: matrix: opencv-version: [4.10.0] - os-ubuntu: - - { ubuntu-id: 2204, ubuntu-version: 22.04 } - - { ubuntu-id: 2404, ubuntu-version: 24.04 } - runs-on: ubuntu-${{ matrix.os-ubuntu.ubuntu-version }} + runs-on: ubuntu-22.04 env: COMMON_CMAKE_OPTIONS: | -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ - -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ steps: - uses: actions/checkout@v4 - name: setup @@ -102,32 +114,47 @@ jobs: git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $GITHUB_ENV - echo "PACKAGE_NAME=opencv-ubuntu-${{ matrix.os-ubuntu.ubuntu-id }}" >> $GITHUB_ENV + echo "PACKAGE_NAME=libopencv-linux-x64" >> $GITHUB_ENV - name: setup ffmpeg run: | wget -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-6.1-linux-clang-default.tar.xz mkdir -p ffmpeg tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 + mkdir -p ${{ github.workspace }}/ffmpeg/cmake + cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $GITHUB_ENV - name: build run: | cd ${{ env.SOURCE_DIR }} mkdir build && cd build cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/aarch64-linux-gnu.toolchain.cmake \ + -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ `cat ${{ github.workspace }}/options.txt` \ -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" \ -DOPENCV_FFMPEG_USE_FIND_PACKAGE=ON \ -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ - -DBUILD_opencv_world=OFF \ -DFFMPEG_ARCH=amd64 .. cmake --build . -j $(nproc) cmake --build . --target install - name: package run: | - mkdir -p ${{ env.PACKAGE_NAME }}/x64 - cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/x64 - tar -zcvf ${{ env.PACKAGE_NAME }}.tar.gz ${{ env.PACKAGE_NAME }} + mkdir ${{ env.PACKAGE_NAME }} + cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ + + mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg + cp -rf ${{ env.FFMPEG_ROOT }}/include ${{ env.PACKAGE_NAME }}/ffmpeg/ + mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg/bin + cp -rf ${{ env.FFMPEG_ROOT }}/bin/amd64 ${{ env.PACKAGE_NAME }}/ffmpeg/bin + mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg/lib + cp -rf ${{ env.FFMPEG_ROOT }}/lib/amd64 ${{ env.PACKAGE_NAME }}/ffmpeg/lib + cp -rf ${{ env.FFMPEG_ROOT }}/cmake ${{ env.PACKAGE_NAME }}/ffmpeg/cmake + cp -rf ${{ env.FFMPEG_ROOT }}/Changelog ${{ env.PACKAGE_NAME }}/ffmpeg/Changelog + cp -rf ${{ env.FFMPEG_ROOT }}/config-amd64.txt ${{ env.PACKAGE_NAME }}/ffmpeg/config.txt + cp -rf ${{ env.FFMPEG_ROOT }}/COPYING.LGPLv2.1 ${{ env.PACKAGE_NAME }}/ffmpeg/COPYING.LGPLv2.1 + cp -rf ${{ env.FFMPEG_ROOT }}/README.txt ${{ env.PACKAGE_NAME }}/ffmpeg/README.txt + cp -rf ${{ env.FFMPEG_ROOT }}/RELEASE_NOTES ${{ env.PACKAGE_NAME }}/ffmpeg/RELEASE_NOTES + + tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . - name: set-opencv-dir if: matrix.opencv-version == '4.10.0' run: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV @@ -136,7 +163,7 @@ jobs: cd test mkdir build && cd build cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - -DOpenCV_DIR=$GITHUB_WORKSPACE/${{ env.PACKAGE_NAME }}/x64/${{ env.OPENCV_SUBDIR }} .. + -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/x64/${{ env.OPENCV_SUBDIR }} .. cmake --build . -j $(nproc) - name: upload uses: actions/upload-artifact@v4 diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 9442fa3..95c05c7 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -2,7 +2,7 @@ name: windows on: push: tags: - - '*' + - "*" pull_request: branches: ["main"] @@ -11,79 +11,80 @@ jobs: strategy: matrix: opencv-version: [4.10.0] - os-compiler: - - { msvc-version: vs2019, windows-version: 2019, toolset-version: v142 } - # - { msvc-version: vs2022, windows-version: 2022, toolset-version: v143 } - runs-on: windows-${{ matrix.os-compiler.windows-version }} + os: + - { + arch: x64, + toolset-version: v142, + } + # - { + # msvc-version: vs2022, + # windows-version: 2022, + # toolset-version: v143, + # } + runs-on: windows-2019 env: UseMultiToolTask: true - COMMON_CMAKE_OPTIONS: -T ${{ matrix.os-compiler.toolset-version }},host=x64 ` + COMMON_CMAKE_OPTIONS: | + -T ${{ matrix.os.toolset-version }},host=x64 ` -DCMAKE_INSTALL_PREFIX=install ` - -DOPENCV_EXTRA_MODULES_PATH="../../opencv_contrib/modules" ` + -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" ` steps: - - uses: actions/checkout@v4 - - name: setup-opencv-source - run: | - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=opencv" >> $env:GITHUB_ENV - echo "PACKAGE_NAME=libopencv-windows-${{ matrix.os-compiler.msvc-version }}" >> $env:GITHUB_ENV - - name: build-x64 - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-x64; cd build-x64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} ` - -A x64 ` - $(type ../../options.txt) ` - -DBUILD_opencv_world=OFF .. - cmake --build . --config Release -j 4 - cmake --build . --config Release --target install - # - name: build-arm64 - # if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' - # run: | - # cd ${{ env.SOURCE_DIR }} - # mkdir build-arm64; cd build-arm64 - # cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A arm64 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_PROCESSOR=ARM64 $(type ../../options.txt) -DBUILD_opencv_world=OFF .. - # cmake --build . --config Release -j 4 - # cmake --build . --config Release --target install - - name: package - if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' - run: | - mkdir ${{ env.PACKAGE_NAME }} - mkdir ${{ env.PACKAGE_NAME }}/x64 - # mkdir ${{ env.PACKAGE_NAME }}/arm64 - Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-x64\install\*" -Destination "${{ env.PACKAGE_NAME }}\x64" - # Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build-arm64\install\*" -Destination "${{ env.PACKAGE_NAME }}\arm64" - tar -zcvf ${{ env.PACKAGE_NAME }}.tar.gz ${{ env.PACKAGE_NAME }} - - name: test-x64 - run: | - cd test - mkdir build-x64; cd build-x64 - cmake ${{ env.COMMON_CMAKE_OPTIONS }} ` - -A x64 ` - -DOpenCV_DIR="$env:GITHUB_WORKSPACE\${{ env.PACKAGE_NAME }}\x64" ` - -DOpenCV_STATIC=ON .. - cmake --build . --config Release -j 4 - # - name: test-arm64 - # if: matrix.os-compiler.msvc-version == 'vs2019' || matrix.os-compiler.msvc-version == 'vs2022' - # run: | - # cd test - # mkdir build-arm64; cd build-arm64 - # cmake ${{ env.COMMON_CMAKE_OPTIONS }} ` - # -A arm64 ` - # -DOpenCV_DIR="$env:GITHUB_WORKSPACE\${{ env.PACKAGE_NAME }}\arm64" ` - # -DOpenCV_STATIC=ON .. - # cmake --build . --config Release -j 4 - - name: upload - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PACKAGE_NAME }} - path: ${{ env.PACKAGE_NAME }}.tar.gz - - name: release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - draft: true - prerelease: false - files: | - ${{ env.PACKAGE_NAME }}.tar.gz + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib + echo "SOURCE_DIR=opencv" >> $env:GITHUB_ENV + echo "PACKAGE_NAME=libopencv-windows-${{ matrix.os.arch }}" >> $env:GITHUB_ENV + - name: setup ffmpeg + run: | + wget https://sourceforge.net/projects/avbuild/files/windows-desktop/ffmpeg-6.1-windows-desktop-vs2022-lite.7z + 7z x ffmpeg-6.1-windows-desktop-vs2022-lite.7z + Move-Item -Force ffmpeg-6.1-windows-desktop-vs2022-lite ffmpeg + mkdir ${{ github.workspace }}/ffmpeg/cmake -Force + cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ + echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $GITHUB_ENV + - name: build + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build; cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A ${{ matrix.os.arch }} ` + -DCMAKE_SYSTEM_NAME=Windows ` + -DCMAKE_SYSTEM_PROCESSOR=${{ matrix.os.arch }} ` + $(type ${{ github.workspace }}/options.txt) ` + -DBUILD_opencv_world=OFF ` + -DWITH_IPP=OFF ` + -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" ` + -DCMAKE_POLICY_DEFAULT_CMP0074=NEW ` + -DFFMPEG_ARCH=${{ matrix.os.arch }} ` + .. + cmake --build . --config Release -j 4 + cmake --build . --config Release --target install + - name: package + run: | + mkdir ${{ env.PACKAGE_NAME }} + Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build\install\*" -Destination "${{ env.PACKAGE_NAME }}" + tar -zcvf ${{ env.PACKAGE_NAME }}.tar.gz ${{ env.PACKAGE_NAME }} + - name: test + run: | + cd test + mkdir build; cd build + cmake -T ${{ matrix.os.toolset-version }},host=x64 ` + -DCMAKE_INSTALL_PREFIX=install ` + -A ${{ matrix.os.arch }} ` + -DOpenCV_DIR="${{ github.workspace }}\${{ env.PACKAGE_NAME }}" ` + -DOpenCV_STATIC=ON .. + cmake --build . --config Release -j 4 + - name: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.tar.gz + - name: release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: true + prerelease: false + files: | + ${{ env.PACKAGE_NAME }}.tar.gz diff --git a/cmake/ffmpeg-config.cmake b/cmake/ffmpeg-config.cmake new file mode 100644 index 0000000..fa1f40d --- /dev/null +++ b/cmake/ffmpeg-config.cmake @@ -0,0 +1,258 @@ +#[==[ +find FFMPEG for cmake + +PLACE THIS FILE TO `FFMPEG_ROOT/cmake` + +modified from vtk project: https://gitlab.kitware.com/vtk/vtk/-/blob/master/CMake/FindFFMPEG.cmake +original license: OSI-approved BSD 3-clause License + +Provides the following variables: + + * `FFMPEG_INCLUDE_DIRS`: Include directories necessary to use FFMPEG. + * `FFMPEG_LIBRARIES`: Libraries necessary to use FFMPEG. Note that this only + includes libraries for the components requested. + * `FFMPEG_VERSION`: The version of FFMPEG found. + +The following components are supported: + + * `avcodec` + * `avdevice` + * `avfilter` + * `avformat` + * `avresample` + * `avutil` + * `swresample` + * `swscale` + +For each component, the following are provided: + + * `FFMPEG__FOUND`: Libraries for the component. + * `FFMPEG__INCLUDE_DIRS`: Include directories for + the component. + * `FFMPEG__LIBRARIES`: Libraries for the component. + * `FFMPEG::`: A target to use with `target_link_libraries`. + +Note that only components requested with `COMPONENTS` or `OPTIONAL_COMPONENTS` +are guaranteed to set these variables or provide targets. +#]==] + +if(NOT DEFINED FFMPEG_ROOT) + get_filename_component(FFMPEG_ROOT "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) +endif() + +# some builds have multiple architectures like `lib/arm64` +if(NOT DEFINED FFMPEG_ARCH) + message(WARNING "FFMPEG_ARCH not defined, set to: ${CMAKE_SYSTEM_PROCESSOR}") + string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} FFMPEG_ARCH) +endif() + +message(STATUS "FFMPEG_ROOT: ${FFMPEG_ROOT}") + +function(_ffmpeg_find component headername) + find_path("FFMPEG_${component}_INCLUDE_DIR" + NAMES + "lib${component}/${headername}" + PATHS + "${FFMPEG_ROOT}/include" + ~/Library/Frameworks + /Library/Frameworks + /usr/local/include + /usr/include + /sw/include # Fink + /opt/local/include # DarwinPorts + /opt/csw/include # Blastwave + /opt/include + /usr/freeware/include + PATH_SUFFIXES + ffmpeg + DOC "FFMPEG's ${component} include directory") + mark_as_advanced("FFMPEG_${component}_INCLUDE_DIR") + + # On Windows, static FFMPEG is sometimes built as `lib.a`. + if(WIN32) + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".a" ".lib") + list(APPEND CMAKE_FIND_LIBRARY_PREFIXES "" "lib") + endif() + + find_library("FFMPEG_${component}_LIBRARY" + NAMES + "${component}" + PATHS + "${FFMPEG_ROOT}/lib" + "${FFMPEG_ROOT}/lib/${ARCH}" + ~/Library/Frameworks + /Library/Frameworks + /usr/local/lib + /usr/local/lib64 + /usr/lib + /usr/lib64 + /sw/lib + /opt/local/lib + /opt/csw/lib + /opt/lib + /usr/freeware/lib64 + "${FFMPEG_ROOT}/bin" + "${FFMPEG_ROOT}/bin/${ARCH}" + DOC "FFMPEG's ${component} library") + mark_as_advanced("FFMPEG_${component}_LIBRARY") + + if(FFMPEG_${component}_LIBRARY AND FFMPEG_${component}_INCLUDE_DIR) + set(_deps_found TRUE) + set(_deps_link) + + foreach(_ffmpeg_dep IN LISTS ARGN) + if(TARGET "FFMPEG::${_ffmpeg_dep}") + list(APPEND _deps_link "FFMPEG::${_ffmpeg_dep}") + else() + set(_deps_found FALSE) + endif() + endforeach() + + if(_deps_found) + if(NOT TARGET "FFMPEG::${component}") + add_library("FFMPEG::${component}" UNKNOWN IMPORTED) + set_target_properties("FFMPEG::${component}" PROPERTIES + IMPORTED_LOCATION "${FFMPEG_${component}_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${FFMPEG_${component}_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LIBRARIES "${_deps_link}") + endif() + + set("FFMPEG_${component}_FOUND" 1 + PARENT_SCOPE) + + # get version + if(EXISTS "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version.h") + # get major version from version_major if version_major.h exists + if(EXISTS "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version_major.h") + set(_major_version_file "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version_major.h") + else() + # otherwise get major version from version.h + set(_major_version_file "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version.h") + endif() + + # get major version + file( + STRINGS + ${_major_version_file} + _version_string + REGEX "^.*VERSION_MAJOR[ \t]+[0-9]+[ \t]*$" + ) + string(REGEX REPLACE ".*VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" _version_major "${_version_string}") + + # get minor and micro version + file( + STRINGS + "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version.h" + _version_string + REGEX "^.*VERSION_(MINOR|MICRO)[ \t]+[0-9]+[ \t]*$" + ) + string(REGEX REPLACE ".*VERSION_MINOR[ \t]+([0-9]+).*" "\\1" _version_minor "${_version_string}") + string(REGEX REPLACE ".*VERSION_MICRO[ \t]+([0-9]+).*" "\\1" _version_micro "${_version_string}") + + if(NOT _version_major STREQUAL "" AND + NOT _version_minor STREQUAL "" AND + NOT _version_micro STREQUAL "") + set("FFMPEG_${component}_VERSION" "${_version_major}.${_version_minor}.${_version_micro}" PARENT_SCOPE) + set("FFMPEG_lib${component}_VERSION" "${_version_major}.${_version_minor}.${_version_micro}" CACHE INTERNAL "") + endif() + + message(STATUS "found ${component}: ${_version_major}.${_version_minor}.${_version_micro}") + endif() + + set(version_header_path "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version.h") + + else() + set("FFMPEG_${component}_FOUND" 0 + PARENT_SCOPE) + set(what) + + if(NOT FFMPEG_${component}_LIBRARY) + set(what "library") + endif() + + if(NOT FFMPEG_${component}_INCLUDE_DIR) + if(what) + string(APPEND what " or headers") + else() + set(what "headers") + endif() + endif() + + set("FFMPEG_${component}_NOT_FOUND_MESSAGE" + "Could not find the ${what} for ${component}." + PARENT_SCOPE) + endif() + endif() +endfunction() + +_ffmpeg_find(avutil avutil.h) +_ffmpeg_find(avresample avresample.h + avutil) +_ffmpeg_find(swresample swresample.h + avutil) +_ffmpeg_find(swscale swscale.h + avutil) +_ffmpeg_find(avcodec avcodec.h + avutil) +_ffmpeg_find(avformat avformat.h + avcodec avutil) +_ffmpeg_find(avfilter avfilter.h + avutil) +_ffmpeg_find(avdevice avdevice.h + avformat avutil) + +if(NOT FFMPEG_FIND_COMPONENTS) + set(FFMPEG_FIND_COMPONENTS avutil swresample swscale avcodec avformat avfilter avdevice) # optional avresample +endif() + +if(TARGET FFMPEG::avutil) + set(_ffmpeg_version_header_path "${FFMPEG_avutil_INCLUDE_DIR}/libavutil/ffversion.h") + + if(EXISTS "${_ffmpeg_version_header_path}") + file(STRINGS "${_ffmpeg_version_header_path}" _ffmpeg_version + REGEX "FFMPEG_VERSION") + string(REGEX REPLACE ".*\"n?\(.*\)\"" "\\1" FFMPEG_VERSION "${_ffmpeg_version}") + unset(_ffmpeg_version) + else() + set(FFMPEG_VERSION FFMPEG_VERSION-NOTFOUND) + endif() + + unset(_ffmpeg_version_header_path) +endif() + +set(FFMPEG_INCLUDE_DIRS) +set(FFMPEG_LIBRARIES) +set(__ffmpeg_version_vars) +set(_ffmpeg_required_vars) + +foreach(_ffmpeg_component IN LISTS FFMPEG_FIND_COMPONENTS) + if(TARGET "FFMPEG::${_ffmpeg_component}") + set(FFMPEG_${_ffmpeg_component}_INCLUDE_DIRS + "${FFMPEG_${_ffmpeg_component}_INCLUDE_DIR}") + set(FFMPEG_${_ffmpeg_component}_LIBRARIES + "${FFMPEG_${_ffmpeg_component}_LIBRARY}") + list(APPEND FFMPEG_INCLUDE_DIRS + "${FFMPEG_${_ffmpeg_component}_INCLUDE_DIRS}") + list(APPEND FFMPEG_LIBRARIES + "${FFMPEG_${_ffmpeg_component}_LIBRARIES}") + + if(FFMEG_FIND_REQUIRED_${_ffmpeg_component}) + list(APPEND _ffmpeg_required_vars + "FFMPEG_${_ffmpeg_required_vars}_INCLUDE_DIRS" + "FFMPEG_${_ffmpeg_required_vars}_LIBRARIES") + endif() + endif() +endforeach() + +unset(_ffmpeg_component) + +if(FFMPEG_INCLUDE_DIRS) + list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(FFMPEG + REQUIRED_VARS FFMPEG_INCLUDE_DIRS FFMPEG_LIBRARIES ${_ffmpeg_required_vars} + VERSION_VAR FFMPEG_VERSION + HANDLE_COMPONENTS) +unset(_ffmpeg_required_vars) diff --git a/options.txt b/options.txt index 879d403..e4bba0f 100644 --- a/options.txt +++ b/options.txt @@ -9,6 +9,8 @@ -DBUILD_TBB=OFF -DBUILD_ITT=OFF -DWITH_ADE=ON +-DWITH_FFMPEG=ON +-DOPENCV_FFMPEG_USE_FIND_PACKAGE=ON -DWITH_CPUFEATURES=OFF -DWITH_EIGEN=ON -DWITH_HALIDE=OFF From c59087a11990f208fea8fe5f91228c63ee7ae1a0 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Tue, 24 Sep 2024 18:38:17 +0800 Subject: [PATCH 21/41] install wget on windows --- .github/workflows/windows.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 95c05c7..22c3498 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -38,6 +38,7 @@ jobs: echo "PACKAGE_NAME=libopencv-windows-${{ matrix.os.arch }}" >> $env:GITHUB_ENV - name: setup ffmpeg run: | + choco install wget --no-progress wget https://sourceforge.net/projects/avbuild/files/windows-desktop/ffmpeg-6.1-windows-desktop-vs2022-lite.7z 7z x ffmpeg-6.1-windows-desktop-vs2022-lite.7z Move-Item -Force ffmpeg-6.1-windows-desktop-vs2022-lite ffmpeg From 4290a4271d1b61bf69ab2e2bc4b944a8ce3cf3f7 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Tue, 24 Sep 2024 18:51:28 +0800 Subject: [PATCH 22/41] fix android, linux --- .github/workflows/android.yml | 4 +++- .github/workflows/apple.yml | 6 +++--- .github/workflows/linux.yml | 6 +++--- .github/workflows/windows.yml | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index f22fce8..7d09f74 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -32,7 +32,7 @@ jobs: echo "PACKAGE_NAME=libopencv-android-${{ matrix.abi }}" >> $GITHUB_ENV - name: setup ffmpeg run: | - wget -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-6.1-linux-clang-default.tar.xz + wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-6.1-linux-clang-default.tar.xz mkdir -p ffmpeg tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 mkdir -p ${{ github.workspace }}/ffmpeg/cmake @@ -59,6 +59,8 @@ jobs: mkdir -p ${{ env.PACKAGE_NAME }}/ cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ + tree -L 3 ${{ env.FFMPEG_ROOT }} + mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg cp -rf ${{ env.FFMPEG_ROOT }}/include ${{ env.PACKAGE_NAME }}/ffmpeg/ mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg/bin diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml index 0311841..24d5e01 100644 --- a/.github/workflows/apple.yml +++ b/.github/workflows/apple.yml @@ -42,7 +42,7 @@ jobs: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV - name: setup ffmpeg run: | - wget -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/iOS/ffmpeg-6.1-iOS-lite-shared.tar.xz + wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/iOS/ffmpeg-6.1-iOS-lite-shared.tar.xz mkdir -p ffmpeg tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 mkdir -p ${{ github.workspace }}/ffmpeg/cmake @@ -119,7 +119,7 @@ jobs: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV - name: setup ffmpeg run: | - wget -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/iOSSimulator/ffmpeg-6.1-iOSSimulator-lite-shared.tar.xz + wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/iOSSimulator/ffmpeg-6.1-iOSSimulator-lite-shared.tar.xz mkdir -p ffmpeg tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 mkdir -p ${{ github.workspace }}/ffmpeg/cmake @@ -197,7 +197,7 @@ jobs: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV - name: setup ffmpeg run: | - wget -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/macOS/ffmpeg-6.1-macOS-default.tar.xz + wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/macOS/ffmpeg-6.1-macOS-default.tar.xz mkdir -p ffmpeg tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 mkdir -p ${{ github.workspace }}/ffmpeg/cmake diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 7aa26a9..04ca61b 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -32,7 +32,7 @@ jobs: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV - name: setup ffmpeg run: | - wget -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-6.1-linux-clang-default.tar.xz + wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-6.1-linux-clang-default.tar.xz mkdir -p ffmpeg tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 mkdir -p ${{ github.workspace }}/ffmpeg/cmake @@ -117,7 +117,7 @@ jobs: echo "PACKAGE_NAME=libopencv-linux-x64" >> $GITHUB_ENV - name: setup ffmpeg run: | - wget -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-6.1-linux-clang-default.tar.xz + wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-6.1-linux-clang-default.tar.xz mkdir -p ffmpeg tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 mkdir -p ${{ github.workspace }}/ffmpeg/cmake @@ -163,7 +163,7 @@ jobs: cd test mkdir build && cd build cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/x64/${{ env.OPENCV_SUBDIR }} .. + -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} .. cmake --build . -j $(nproc) - name: upload uses: actions/upload-artifact@v4 diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 22c3498..c97b801 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -39,7 +39,7 @@ jobs: - name: setup ffmpeg run: | choco install wget --no-progress - wget https://sourceforge.net/projects/avbuild/files/windows-desktop/ffmpeg-6.1-windows-desktop-vs2022-lite.7z + wget -q https://sourceforge.net/projects/avbuild/files/windows-desktop/ffmpeg-6.1-windows-desktop-vs2022-lite.7z 7z x ffmpeg-6.1-windows-desktop-vs2022-lite.7z Move-Item -Force ffmpeg-6.1-windows-desktop-vs2022-lite ffmpeg mkdir ${{ github.workspace }}/ffmpeg/cmake -Force From d0c1845abff8f9dd830d7cb898b6802e6726ecc5 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Tue, 24 Sep 2024 18:53:03 +0800 Subject: [PATCH 23/41] fix windows --- .github/workflows/windows.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index c97b801..b7991f6 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -16,6 +16,10 @@ jobs: arch: x64, toolset-version: v142, } + - { + arch: arm64, + toolset-version: v142, + } # - { # msvc-version: vs2022, # windows-version: 2022, From 0a5b452bee62d5a189b76977f4cb8a9c93efec8d Mon Sep 17 00:00:00 2001 From: rainy liu Date: Tue, 24 Sep 2024 20:15:28 +0800 Subject: [PATCH 24/41] fix android,linux --- .github/workflows/android.yml | 2 +- .github/workflows/linux.yml | 140 ++++++---------------------------- .github/workflows/windows.yml | 5 -- 3 files changed, 26 insertions(+), 121 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 7d09f74..aefa067 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -32,7 +32,7 @@ jobs: echo "PACKAGE_NAME=libopencv-android-${{ matrix.abi }}" >> $GITHUB_ENV - name: setup ffmpeg run: | - wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-6.1-linux-clang-default.tar.xz + wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/android/ffmpeg-6.1-android-lite.tar.xz mkdir -p ffmpeg tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 mkdir -p ${{ github.workspace }}/ffmpeg/cmake diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 04ca61b..68f0210 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -7,20 +7,29 @@ on: branches: ["main"] jobs: - armlinux: + linux: runs-on: ubuntu-latest strategy: matrix: opencv-version: [4.10.0] + os: + - { arch: arm64, ffmpeg_arch: arm64 } + - { arch: x64, ffmpeg_arch: amd64 } env: COMMON_CMAKE_OPTIONS: | -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ steps: - - name: setup + - name: setup arm64 + if: matrix.os.arch == 'arm64' + run: | + sudo apt-get update + sudo apt-get install g++-aarch64-linux-gnu + - name: setup x64 + if: matrix.os.arch == 'x64' run: | sudo apt-get update - sudo apt-get install g++-arm-linux-gnueabi g++-arm-linux-gnueabihf g++-aarch64-linux-gnu + sudo apt-get install libgtk-3-dev - uses: actions/checkout@v4 - name: setup-opencv-source @@ -28,93 +37,14 @@ jobs: git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $GITHUB_ENV - echo "PACKAGE_NAME=libopencv-linux-arm64" >> $GITHUB_ENV + echo "PACKAGE_NAME=libopencv-linux-${{ matrix.os.arch }}" >> $GITHUB_ENV echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV - - name: setup ffmpeg - run: | - wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-6.1-linux-clang-default.tar.xz - mkdir -p ffmpeg - tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 - mkdir -p ${{ github.workspace }}/ffmpeg/cmake - cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ - echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $GITHUB_ENV - - name: build-aarch64-linux-gnu - run: | - cd ${{ env.SOURCE_DIR }} - mkdir build-aarch64-linux-gnu && cd build-aarch64-linux-gnu - cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ - -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/aarch64-linux-gnu.toolchain.cmake \ - `cat ${{ github.workspace }}/options.txt` \ - -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" \ - -DOPENCV_FFMPEG_USE_FIND_PACKAGE=ON \ - -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ - -DBUILD_opencv_world=OFF \ - -DFFMPEG_ARCH=arm64 .. - cmake --build . -j $(nproc) - cmake --build . --target install - - name: package - run: | - mkdir ${{ env.PACKAGE_NAME }} - cp -rf ${{ env.SOURCE_DIR }}/build-aarch64-linux-gnu/install/* ${{ env.PACKAGE_NAME }}/ - mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg - cp -rf ${{ env.FFMPEG_ROOT }}/include ${{ env.PACKAGE_NAME }}/ffmpeg/ - mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg/bin - cp -rf ${{ env.FFMPEG_ROOT }}/bin/arm64 ${{ env.PACKAGE_NAME }}/ffmpeg/bin - mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg/lib - cp -rf ${{ env.FFMPEG_ROOT }}/lib/arm64 ${{ env.PACKAGE_NAME }}/ffmpeg/lib - cp -rf ${{ env.FFMPEG_ROOT }}/cmake ${{ env.PACKAGE_NAME }}/ffmpeg/cmake - cp -rf ${{ env.FFMPEG_ROOT }}/Changelog ${{ env.PACKAGE_NAME }}/ffmpeg/Changelog - cp -rf ${{ env.FFMPEG_ROOT }}/config-arm64.txt ${{ env.PACKAGE_NAME }}/ffmpeg/config.txt - cp -rf ${{ env.FFMPEG_ROOT }}/COPYING.LGPLv2.1 ${{ env.PACKAGE_NAME }}/ffmpeg/COPYING.LGPLv2.1 - cp -rf ${{ env.FFMPEG_ROOT }}/README.txt ${{ env.PACKAGE_NAME }}/ffmpeg/README.txt - cp -rf ${{ env.FFMPEG_ROOT }}/RELEASE_NOTES ${{ env.PACKAGE_NAME }}/ffmpeg/RELEASE_NOTES - - tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . - - name: test-aarch64-linux-gnu - run: | - cd test - mkdir build-aarch64-linux-gnu && cd build-aarch64-linux-gnu - cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/aarch64-linux-gnu.toolchain.cmake \ - -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} .. - cmake --build . -j $(nproc) - - name: upload - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PACKAGE_NAME }} - path: ${{ env.PACKAGE_NAME }}.tar.gz - - name: release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - draft: true - prerelease: false - files: | - ${{ env.PACKAGE_NAME }}.tar.gz - - linux: - strategy: - matrix: - opencv-version: [4.10.0] - runs-on: ubuntu-22.04 - env: - COMMON_CMAKE_OPTIONS: | - -DCMAKE_INSTALL_PREFIX=install \ - -DCMAKE_BUILD_TYPE=Release \ - steps: - - uses: actions/checkout@v4 - - name: setup - run: | - sudo apt-get update - sudo apt-get install libgtk-3-dev - - name: setup-opencv-source - run: | - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv - git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $GITHUB_ENV - echo "PACKAGE_NAME=libopencv-linux-x64" >> $GITHUB_ENV + if [ "$arch" = "arm64" ]; then + echo "TOOLCHAIN_FILE='-DOPENCV_EXTRA_MODULES_PATH=${{ github.workspace }}/opencv_contrib/modules'" >> $GITHUB_ENV + else + echo "TOOLCHAIN_FILE=" >> $GITHUB_ENV + fi - name: setup ffmpeg run: | wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-6.1-linux-clang-default.tar.xz @@ -129,11 +59,13 @@ jobs: mkdir build && cd build cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ + ${{ env.TOOLCHAIN_FILE }} \ `cat ${{ github.workspace }}/options.txt` \ -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" \ -DOPENCV_FFMPEG_USE_FIND_PACKAGE=ON \ -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ - -DFFMPEG_ARCH=amd64 .. + -DBUILD_opencv_world=OFF \ + -DFFMPEG_ARCH=${{ matrix.os.ffmpeg_arch }} .. cmake --build . -j $(nproc) cmake --build . --target install - name: package @@ -144,25 +76,23 @@ jobs: mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg cp -rf ${{ env.FFMPEG_ROOT }}/include ${{ env.PACKAGE_NAME }}/ffmpeg/ mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg/bin - cp -rf ${{ env.FFMPEG_ROOT }}/bin/amd64 ${{ env.PACKAGE_NAME }}/ffmpeg/bin + cp -rf ${{ env.FFMPEG_ROOT }}/bin/${{ matrix.os.ffmpeg_arch }} ${{ env.PACKAGE_NAME }}/ffmpeg/bin mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg/lib - cp -rf ${{ env.FFMPEG_ROOT }}/lib/amd64 ${{ env.PACKAGE_NAME }}/ffmpeg/lib + cp -rf ${{ env.FFMPEG_ROOT }}/lib/${{ matrix.os.ffmpeg_arch }} ${{ env.PACKAGE_NAME }}/ffmpeg/lib cp -rf ${{ env.FFMPEG_ROOT }}/cmake ${{ env.PACKAGE_NAME }}/ffmpeg/cmake cp -rf ${{ env.FFMPEG_ROOT }}/Changelog ${{ env.PACKAGE_NAME }}/ffmpeg/Changelog - cp -rf ${{ env.FFMPEG_ROOT }}/config-amd64.txt ${{ env.PACKAGE_NAME }}/ffmpeg/config.txt + cp -rf ${{ env.FFMPEG_ROOT }}/config-${{ matrix.os.ffmpeg_arch }}.txt ${{ env.PACKAGE_NAME }}/ffmpeg/config.txt cp -rf ${{ env.FFMPEG_ROOT }}/COPYING.LGPLv2.1 ${{ env.PACKAGE_NAME }}/ffmpeg/COPYING.LGPLv2.1 cp -rf ${{ env.FFMPEG_ROOT }}/README.txt ${{ env.PACKAGE_NAME }}/ffmpeg/README.txt cp -rf ${{ env.FFMPEG_ROOT }}/RELEASE_NOTES ${{ env.PACKAGE_NAME }}/ffmpeg/RELEASE_NOTES tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . - - name: set-opencv-dir - if: matrix.opencv-version == '4.10.0' - run: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV - name: test run: | cd test mkdir build && cd build cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ + ${{ env.TOOLCHAIN_FILE }} \ -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} .. cmake --build . -j $(nproc) - name: upload @@ -178,23 +108,3 @@ jobs: prerelease: false files: | ${{ env.PACKAGE_NAME }}.tar.gz - - # release: - # permissions: - # contents: write # for softprops/action-gh-release to create a release - # needs: [armlinux, ubuntu] - # runs-on: ubuntu-latest - # steps: - # - name: download - # uses: actions/download-artifact@v4 - # with: - # path: artifacts - - # - name: create-release - # uses: softprops/action-gh-release@v2 - # if: startsWith(github.ref, 'refs/tags/') - # with: - # draft: true - # prerelease: false - # token: ${{ secrets.GITHUB_TOKEN }} - # files: artifacts/*/*.tar.gz diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index b7991f6..ba7c2bc 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -20,11 +20,6 @@ jobs: arch: arm64, toolset-version: v142, } - # - { - # msvc-version: vs2022, - # windows-version: 2022, - # toolset-version: v143, - # } runs-on: windows-2019 env: UseMultiToolTask: true From c4c3f9307d9ddc36b1ebb653f1fc974436f94470 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Tue, 24 Sep 2024 20:30:21 +0800 Subject: [PATCH 25/41] fix ffmpeg_root --- .github/workflows/android.yml | 7 ++++--- .github/workflows/apple.yml | 24 ++++++++++++------------ .github/workflows/linux.yml | 16 +++++++++------- .github/workflows/windows.yml | 2 +- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index aefa067..f3a5b12 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -28,8 +28,8 @@ jobs: run: | git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=opencv" >> $GITHUB_ENV - echo "PACKAGE_NAME=libopencv-android-${{ matrix.abi }}" >> $GITHUB_ENV + echo "SOURCE_DIR=opencv" >> $env:GITHUB_ENV + echo "PACKAGE_NAME=libopencv-android-${{ matrix.abi }}" >> $env:GITHUB_ENV - name: setup ffmpeg run: | wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/android/ffmpeg-6.1-android-lite.tar.xz @@ -37,7 +37,7 @@ jobs: tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 mkdir -p ${{ github.workspace }}/ffmpeg/cmake cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ - echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $GITHUB_ENV + echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $env:GITHUB_ENV - name: build run: | cd ${{ env.SOURCE_DIR }} @@ -48,6 +48,7 @@ jobs: `cat ${{ github.workspace }}/options.txt` \ -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ -DBUILD_opencv_world=OFF \ + -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" \ -DFFMPEG_ARCH="${{ matrix.abi }}" \ -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ .. diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml index 24d5e01..148cc36 100644 --- a/.github/workflows/apple.yml +++ b/.github/workflows/apple.yml @@ -37,9 +37,9 @@ jobs: run: | git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $GITHUB_ENV - echo "PACKAGE_NAME=libopencv-ios-arm64" >> $GITHUB_ENV - echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $env:GITHUB_ENV + echo "PACKAGE_NAME=libopencv-ios-arm64" >> $env:GITHUB_ENV + echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $env:GITHUB_ENV - name: setup ffmpeg run: | wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/iOS/ffmpeg-6.1-iOS-lite-shared.tar.xz @@ -47,7 +47,7 @@ jobs: tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 mkdir -p ${{ github.workspace }}/ffmpeg/cmake cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ - echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $GITHUB_ENV + echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $env:GITHUB_ENV - name: build run: | cd ${{ env.SOURCE_DIR }} @@ -114,9 +114,9 @@ jobs: run: | git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $GITHUB_ENV - echo "PACKAGE_NAME=libopencv-iossimulator-${{ matrix.platform.arch }}" >> $GITHUB_ENV - echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $env:GITHUB_ENV + echo "PACKAGE_NAME=libopencv-iossimulator-${{ matrix.platform.arch }}" >> $env:GITHUB_ENV + echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $env:GITHUB_ENV - name: setup ffmpeg run: | wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/iOSSimulator/ffmpeg-6.1-iOSSimulator-lite-shared.tar.xz @@ -124,7 +124,7 @@ jobs: tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 mkdir -p ${{ github.workspace }}/ffmpeg/cmake cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ - echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $GITHUB_ENV + echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $env:GITHUB_ENV - name: build run: | cd ${{ env.SOURCE_DIR }} @@ -192,9 +192,9 @@ jobs: run: | git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $GITHUB_ENV - echo "PACKAGE_NAME=libopencv-macos-${{ matrix.osname.arch }}" >> $GITHUB_ENV - echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $env:GITHUB_ENV + echo "PACKAGE_NAME=libopencv-macos-${{ matrix.osname.arch }}" >> $env:GITHUB_ENV + echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $env:GITHUB_ENV - name: setup ffmpeg run: | wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/macOS/ffmpeg-6.1-macOS-default.tar.xz @@ -202,7 +202,7 @@ jobs: tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 mkdir -p ${{ github.workspace }}/ffmpeg/cmake cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ - echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $GITHUB_ENV + echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $env:GITHUB_ENV - name: build run: | cd ${{ env.SOURCE_DIR }} diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 68f0210..9ef2662 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -36,23 +36,25 @@ jobs: run: | git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $GITHUB_ENV - echo "PACKAGE_NAME=libopencv-linux-${{ matrix.os.arch }}" >> $GITHUB_ENV - echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $GITHUB_ENV + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $env:GITHUB_ENV + echo "PACKAGE_NAME=libopencv-linux-${{ matrix.os.arch }}" >> $env:GITHUB_ENV + echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $env:GITHUB_ENV if [ "$arch" = "arm64" ]; then - echo "TOOLCHAIN_FILE='-DOPENCV_EXTRA_MODULES_PATH=${{ github.workspace }}/opencv_contrib/modules'" >> $GITHUB_ENV + echo "TOOLCHAIN_FILE='-DOPENCV_EXTRA_MODULES_PATH=${{ github.workspace }}/opencv_contrib/modules'" >> $env:GITHUB_ENV else - echo "TOOLCHAIN_FILE=" >> $GITHUB_ENV + echo "TOOLCHAIN_FILE=" >> $env:GITHUB_ENV fi + + echo ${{ env.TOOLCHAIN_FILE }} - name: setup ffmpeg run: | wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-6.1-linux-clang-default.tar.xz mkdir -p ffmpeg - tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 + tar xf ffmpeg.tar.xz -C ffmpeg --strip-components=1 mkdir -p ${{ github.workspace }}/ffmpeg/cmake cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ - echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $GITHUB_ENV + echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $env:GITHUB_ENV - name: build run: | cd ${{ env.SOURCE_DIR }} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index ba7c2bc..a173f4c 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -43,7 +43,7 @@ jobs: Move-Item -Force ffmpeg-6.1-windows-desktop-vs2022-lite ffmpeg mkdir ${{ github.workspace }}/ffmpeg/cmake -Force cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ - echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $GITHUB_ENV + echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $env:GITHUB_ENV - name: build run: | cd ${{ env.SOURCE_DIR }} From a43a0438f3f8b89c300ef4b141faeab4eb555289 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Tue, 24 Sep 2024 20:33:49 +0800 Subject: [PATCH 26/41] fix --- .github/workflows/android.yml | 7 ++++--- .github/workflows/apple.yml | 24 ++++++++++++------------ .github/workflows/linux.yml | 12 ++++++------ .github/workflows/windows.yml | 6 +++--- 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index f3a5b12..2f5347a 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -28,8 +28,8 @@ jobs: run: | git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=opencv" >> $env:GITHUB_ENV - echo "PACKAGE_NAME=libopencv-android-${{ matrix.abi }}" >> $env:GITHUB_ENV + echo "SOURCE_DIR=opencv" >> "$GITHUB_ENV" + echo "PACKAGE_NAME=libopencv-android-${{ matrix.abi }}" >> "$GITHUB_ENV" - name: setup ffmpeg run: | wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/android/ffmpeg-6.1-android-lite.tar.xz @@ -37,9 +37,10 @@ jobs: tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 mkdir -p ${{ github.workspace }}/ffmpeg/cmake cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ - echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $env:GITHUB_ENV + echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> "$GITHUB_ENV" - name: build run: | + echo "$GITHUB_ENV" cd ${{ env.SOURCE_DIR }} mkdir build && cd build cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml index 148cc36..c904f98 100644 --- a/.github/workflows/apple.yml +++ b/.github/workflows/apple.yml @@ -37,9 +37,9 @@ jobs: run: | git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $env:GITHUB_ENV - echo "PACKAGE_NAME=libopencv-ios-arm64" >> $env:GITHUB_ENV - echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $env:GITHUB_ENV + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> "$GITHUB_ENV" + echo "PACKAGE_NAME=libopencv-ios-arm64" >> "$GITHUB_ENV" + echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> "$GITHUB_ENV" - name: setup ffmpeg run: | wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/iOS/ffmpeg-6.1-iOS-lite-shared.tar.xz @@ -47,7 +47,7 @@ jobs: tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 mkdir -p ${{ github.workspace }}/ffmpeg/cmake cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ - echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $env:GITHUB_ENV + echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> "$GITHUB_ENV" - name: build run: | cd ${{ env.SOURCE_DIR }} @@ -114,9 +114,9 @@ jobs: run: | git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $env:GITHUB_ENV - echo "PACKAGE_NAME=libopencv-iossimulator-${{ matrix.platform.arch }}" >> $env:GITHUB_ENV - echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $env:GITHUB_ENV + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> "$GITHUB_ENV" + echo "PACKAGE_NAME=libopencv-iossimulator-${{ matrix.platform.arch }}" >> "$GITHUB_ENV" + echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> "$GITHUB_ENV" - name: setup ffmpeg run: | wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/iOSSimulator/ffmpeg-6.1-iOSSimulator-lite-shared.tar.xz @@ -124,7 +124,7 @@ jobs: tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 mkdir -p ${{ github.workspace }}/ffmpeg/cmake cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ - echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $env:GITHUB_ENV + echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> "$GITHUB_ENV" - name: build run: | cd ${{ env.SOURCE_DIR }} @@ -192,9 +192,9 @@ jobs: run: | git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $env:GITHUB_ENV - echo "PACKAGE_NAME=libopencv-macos-${{ matrix.osname.arch }}" >> $env:GITHUB_ENV - echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $env:GITHUB_ENV + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> "$GITHUB_ENV" + echo "PACKAGE_NAME=libopencv-macos-${{ matrix.osname.arch }}" >> "$GITHUB_ENV" + echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> "$GITHUB_ENV" - name: setup ffmpeg run: | wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/macOS/ffmpeg-6.1-macOS-default.tar.xz @@ -202,7 +202,7 @@ jobs: tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 mkdir -p ${{ github.workspace }}/ffmpeg/cmake cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ - echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $env:GITHUB_ENV + echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> "$GITHUB_ENV" - name: build run: | cd ${{ env.SOURCE_DIR }} diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 9ef2662..6fce97c 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -36,14 +36,14 @@ jobs: run: | git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $env:GITHUB_ENV - echo "PACKAGE_NAME=libopencv-linux-${{ matrix.os.arch }}" >> $env:GITHUB_ENV - echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> $env:GITHUB_ENV + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> "$GITHUB_ENV" + echo "PACKAGE_NAME=libopencv-linux-${{ matrix.os.arch }}" >> "$GITHUB_ENV" + echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> "$GITHUB_ENV" if [ "$arch" = "arm64" ]; then - echo "TOOLCHAIN_FILE='-DOPENCV_EXTRA_MODULES_PATH=${{ github.workspace }}/opencv_contrib/modules'" >> $env:GITHUB_ENV + echo "TOOLCHAIN_FILE='-DOPENCV_EXTRA_MODULES_PATH=${{ github.workspace }}/opencv_contrib/modules'" >> "$GITHUB_ENV" else - echo "TOOLCHAIN_FILE=" >> $env:GITHUB_ENV + echo "TOOLCHAIN_FILE=" >> "$GITHUB_ENV" fi echo ${{ env.TOOLCHAIN_FILE }} @@ -54,7 +54,7 @@ jobs: tar xf ffmpeg.tar.xz -C ffmpeg --strip-components=1 mkdir -p ${{ github.workspace }}/ffmpeg/cmake cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ - echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $env:GITHUB_ENV + echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> "$GITHUB_ENV" - name: build run: | cd ${{ env.SOURCE_DIR }} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index a173f4c..0fa971a 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -33,8 +33,8 @@ jobs: run: | git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=opencv" >> $env:GITHUB_ENV - echo "PACKAGE_NAME=libopencv-windows-${{ matrix.os.arch }}" >> $env:GITHUB_ENV + echo "SOURCE_DIR=opencv" >> "$GITHUB_ENV" + echo "PACKAGE_NAME=libopencv-windows-${{ matrix.os.arch }}" >> "$GITHUB_ENV" - name: setup ffmpeg run: | choco install wget --no-progress @@ -43,7 +43,7 @@ jobs: Move-Item -Force ffmpeg-6.1-windows-desktop-vs2022-lite ffmpeg mkdir ${{ github.workspace }}/ffmpeg/cmake -Force cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ - echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $env:GITHUB_ENV + echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> "$GITHUB_ENV" - name: build run: | cd ${{ env.SOURCE_DIR }} From c54d792bf6129eac03b0a63d8c89a39f8e87a1fd Mon Sep 17 00:00:00 2001 From: rainy liu Date: Tue, 24 Sep 2024 20:36:29 +0800 Subject: [PATCH 27/41] fix ffmpeg-config.cmake --- cmake/ffmpeg-config.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/ffmpeg-config.cmake b/cmake/ffmpeg-config.cmake index fa1f40d..f59f1b1 100644 --- a/cmake/ffmpeg-config.cmake +++ b/cmake/ffmpeg-config.cmake @@ -79,7 +79,7 @@ function(_ffmpeg_find component headername) "${component}" PATHS "${FFMPEG_ROOT}/lib" - "${FFMPEG_ROOT}/lib/${ARCH}" + "${FFMPEG_ROOT}/lib/${FFMPEG_ARCH}" ~/Library/Frameworks /Library/Frameworks /usr/local/lib @@ -92,7 +92,7 @@ function(_ffmpeg_find component headername) /opt/lib /usr/freeware/lib64 "${FFMPEG_ROOT}/bin" - "${FFMPEG_ROOT}/bin/${ARCH}" + "${FFMPEG_ROOT}/bin/${FFMPEG_ARCH}" DOC "FFMPEG's ${component} library") mark_as_advanced("FFMPEG_${component}_LIBRARY") From b0224f1f22322addda5d560ee7e6dc7cd18e07d3 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Tue, 24 Sep 2024 22:58:35 +0800 Subject: [PATCH 28/41] fix --- .github/workflows/android.yml | 16 ++++----- .github/workflows/apple.yml | 64 +++++++++++++---------------------- .github/workflows/linux.yml | 17 ++++------ .github/workflows/windows.yml | 36 +++++++++++++------- cmake/ffmpeg-config.cmake | 56 +++++++++++++++++------------- 5 files changed, 93 insertions(+), 96 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 2f5347a..1672c54 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -21,7 +21,11 @@ jobs: -DANDROID_PLATFORM=android-24 \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ - -DANDROID_STL=c++_static \ + -DANDROID_STL=c++_static \ \ + -DANDROID_ABI="${{ matrix.abi }}" \ + -DANDROID_ARM_NEON=ON \ + -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ + -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ steps: - uses: actions/checkout@v4 - name: setup-opencv-source @@ -43,16 +47,10 @@ jobs: echo "$GITHUB_ENV" cd ${{ env.SOURCE_DIR }} mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - -DANDROID_ABI="${{ matrix.abi }}" \ - -DANDROID_ARM_NEON=ON \ + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ `cat ${{ github.workspace }}/options.txt` \ - -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ - -DBUILD_opencv_world=OFF \ -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" \ - -DFFMPEG_ARCH="${{ matrix.abi }}" \ - -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ - .. + -DFFMPEG_ARCH="${{ matrix.abi }}" cmake --build . -j $(nproc) cmake --build . --target install diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml index c904f98..515a212 100644 --- a/.github/workflows/apple.yml +++ b/.github/workflows/apple.yml @@ -31,6 +31,10 @@ jobs: -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ + -DBUILD_TIFF=OFF \ + -DBUILD_OPENJPEG=OFF \ + -DWITH_OPENCL=OFF \ + -DWITH_OPENCL_SVM=OFF \ steps: - uses: actions/checkout@v4 - name: setup-opencv-source @@ -52,13 +56,10 @@ jobs: run: | cd ${{ env.SOURCE_DIR }} mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} `cat ../../options.txt` \ + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ + `cat ../../options.txt` \ -DPLATFORM=OS64 \ - -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" \ - -DWITH_TIFF=OFF \ - -DWITH_OPENJPEG=OFF \ - -DWITH_OPENCL=OFF \ - -DWITH_OPENCL_SVM=OFF .. + -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" cmake --build . -j 4 cmake --build . --target install - name: package @@ -73,8 +74,9 @@ jobs: run: | cd test mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=OS64 \ - -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} .. + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ + -DPLATFORM=OS64 \ + -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} cmake --build . -j 4 - name: upload uses: actions/upload-artifact@v4 @@ -108,6 +110,10 @@ jobs: -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ + -DBUILD_TIFF=OFF \ + -DBUILD_OPENJPEG=OFF \ + -DWITH_OPENCL=OFF \ + -DWITH_OPENCL_SVM=OFF \ steps: - uses: actions/checkout@v4 - name: setup-opencv-source @@ -129,14 +135,11 @@ jobs: run: | cd ${{ env.SOURCE_DIR }} mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} `cat ../../options.txt` \ + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ + `cat ../../options.txt` \ -DPLATFORM=${{ matrix.platform.name }} \ -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" \ - -DWITH_TIFF=OFF \ - -DWITH_OPENJPEG=OFF \ - -DWITH_OPENCL=OFF \ - -DWITH_OPENCL_SVM=OFF \ - -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON .. + -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON cmake --build . -j 4 cmake --build . --target install - name: package @@ -151,8 +154,9 @@ jobs: run: | cd test mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=${{ matrix.platform.name }} \ - -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} .. + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ + -DPLATFORM=${{ matrix.platform.name }} \ + -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} cmake --build . -j 4 - name: upload uses: actions/upload-artifact@v4 @@ -186,6 +190,7 @@ jobs: -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ + -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ steps: - uses: actions/checkout@v4 - name: setup-opencv-source @@ -207,11 +212,10 @@ jobs: run: | cd ${{ env.SOURCE_DIR }} mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=${{ matrix.osname.platform }} \ + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ + -DPLATFORM=${{ matrix.osname.platform }} \ `cat ../../options.txt` \ - -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" \ - -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ - .. + -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" cmake --build . -j 4 cmake --build . --target install - name: package @@ -243,23 +247,3 @@ jobs: prerelease: false files: | ${{ env.PACKAGE_NAME }}.tar.gz - - # release: - # permissions: - # contents: write # for softprops/action-gh-release to create a release - # needs: [ios, ios-simulator, macos] - # runs-on: macos-14 - # steps: - # - name: download - # uses: actions/download-artifact@v4 - # with: - # path: artifacts - - # - name: create-release - # uses: softprops/action-gh-release@v2 - # if: startsWith(github.ref, 'refs/tags/') - # with: - # draft: true - # prerelease: false - # token: ${{ secrets.GITHUB_TOKEN }} - # files: artifacts/*/*.tar.gz diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 6fce97c..d27a69b 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -19,6 +19,8 @@ jobs: COMMON_CMAKE_OPTIONS: | -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ + -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ steps: - name: setup arm64 if: matrix.os.arch == 'arm64' @@ -39,14 +41,13 @@ jobs: echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> "$GITHUB_ENV" echo "PACKAGE_NAME=libopencv-linux-${{ matrix.os.arch }}" >> "$GITHUB_ENV" echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> "$GITHUB_ENV" - - if [ "$arch" = "arm64" ]; then + - name: set toolchain + run: | + if [ "${{ matrix.os.arch }}" = "arm64" ]; then echo "TOOLCHAIN_FILE='-DOPENCV_EXTRA_MODULES_PATH=${{ github.workspace }}/opencv_contrib/modules'" >> "$GITHUB_ENV" else echo "TOOLCHAIN_FILE=" >> "$GITHUB_ENV" fi - - echo ${{ env.TOOLCHAIN_FILE }} - name: setup ffmpeg run: | wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-6.1-linux-clang-default.tar.xz @@ -59,15 +60,11 @@ jobs: run: | cd ${{ env.SOURCE_DIR }} mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ ${{ env.TOOLCHAIN_FILE }} \ `cat ${{ github.workspace }}/options.txt` \ -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" \ - -DOPENCV_FFMPEG_USE_FIND_PACKAGE=ON \ - -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ - -DBUILD_opencv_world=OFF \ - -DFFMPEG_ARCH=${{ matrix.os.ffmpeg_arch }} .. + -DFFMPEG_ARCH=${{ matrix.os.ffmpeg_arch }} cmake --build . -j $(nproc) cmake --build . --target install - name: package diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 0fa971a..5f63716 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -27,6 +27,12 @@ jobs: -T ${{ matrix.os.toolset-version }},host=x64 ` -DCMAKE_INSTALL_PREFIX=install ` -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" ` + -DCMAKE_POLICY_DEFAULT_CMP0074=NEW ` + -A ${{ matrix.os.arch }} ` + -DCMAKE_SYSTEM_NAME=Windows ` + -DCMAKE_SYSTEM_PROCESSOR=${{ matrix.os.arch }} ` + $(type ${{ github.workspace }}/options.txt) ` + -DFFMPEG_ARCH=${{ matrix.os.arch }} steps: - uses: actions/checkout@v4 - name: setup-opencv-source @@ -44,22 +50,26 @@ jobs: mkdir ${{ github.workspace }}/ffmpeg/cmake -Force cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> "$GITHUB_ENV" - - name: build + - name: make directory run: | cd ${{ env.SOURCE_DIR }} - mkdir build; cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -A ${{ matrix.os.arch }} ` - -DCMAKE_SYSTEM_NAME=Windows ` - -DCMAKE_SYSTEM_PROCESSOR=${{ matrix.os.arch }} ` - $(type ${{ github.workspace }}/options.txt) ` - -DBUILD_opencv_world=OFF ` + mkdir build + - name: generate arm64 + if: ${{ matrix.os.arch }} == 'arm64' + run: | + cd ${{ env.SOURCE_DIR }}/build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. ` -DWITH_IPP=OFF ` - -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" ` - -DCMAKE_POLICY_DEFAULT_CMP0074=NEW ` - -DFFMPEG_ARCH=${{ matrix.os.arch }} ` - .. - cmake --build . --config Release -j 4 - cmake --build . --config Release --target install + -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" + - name: generate x64 + if: ${{ matrix.os.arch }} == 'x64' + run: | + cd ${{ env.SOURCE_DIR }}/build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. ` + -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" + - name: build + run: | + cmake --build . --config Release --target install -j 4 - name: package run: | mkdir ${{ env.PACKAGE_NAME }} diff --git a/cmake/ffmpeg-config.cmake b/cmake/ffmpeg-config.cmake index f59f1b1..ab3f584 100644 --- a/cmake/ffmpeg-config.cmake +++ b/cmake/ffmpeg-config.cmake @@ -46,7 +46,16 @@ if(NOT DEFINED FFMPEG_ARCH) string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} FFMPEG_ARCH) endif() -message(STATUS "FFMPEG_ROOT: ${FFMPEG_ROOT}") +message(STATUS "FFMPEG:") +message(STATUS " FFMPEG_ROOT: ${FFMPEG_ROOT}") +message(STATUS " FFMPEG_ARCH: ${FFMPEG_ARCH}") + +# https://stackoverflow.com/a/46057018/18539998 +if(ANDROID) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH) +endif() function(_ffmpeg_find component headername) find_path("FFMPEG_${component}_INCLUDE_DIR" @@ -65,7 +74,8 @@ function(_ffmpeg_find component headername) /usr/freeware/include PATH_SUFFIXES ffmpeg - DOC "FFMPEG's ${component} include directory") + DOC "FFMPEG's ${component} include directory" + ) mark_as_advanced("FFMPEG_${component}_INCLUDE_DIR") # On Windows, static FFMPEG is sometimes built as `lib.a`. @@ -93,7 +103,8 @@ function(_ffmpeg_find component headername) /usr/freeware/lib64 "${FFMPEG_ROOT}/bin" "${FFMPEG_ROOT}/bin/${FFMPEG_ARCH}" - DOC "FFMPEG's ${component} library") + DOC "FFMPEG's ${component} library" + ) mark_as_advanced("FFMPEG_${component}_LIBRARY") if(FFMPEG_${component}_LIBRARY AND FFMPEG_${component}_INCLUDE_DIR) @@ -114,11 +125,11 @@ function(_ffmpeg_find component headername) set_target_properties("FFMPEG::${component}" PROPERTIES IMPORTED_LOCATION "${FFMPEG_${component}_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${FFMPEG_${component}_INCLUDE_DIR}" - IMPORTED_LINK_INTERFACE_LIBRARIES "${_deps_link}") + IMPORTED_LINK_INTERFACE_LIBRARIES "${_deps_link}" + ) endif() - set("FFMPEG_${component}_FOUND" 1 - PARENT_SCOPE) + set("FFMPEG_${component}_FOUND" 1 PARENT_SCOPE) # get version if(EXISTS "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version.h") @@ -180,26 +191,20 @@ function(_ffmpeg_find component headername) set("FFMPEG_${component}_NOT_FOUND_MESSAGE" "Could not find the ${what} for ${component}." - PARENT_SCOPE) + PARENT_SCOPE + ) endif() endif() endfunction() _ffmpeg_find(avutil avutil.h) -_ffmpeg_find(avresample avresample.h - avutil) -_ffmpeg_find(swresample swresample.h - avutil) -_ffmpeg_find(swscale swscale.h - avutil) -_ffmpeg_find(avcodec avcodec.h - avutil) -_ffmpeg_find(avformat avformat.h - avcodec avutil) -_ffmpeg_find(avfilter avfilter.h - avutil) -_ffmpeg_find(avdevice avdevice.h - avformat avutil) +_ffmpeg_find(avresample avresample.h avutil) +_ffmpeg_find(swresample swresample.h avutil) +_ffmpeg_find(swscale swscale.h avutil) +_ffmpeg_find(avcodec avcodec.h avutil) +_ffmpeg_find(avformat avformat.h avcodec avutil) +_ffmpeg_find(avfilter avfilter.h avutil) +_ffmpeg_find(avdevice avdevice.h avformat avutil) if(NOT FFMPEG_FIND_COMPONENTS) set(FFMPEG_FIND_COMPONENTS avutil swresample swscale avcodec avformat avfilter avdevice) # optional avresample @@ -210,7 +215,8 @@ if(TARGET FFMPEG::avutil) if(EXISTS "${_ffmpeg_version_header_path}") file(STRINGS "${_ffmpeg_version_header_path}" _ffmpeg_version - REGEX "FFMPEG_VERSION") + REGEX "FFMPEG_VERSION" + ) string(REGEX REPLACE ".*\"n?\(.*\)\"" "\\1" FFMPEG_VERSION "${_ffmpeg_version}") unset(_ffmpeg_version) else() @@ -239,7 +245,8 @@ foreach(_ffmpeg_component IN LISTS FFMPEG_FIND_COMPONENTS) if(FFMEG_FIND_REQUIRED_${_ffmpeg_component}) list(APPEND _ffmpeg_required_vars "FFMPEG_${_ffmpeg_required_vars}_INCLUDE_DIRS" - "FFMPEG_${_ffmpeg_required_vars}_LIBRARIES") + "FFMPEG_${_ffmpeg_required_vars}_LIBRARIES" + ) endif() endif() endforeach() @@ -254,5 +261,6 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args(FFMPEG REQUIRED_VARS FFMPEG_INCLUDE_DIRS FFMPEG_LIBRARIES ${_ffmpeg_required_vars} VERSION_VAR FFMPEG_VERSION - HANDLE_COMPONENTS) + HANDLE_COMPONENTS +) unset(_ffmpeg_required_vars) From 4027b78e8134636e0a01426c43aa60f8e494b56c Mon Sep 17 00:00:00 2001 From: rainy liu Date: Tue, 24 Sep 2024 23:14:47 +0800 Subject: [PATCH 29/41] fix --- .github/workflows/android.yml | 9 +++++---- .github/workflows/linux.yml | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 1672c54..a5c1b0d 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -15,14 +15,15 @@ jobs: abi: [armeabi-v7a, arm64-v8a, x86_64] env: COMMON_CMAKE_OPTIONS: | + -G Ninja \ -DCMAKE_POLICY_DEFAULT_CMP0057=NEW \ -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_LATEST_HOME/build/cmake/android.toolchain.cmake \ -DANDROID_USE_LEGACY_TOOLCHAIN_FILE=False \ - -DANDROID_PLATFORM=android-24 \ + -DANDROID_PLATFORM=android-21 \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ - -DANDROID_STL=c++_static \ \ - -DANDROID_ABI="${{ matrix.abi }}" \ + -DANDROID_STL=c++_static \ + -DANDROID_ABI=${{ matrix.abi }} \ -DANDROID_ARM_NEON=ON \ -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ @@ -32,7 +33,7 @@ jobs: run: | git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=opencv" >> "$GITHUB_ENV" + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> "$GITHUB_ENV" echo "PACKAGE_NAME=libopencv-android-${{ matrix.abi }}" >> "$GITHUB_ENV" - name: setup ffmpeg run: | diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index d27a69b..5e695b9 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -44,7 +44,7 @@ jobs: - name: set toolchain run: | if [ "${{ matrix.os.arch }}" = "arm64" ]; then - echo "TOOLCHAIN_FILE='-DOPENCV_EXTRA_MODULES_PATH=${{ github.workspace }}/opencv_contrib/modules'" >> "$GITHUB_ENV" + echo "TOOLCHAIN_FILE='-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/aarch64-linux-gnu.toolchain.cmake'" >> "$GITHUB_ENV" else echo "TOOLCHAIN_FILE=" >> "$GITHUB_ENV" fi From 4d616aa630b68886257a5256828569385fcd6cdf Mon Sep 17 00:00:00 2001 From: rainy liu Date: Tue, 24 Sep 2024 23:23:39 +0800 Subject: [PATCH 30/41] fix --- .github/workflows/android.yml | 1 - .github/workflows/windows.yml | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index a5c1b0d..7b985f9 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -15,7 +15,6 @@ jobs: abi: [armeabi-v7a, arm64-v8a, x86_64] env: COMMON_CMAKE_OPTIONS: | - -G Ninja \ -DCMAKE_POLICY_DEFAULT_CMP0057=NEW \ -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_LATEST_HOME/build/cmake/android.toolchain.cmake \ -DANDROID_USE_LEGACY_TOOLCHAIN_FILE=False \ diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 5f63716..63f88d2 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -32,14 +32,14 @@ jobs: -DCMAKE_SYSTEM_NAME=Windows ` -DCMAKE_SYSTEM_PROCESSOR=${{ matrix.os.arch }} ` $(type ${{ github.workspace }}/options.txt) ` - -DFFMPEG_ARCH=${{ matrix.os.arch }} + -DFFMPEG_ARCH=${{ matrix.os.arch }} ` steps: - uses: actions/checkout@v4 - name: setup-opencv-source run: | git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=opencv" >> "$GITHUB_ENV" + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> "$GITHUB_ENV" echo "PACKAGE_NAME=libopencv-windows-${{ matrix.os.arch }}" >> "$GITHUB_ENV" - name: setup ffmpeg run: | From e205f3cc410cf7d2bea8e1e7f254f1429238ce92 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Tue, 24 Sep 2024 23:31:32 +0800 Subject: [PATCH 31/41] fix --- .github/workflows/android.yml | 4 ++-- .github/workflows/apple.yml | 14 ++++++++------ .github/workflows/linux.yml | 4 ++-- .github/workflows/windows.yml | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 7b985f9..b1f4ecc 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -47,8 +47,8 @@ jobs: echo "$GITHUB_ENV" cd ${{ env.SOURCE_DIR }} mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ - `cat ${{ github.workspace }}/options.txt` \ + cmake `cat ${{ github.workspace }}/options.txt` \ + ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" \ -DFFMPEG_ARCH="${{ matrix.abi }}" cmake --build . -j $(nproc) diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml index 515a212..9af9dd9 100644 --- a/.github/workflows/apple.yml +++ b/.github/workflows/apple.yml @@ -35,6 +35,7 @@ jobs: -DBUILD_OPENJPEG=OFF \ -DWITH_OPENCL=OFF \ -DWITH_OPENCL_SVM=OFF \ + -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ steps: - uses: actions/checkout@v4 - name: setup-opencv-source @@ -56,8 +57,8 @@ jobs: run: | cd ${{ env.SOURCE_DIR }} mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ - `cat ../../options.txt` \ + cmake `cat ${{ github.workspace }}/options.txt` \ + ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ -DPLATFORM=OS64 \ -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" cmake --build . -j 4 @@ -114,6 +115,7 @@ jobs: -DBUILD_OPENJPEG=OFF \ -DWITH_OPENCL=OFF \ -DWITH_OPENCL_SVM=OFF \ + -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ steps: - uses: actions/checkout@v4 - name: setup-opencv-source @@ -135,8 +137,8 @@ jobs: run: | cd ${{ env.SOURCE_DIR }} mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ - `cat ../../options.txt` \ + cmake `cat ${{ github.workspace }}/options.txt` \ + ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ -DPLATFORM=${{ matrix.platform.name }} \ -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" \ -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON @@ -212,9 +214,9 @@ jobs: run: | cd ${{ env.SOURCE_DIR }} mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ + cmake `cat ${{ github.workspace }}/options.txt` \ + ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ -DPLATFORM=${{ matrix.osname.platform }} \ - `cat ../../options.txt` \ -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" cmake --build . -j 4 cmake --build . --target install diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 5e695b9..0aa0a86 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -60,9 +60,9 @@ jobs: run: | cd ${{ env.SOURCE_DIR }} mkdir build && cd build - cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ + cmake `cat ${{ github.workspace }}/options.txt` \ + ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ ${{ env.TOOLCHAIN_FILE }} \ - `cat ${{ github.workspace }}/options.txt` \ -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" \ -DFFMPEG_ARCH=${{ matrix.os.ffmpeg_arch }} cmake --build . -j $(nproc) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 63f88d2..bf89fee 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -24,6 +24,7 @@ jobs: env: UseMultiToolTask: true COMMON_CMAKE_OPTIONS: | + $(type ${{ github.workspace }}/options.txt) ` -T ${{ matrix.os.toolset-version }},host=x64 ` -DCMAKE_INSTALL_PREFIX=install ` -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" ` @@ -31,7 +32,6 @@ jobs: -A ${{ matrix.os.arch }} ` -DCMAKE_SYSTEM_NAME=Windows ` -DCMAKE_SYSTEM_PROCESSOR=${{ matrix.os.arch }} ` - $(type ${{ github.workspace }}/options.txt) ` -DFFMPEG_ARCH=${{ matrix.os.arch }} ` steps: - uses: actions/checkout@v4 From 620679d3779e2fa6387be7c347f486c97d299189 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Tue, 24 Sep 2024 23:39:24 +0800 Subject: [PATCH 32/41] fix windows --- .github/workflows/windows.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index bf89fee..1669db7 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -39,8 +39,8 @@ jobs: run: | git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib - echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> "$GITHUB_ENV" - echo "PACKAGE_NAME=libopencv-windows-${{ matrix.os.arch }}" >> "$GITHUB_ENV" + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $env:GITHUB_ENV + echo "PACKAGE_NAME=libopencv-windows-${{ matrix.os.arch }}" >> $env:GITHUB_ENV - name: setup ffmpeg run: | choco install wget --no-progress @@ -49,7 +49,7 @@ jobs: Move-Item -Force ffmpeg-6.1-windows-desktop-vs2022-lite ffmpeg mkdir ${{ github.workspace }}/ffmpeg/cmake -Force cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ - echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> "$GITHUB_ENV" + echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $env:GITHUB_ENV - name: make directory run: | cd ${{ env.SOURCE_DIR }} From 984efa3d68447a01d0b8aaa904985effa141828e Mon Sep 17 00:00:00 2001 From: rainy liu Date: Tue, 24 Sep 2024 23:45:50 +0800 Subject: [PATCH 33/41] fix windows --- .github/workflows/windows.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 1669db7..1149e58 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -69,6 +69,7 @@ jobs: -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" - name: build run: | + cd ${{ env.SOURCE_DIR }}/build cmake --build . --config Release --target install -j 4 - name: package run: | From 0538ed4135bdc3641ab5e73e251207aa6cad33c9 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Wed, 25 Sep 2024 23:23:04 +0800 Subject: [PATCH 34/41] fix --- .github/workflows/android.yml | 40 +-- .github/workflows/apple.yml | 42 ++- .github/workflows/linux.yml | 39 +-- .github/workflows/windows.yml | 118 +++++-- cmake/ffmpeg-config.cmake | 570 ++++++++++++++++++++++------------ 5 files changed, 536 insertions(+), 273 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index b1f4ecc..33be958 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -5,6 +5,9 @@ on: - "*" pull_request: branches: ["main"] +env: + ANDROID_PLATFORM: android-21 + FFMPEG_ROOT: /tmp/ffmpeg jobs: android: @@ -18,7 +21,7 @@ jobs: -DCMAKE_POLICY_DEFAULT_CMP0057=NEW \ -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_LATEST_HOME/build/cmake/android.toolchain.cmake \ -DANDROID_USE_LEGACY_TOOLCHAIN_FILE=False \ - -DANDROID_PLATFORM=android-21 \ + -DANDROID_PLATFORM=$ANDROID_PLATFORM \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_BUILD_TYPE=Release \ -DANDROID_STL=c++_static \ @@ -37,11 +40,21 @@ jobs: - name: setup ffmpeg run: | wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/android/ffmpeg-6.1-android-lite.tar.xz - mkdir -p ffmpeg - tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 - mkdir -p ${{ github.workspace }}/ffmpeg/cmake - cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ + mkdir -p tmp + tar xvf ffmpeg.tar.xz -C tmp --strip-components=1 + + mkdir -p $FFMPEG_ROOT + cp -rf tmp/include $FFMPEG_ROOT + cp -rf tmp/lib/${{ matrix.abi }} $FFMPEG_ROOT/lib + cp -rf tmp/bin/${{ matrix.abi }} $FFMPEG_ROOT/bin + cp -rf tmp/COPYING.LGPLv2.1 $FFMPEG_ROOT + cp -rf tmp/RELEASE_NOTES $FFMPEG_ROOT + + mkdir -p $FFMPEG_ROOT/cmake + cp -rf ${{ github.workspace }}/cmake/ffmpeg-config.cmake $FFMPEG_ROOT/cmake/ echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> "$GITHUB_ENV" + + rm -rf tmp - name: build run: | echo "$GITHUB_ENV" @@ -49,7 +62,7 @@ jobs: mkdir build && cd build cmake `cat ${{ github.workspace }}/options.txt` \ ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ - -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" \ + -DFFMPEG_DIR="$FFMPEG_ROOT/cmake" \ -DFFMPEG_ARCH="${{ matrix.abi }}" cmake --build . -j $(nproc) cmake --build . --target install @@ -59,20 +72,7 @@ jobs: mkdir -p ${{ env.PACKAGE_NAME }}/ cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ - tree -L 3 ${{ env.FFMPEG_ROOT }} - - mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg - cp -rf ${{ env.FFMPEG_ROOT }}/include ${{ env.PACKAGE_NAME }}/ffmpeg/ - mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg/bin - cp -rf ${{ env.FFMPEG_ROOT }}/bin/${{ matrix.abi }} ${{ env.PACKAGE_NAME }}/ffmpeg/bin - mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg/lib - cp -rf ${{ env.FFMPEG_ROOT }}/lib/${{ matrix.abi }} ${{ env.PACKAGE_NAME }}/ffmpeg/lib - cp -rf ${{ env.FFMPEG_ROOT }}/cmake ${{ env.PACKAGE_NAME }}/ffmpeg/cmake - cp -rf ${{ env.FFMPEG_ROOT }}/Changelog ${{ env.PACKAGE_NAME }}/ffmpeg/Changelog - cp -rf ${{ env.FFMPEG_ROOT }}/config-${{ matrix.abi }}.txt ${{ env.PACKAGE_NAME }}/ffmpeg/config.txt - cp -rf ${{ env.FFMPEG_ROOT }}/COPYING.LGPLv2.1 ${{ env.PACKAGE_NAME }}/ffmpeg/COPYING.LGPLv2.1 - cp -rf ${{ env.FFMPEG_ROOT }}/README.txt ${{ env.PACKAGE_NAME }}/ffmpeg/README.txt - cp -rf ${{ env.FFMPEG_ROOT }}/RELEASE_NOTES ${{ env.PACKAGE_NAME }}/ffmpeg/RELEASE_NOTES + cp -rf $FFMPEG_ROOT ${{ env.PACKAGE_NAME }}/ffmpeg tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . - name: test diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml index 9af9dd9..9ca6bf8 100644 --- a/.github/workflows/apple.yml +++ b/.github/workflows/apple.yml @@ -14,6 +14,7 @@ env: ENABLE_BITCODE: OFF ENABLE_ARC: OFF ENABLE_VISIBILITY: OFF + FFMPEG_ROOT: /tmp/ffmpeg jobs: ios: @@ -48,11 +49,10 @@ jobs: - name: setup ffmpeg run: | wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/iOS/ffmpeg-6.1-iOS-lite-shared.tar.xz - mkdir -p ffmpeg - tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 - mkdir -p ${{ github.workspace }}/ffmpeg/cmake - cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ - echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> "$GITHUB_ENV" + mkdir -p $FFMPEG_ROOT + tar xvf ffmpeg.tar.xz -C $FFMPEG_ROOT --strip-components=1 + mkdir -p $FFMPEG_ROOT/cmake + cp -rf ${{ github.workspace }}/cmake/ffmpeg-config.cmake $FFMPEG_ROOT/cmake/ - name: build run: | cd ${{ env.SOURCE_DIR }} @@ -60,7 +60,7 @@ jobs: cmake `cat ${{ github.workspace }}/options.txt` \ ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ -DPLATFORM=OS64 \ - -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" + -DFFMPEG_DIR="$FFMPEG_ROOT/cmake" cmake --build . -j 4 cmake --build . --target install - name: package @@ -68,7 +68,7 @@ jobs: mkdir -p ${{ env.PACKAGE_NAME }}/ cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ - cp -rf ${{ env.FFMPEG_ROOT }} ${{ env.PACKAGE_NAME }}/ffmpeg + cp -rf $FFMPEG_ROOT ${{ env.PACKAGE_NAME }}/ffmpeg tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . - name: test @@ -128,11 +128,10 @@ jobs: - name: setup ffmpeg run: | wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/iOSSimulator/ffmpeg-6.1-iOSSimulator-lite-shared.tar.xz - mkdir -p ffmpeg - tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 - mkdir -p ${{ github.workspace }}/ffmpeg/cmake - cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ - echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> "$GITHUB_ENV" + mkdir -p $FFMPEG_ROOT + tar xvf ffmpeg.tar.xz -C $FFMPEG_ROOT --strip-components=1 + mkdir -p $FFMPEG_ROOT/cmake + cp -rf ${{ github.workspace }}/cmake/ffmpeg-config.cmake $FFMPEG_ROOT/cmake/ - name: build run: | cd ${{ env.SOURCE_DIR }} @@ -140,7 +139,7 @@ jobs: cmake `cat ${{ github.workspace }}/options.txt` \ ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ -DPLATFORM=${{ matrix.platform.name }} \ - -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" \ + -DFFMPEG_DIR="$FFMPEG_ROOT/cmake" \ -DOPENCV_DISABLE_FILESYSTEM_SUPPORT=ON cmake --build . -j 4 cmake --build . --target install @@ -149,7 +148,7 @@ jobs: mkdir -p ${{ env.PACKAGE_NAME }}/ cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ - cp -rf ${{ env.FFMPEG_ROOT }} ${{ env.PACKAGE_NAME }}/ffmpeg + cp -rf $FFMPEG_ROOT ${{ env.PACKAGE_NAME }}/ffmpeg tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . - name: test @@ -204,12 +203,11 @@ jobs: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> "$GITHUB_ENV" - name: setup ffmpeg run: | - wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/macOS/ffmpeg-6.1-macOS-default.tar.xz - mkdir -p ffmpeg - tar xvf ffmpeg.tar.xz -C ffmpeg --strip-components=1 - mkdir -p ${{ github.workspace }}/ffmpeg/cmake - cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ - echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> "$GITHUB_ENV" + wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/macOS/ffmpeg-6.1-macOS-lite.tar.xz + mkdir -p $FFMPEG_ROOT + tar xvf ffmpeg.tar.xz -C $FFMPEG_ROOT --strip-components=1 + mkdir -p $FFMPEG_ROOT/cmake + cp -rf ${{ github.workspace }}/cmake/ffmpeg-config.cmake $FFMPEG_ROOT/cmake/ - name: build run: | cd ${{ env.SOURCE_DIR }} @@ -217,7 +215,7 @@ jobs: cmake `cat ${{ github.workspace }}/options.txt` \ ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ -DPLATFORM=${{ matrix.osname.platform }} \ - -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" + -DFFMPEG_DIR="$FFMPEG_ROOT/cmake" cmake --build . -j 4 cmake --build . --target install - name: package @@ -225,7 +223,7 @@ jobs: mkdir -p ${{ env.PACKAGE_NAME }}/ cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ - cp -rf ${{ env.FFMPEG_ROOT }} ${{ env.PACKAGE_NAME }}/ffmpeg + cp -rf $FFMPEG_ROOT ${{ env.PACKAGE_NAME }}/ffmpeg tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . - name: test diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 0aa0a86..9746b2e 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -6,6 +6,10 @@ on: pull_request: branches: ["main"] +env: + ANDROID_PLATFORM: android-21 + FFMPEG_ROOT: /tmp/ffmpeg + jobs: linux: runs-on: ubuntu-latest @@ -50,12 +54,22 @@ jobs: fi - name: setup ffmpeg run: | - wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-6.1-linux-clang-default.tar.xz - mkdir -p ffmpeg - tar xf ffmpeg.tar.xz -C ffmpeg --strip-components=1 - mkdir -p ${{ github.workspace }}/ffmpeg/cmake - cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ + wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-6.1-linux-clang-lite.tar.xz + mkdir -p tmp + tar xvf ffmpeg.tar.xz -C tmp --strip-components=1 + + mkdir -p $FFMPEG_ROOT + cp -rf tmp/include $FFMPEG_ROOT + cp -rf tmp/lib/${{ matrix.os.ffmpeg_arch }} $FFMPEG_ROOT/lib + cp -rf tmp/bin/${{ matrix.os.ffmpeg_arch }} $FFMPEG_ROOT/bin + cp -rf tmp/COPYING.LGPLv2.1 $FFMPEG_ROOT + cp -rf tmp/RELEASE_NOTES $FFMPEG_ROOT + + mkdir -p $FFMPEG_ROOT/cmake + cp -rf ${{ github.workspace }}/cmake/ffmpeg-config.cmake $FFMPEG_ROOT/cmake/ echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> "$GITHUB_ENV" + + rm -rf tmp - name: build run: | cd ${{ env.SOURCE_DIR }} @@ -63,7 +77,7 @@ jobs: cmake `cat ${{ github.workspace }}/options.txt` \ ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ ${{ env.TOOLCHAIN_FILE }} \ - -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" \ + -DFFMPEG_DIR="$FFMPEG_ROOT/cmake" \ -DFFMPEG_ARCH=${{ matrix.os.ffmpeg_arch }} cmake --build . -j $(nproc) cmake --build . --target install @@ -72,18 +86,7 @@ jobs: mkdir ${{ env.PACKAGE_NAME }} cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ - mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg - cp -rf ${{ env.FFMPEG_ROOT }}/include ${{ env.PACKAGE_NAME }}/ffmpeg/ - mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg/bin - cp -rf ${{ env.FFMPEG_ROOT }}/bin/${{ matrix.os.ffmpeg_arch }} ${{ env.PACKAGE_NAME }}/ffmpeg/bin - mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg/lib - cp -rf ${{ env.FFMPEG_ROOT }}/lib/${{ matrix.os.ffmpeg_arch }} ${{ env.PACKAGE_NAME }}/ffmpeg/lib - cp -rf ${{ env.FFMPEG_ROOT }}/cmake ${{ env.PACKAGE_NAME }}/ffmpeg/cmake - cp -rf ${{ env.FFMPEG_ROOT }}/Changelog ${{ env.PACKAGE_NAME }}/ffmpeg/Changelog - cp -rf ${{ env.FFMPEG_ROOT }}/config-${{ matrix.os.ffmpeg_arch }}.txt ${{ env.PACKAGE_NAME }}/ffmpeg/config.txt - cp -rf ${{ env.FFMPEG_ROOT }}/COPYING.LGPLv2.1 ${{ env.PACKAGE_NAME }}/ffmpeg/COPYING.LGPLv2.1 - cp -rf ${{ env.FFMPEG_ROOT }}/README.txt ${{ env.PACKAGE_NAME }}/ffmpeg/README.txt - cp -rf ${{ env.FFMPEG_ROOT }}/RELEASE_NOTES ${{ env.PACKAGE_NAME }}/ffmpeg/RELEASE_NOTES + cp -rf $FFMPEG_ROOT ${{ env.PACKAGE_NAME }}/ffmpeg tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . - name: test diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 1149e58..c17bf4b 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -12,14 +12,7 @@ jobs: matrix: opencv-version: [4.10.0] os: - - { - arch: x64, - toolset-version: v142, - } - - { - arch: arm64, - toolset-version: v142, - } + - { arch: x64, toolset-version: v142 } runs-on: windows-2019 env: UseMultiToolTask: true @@ -29,9 +22,8 @@ jobs: -DCMAKE_INSTALL_PREFIX=install ` -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" ` -DCMAKE_POLICY_DEFAULT_CMP0074=NEW ` - -A ${{ matrix.os.arch }} ` + -A x64 ` -DCMAKE_SYSTEM_NAME=Windows ` - -DCMAKE_SYSTEM_PROCESSOR=${{ matrix.os.arch }} ` -DFFMPEG_ARCH=${{ matrix.os.arch }} ` steps: - uses: actions/checkout@v4 @@ -43,32 +35,112 @@ jobs: echo "PACKAGE_NAME=libopencv-windows-${{ matrix.os.arch }}" >> $env:GITHUB_ENV - name: setup ffmpeg run: | + echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $env:GITHUB_ENV choco install wget --no-progress wget -q https://sourceforge.net/projects/avbuild/files/windows-desktop/ffmpeg-6.1-windows-desktop-vs2022-lite.7z 7z x ffmpeg-6.1-windows-desktop-vs2022-lite.7z - Move-Item -Force ffmpeg-6.1-windows-desktop-vs2022-lite ffmpeg - mkdir ${{ github.workspace }}/ffmpeg/cmake -Force - cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/ - echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $env:GITHUB_ENV + Move-Item -Force ffmpeg-6.1-windows-desktop-vs2022-lite tmp + mkdir -Force ${{ env.FFMPEG_ROOT }} + + Move-Item -Force tmp/include ${{ env.FFMPEG_ROOT }}/ + Move-Item -Force tmp/bin/${{ matrix.os.arch }} ${{ env.FFMPEG_ROOT }}/bin + Move-Item -Force tmp/lib/${{ matrix.os.arch }} ${{ env.FFMPEG_ROOT }}/lib + Move-Item -Force tmp/COPYING.LGPLv2.1 ${{ env.FFMPEG_ROOT }}/ + Move-Item -Force tmp/RELEASE_NOTES ${{ env.FFMPEG_ROOT }}/ + + mkdir ${{ env.FFMPEG_ROOT }}/cmake -Force + cp -Force ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ env.FFMPEG_ROOT }}/cmake/ + + Remove-Item tmp -Recurse -Force -Confirm:$false - name: make directory run: | cd ${{ env.SOURCE_DIR }} mkdir build - - name: generate arm64 - if: ${{ matrix.os.arch }} == 'arm64' - run: | cd ${{ env.SOURCE_DIR }}/build cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. ` - -DWITH_IPP=OFF ` -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" - - name: generate x64 - if: ${{ matrix.os.arch }} == 'x64' + cmake --build . --config Release --target install -j 4 + - name: package run: | + mkdir ${{ env.PACKAGE_NAME }} + Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build\install\*" -Destination "${{ env.PACKAGE_NAME }}" + tar -zcvf ${{ env.PACKAGE_NAME }}.tar.gz ${{ env.PACKAGE_NAME }} + - name: test + run: | + cd test + mkdir build; cd build + cmake -T ${{ matrix.os.toolset-version }},host=x64 ` + -DCMAKE_INSTALL_PREFIX=install ` + -A x64 ` + -DOpenCV_DIR="${{ github.workspace }}\${{ env.PACKAGE_NAME }}" ` + -DOpenCV_STATIC=ON .. + cmake --build . --config Release -j 4 + - name: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.tar.gz + - name: release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: true + prerelease: false + files: | + ${{ env.PACKAGE_NAME }}.tar.gz + + windows-arm64: + strategy: + matrix: + opencv-version: [4.10.0] + os: + - { arch: arm64, toolset-version: v142 } + runs-on: windows-2019 + env: + UseMultiToolTask: true + COMMON_CMAKE_OPTIONS: | + $(type ${{ github.workspace }}/options.txt) ` + -T ${{ matrix.os.toolset-version }},host=x64 ` + -DCMAKE_INSTALL_PREFIX=install ` + -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" ` + -DCMAKE_POLICY_DEFAULT_CMP0074=NEW ` + -A ARM64 ` + -DCMAKE_SYSTEM_NAME=Windows ` + -DCMAKE_SYSTEM_PROCESSOR=ARM64 ` + -DFFMPEG_ARCH=${{ matrix.os.arch }} ` + steps: + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $env:GITHUB_ENV + echo "PACKAGE_NAME=libopencv-windows-${{ matrix.os.arch }}" >> $env:GITHUB_ENV + - name: setup ffmpeg + run: | + echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $env:GITHUB_ENV + choco install wget --no-progress + wget -q https://sourceforge.net/projects/avbuild/files/windows-desktop/ffmpeg-6.1-windows-desktop-vs2022-lite.7z + 7z x ffmpeg-6.1-windows-desktop-vs2022-lite.7z + Move-Item -Force ffmpeg-6.1-windows-desktop-vs2022-lite tmp + mkdir -Force ${{ env.FFMPEG_ROOT }} + + Move-Item -Force tmp/include ${{ env.FFMPEG_ROOT }}/ + Move-Item -Force tmp/bin/${{ matrix.os.arch }} ${{ env.FFMPEG_ROOT }}/bin + Move-Item -Force tmp/lib/${{ matrix.os.arch }} ${{ env.FFMPEG_ROOT }}/lib + Move-Item -Force tmp/COPYING.LGPLv2.1 ${{ env.FFMPEG_ROOT }}/ + Move-Item -Force tmp/RELEASE_NOTES ${{ env.FFMPEG_ROOT }}/ + + mkdir ${{ env.FFMPEG_ROOT }}/cmake -Force + cp -Force ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ env.FFMPEG_ROOT }}/cmake/ + - name: build + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build cd ${{ env.SOURCE_DIR }}/build cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. ` + -DWITH_IPP=OFF ` -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" - - name: build - run: | cd ${{ env.SOURCE_DIR }}/build cmake --build . --config Release --target install -j 4 - name: package @@ -82,7 +154,7 @@ jobs: mkdir build; cd build cmake -T ${{ matrix.os.toolset-version }},host=x64 ` -DCMAKE_INSTALL_PREFIX=install ` - -A ${{ matrix.os.arch }} ` + -A ARM64 ` -DOpenCV_DIR="${{ github.workspace }}\${{ env.PACKAGE_NAME }}" ` -DOpenCV_STATIC=ON .. cmake --build . --config Release -j 4 diff --git a/cmake/ffmpeg-config.cmake b/cmake/ffmpeg-config.cmake index ab3f584..16441ad 100644 --- a/cmake/ffmpeg-config.cmake +++ b/cmake/ffmpeg-config.cmake @@ -1,40 +1,99 @@ -#[==[ -find FFMPEG for cmake +#[=======================================================================[.rst +FindFFMPEG +---------- -PLACE THIS FILE TO `FFMPEG_ROOT/cmake` +FindModule for FFMPEG and associated libraries -modified from vtk project: https://gitlab.kitware.com/vtk/vtk/-/blob/master/CMake/FindFFMPEG.cmake -original license: OSI-approved BSD 3-clause License +.. versionchanged:: 3.0 + Updated FindModule to CMake standards -Provides the following variables: +Components +^^^^^^^^^^ - * `FFMPEG_INCLUDE_DIRS`: Include directories necessary to use FFMPEG. - * `FFMPEG_LIBRARIES`: Libraries necessary to use FFMPEG. Note that this only - includes libraries for the components requested. - * `FFMPEG_VERSION`: The version of FFMPEG found. +.. versionadded:: 1.0 -The following components are supported: +This module contains provides several components: - * `avcodec` - * `avdevice` - * `avfilter` - * `avformat` - * `avresample` - * `avutil` - * `swresample` - * `swscale` +``avcodec`` +``avdevice`` +``avfilter`` +``avformat`` +``avutil`` +``postproc`` +``swscale`` +``swresample`` -For each component, the following are provided: +Import targets exist for each component. - * `FFMPEG__FOUND`: Libraries for the component. - * `FFMPEG__INCLUDE_DIRS`: Include directories for - the component. - * `FFMPEG__LIBRARIES`: Libraries for the component. - * `FFMPEG::`: A target to use with `target_link_libraries`. +Imported Targets +^^^^^^^^^^^^^^^^ -Note that only components requested with `COMPONENTS` or `OPTIONAL_COMPONENTS` -are guaranteed to set these variables or provide targets. -#]==] +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` targets: + +``FFMPEG::avcodec`` + AVcodec component + +``FFMPEG::avdevice`` + AVdevice component + +``FFMPEG::avfilter`` + AVfilter component + +``FFMPEG::avformat`` + AVformat component + +``FFMPEG::avutil`` + AVutil component + +``FFMPEG::postproc`` + postproc component + +``FFMPEG::swscale`` + SWscale component + +``FFMPEG::swresample`` + SWresample component + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``FFMPEG_FOUND`` + True, if all required components and the core library were found. +``FFMPEG_VERSION`` + Detected version of found FFMPEG libraries. +``FFMPEG_INCLUDE_DIRS`` + Include directories needed for FFMPEG. +``FFMPEG_LIBRARIES`` + Libraries needed to link to FFMPEG. +``FFMPEG_DEFINITIONS`` + Compiler flags required for FFMPEG. + +``FFMPEG__VERSION`` + Detected version of found FFMPEG component library. +``FFMPEG__INCLUDE_DIRS`` + Include directories needed for FFMPEG component. +``FFMPEG__LIBRARIES`` + Libraries needed to link to FFMPEG component. +``FFMPEG__DEFINITIONS`` + Compiler flags required for FFMPEG component. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``FFMPEG__LIBRARY`` + Path to the library component of FFMPEG. +``FFMPEG__INCLUDE_DIR`` + Directory containing ``.h``. + +#]=======================================================================] + +include(FindPackageHandleStandardArgs) if(NOT DEFINED FFMPEG_ROOT) get_filename_component(FFMPEG_ROOT "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) @@ -47,8 +106,8 @@ if(NOT DEFINED FFMPEG_ARCH) endif() message(STATUS "FFMPEG:") -message(STATUS " FFMPEG_ROOT: ${FFMPEG_ROOT}") -message(STATUS " FFMPEG_ARCH: ${FFMPEG_ARCH}") +message(STATUS " FFMPEG_ROOT: ${FFMPEG_ROOT}") +message(STATUS " FFMPEG_ARCH: ${FFMPEG_ARCH}") # https://stackoverflow.com/a/46057018/18539998 if(ANDROID) @@ -57,10 +116,59 @@ if(ANDROID) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH) endif() -function(_ffmpeg_find component headername) - find_path("FFMPEG_${component}_INCLUDE_DIR" - NAMES - "lib${component}/${headername}" +set( + _DEFAULT_COMPONENTS + avcodec + avdevice + avformat + avfilter + avresample + avutil + postproc + swscale + swresample +) + +set(FFMPEG_FIND_COMPONENTS + avcodec + avformat + avutil + swscale +) + +set(component_avcodec libavcodec avcodec avcodec.h) +set(component_avdevice libavdevice avdevice avdevice.h) +set(component_avformat libavformat avformat avformat.h) +set(component_avfilter libavfilter avfilter avfilter.h) +set(component_avresample libavresample avresample avresample.h) +set(component_avutil libavutil avutil avutil.h) +set(component_postproc libpostproc postproc postprocess.h) +set(component_swscale libswscale swscale swscale.h) +set(component_swresample libswresample swresample swresample.h) + +if(NOT FFMPEG_FIND_COMPONENTS) + set(FFMPEG_FIND_COMPONENTS ${_DEFAULT_COMPONENTS}) +endif() + +# ffmpeg_find_component: Find and set up requested FFMPEG component +macro(ffmpeg_find_component component) + list(GET component_${component} 0 component_libname) + list(GET component_${component} 1 component_name) + list(GET component_${component} 2 component_header) + + if(NOT CMAKE_HOST_SYSTEM_NAME MATCHES "Windows") + find_package(PkgConfig) + set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${FFMPEG_ROOT}/lib/pkgconfig") + + if(PKG_CONFIG_FOUND) + pkg_search_module(PC_FFMPEG_${component} QUIET ${component_libname}) + endif() + endif() + + find_path( + FFMPEG_${component}_INCLUDE_DIR + NAMES ${component_libname}/${component_header} ${component_libname}/version.h + HINTS ${PC_FFMPEG_${component}_INCLUDE_DIRS} PATHS "${FFMPEG_ROOT}/include" ~/Library/Frameworks @@ -72,195 +180,277 @@ function(_ffmpeg_find component headername) /opt/csw/include # Blastwave /opt/include /usr/freeware/include - PATH_SUFFIXES - ffmpeg - DOC "FFMPEG's ${component} include directory" + DOC "FFMPEG component ${component_name} include directory" ) - mark_as_advanced("FFMPEG_${component}_INCLUDE_DIR") - # On Windows, static FFMPEG is sometimes built as `lib.a`. - if(WIN32) - list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".a" ".lib") - list(APPEND CMAKE_FIND_LIBRARY_PREFIXES "" "lib") + ffmpeg_check_version() + + if(CMAKE_HOST_SYSTEM_NAME MATCHES "Windows") + find_library( + FFMPEG_${component}_IMPLIB + NAMES ${component_libname} ${component_name} + HINTS ${FFMPEG_ROOT}/lib + PATHS + ${FFMPEG_ROOT}/lib/${FFMPEG_ARCH} + DOC "FFMPEG component ${component_name} import library location" + ) + + ffmpeg_find_dll() + else() + find_library( + FFMPEG_${component}_LIBRARY + NAMES ${component_libname} ${component_name} + HINTS ${PC_FFMPEG_${component}_LIBRARY_DIRS} + PATHS + "${FFMPEG_ROOT}/lib" + "${FFMPEG_ROOT}/lib/${FFMPEG_ARCH}" + ~/Library/Frameworks + /Library/Frameworks + /usr/local/lib + /usr/local/lib64 + /usr/lib + /usr/lib64 + /sw/lib + /opt/local/lib + /opt/csw/lib + /opt/lib + /usr/freeware/lib64 + "${FFMPEG_ROOT}/bin" + "${FFMPEG_ROOT}/bin/${FFMPEG_ARCH}" + DOC "FFMPEG component ${component_name} location" + ) endif() - find_library("FFMPEG_${component}_LIBRARY" - NAMES - "${component}" - PATHS - "${FFMPEG_ROOT}/lib" - "${FFMPEG_ROOT}/lib/${FFMPEG_ARCH}" - ~/Library/Frameworks - /Library/Frameworks - /usr/local/lib - /usr/local/lib64 - /usr/lib - /usr/lib64 - /sw/lib - /opt/local/lib - /opt/csw/lib - /opt/lib - /usr/freeware/lib64 - "${FFMPEG_ROOT}/bin" - "${FFMPEG_ROOT}/bin/${FFMPEG_ARCH}" - DOC "FFMPEG's ${component} library" + if(FFMPEG_${component}_LIBRARY AND FFMPEG_${component}_INCLUDE_DIR) + set(FFMPEG_${component}_FOUND TRUE) + set(FFMPEG_${component}_LIBRARIES ${${_library_var}}) + set(FFMPEG_${component}_INCLUDE_DIRS ${FFMPEG_${component}_INCLUDE_DIR}) + set(FFMPEG_${component}_DEFINITIONS ${PC_FFMPEG_${component}_CFLAGS_OTHER}) + mark_as_advanced(FFMPEG_${component}_LIBRARY FFMPEG_${component}_INCLUDE_DIR FFMPEG_${component}_IMPLIB) + endif() + + message(DEBUG "[FindFFMPEG]: ${component_name}:") + message(DEBUG "[FindFFMPEG]: LIBRARY: ${FFMPEG_${component}_LIBRARY}") + message(DEBUG "[FindFFMPEG]: IMPLIB: ${FFMPEG_${component}_IMPLIB}") + message(DEBUG "[FindFFMPEG]: INCLUDE: ${FFMPEG_${component}_INCLUDE_DIR}") + message(DEBUG "[FindFFMPEG]: DEFINITIONS: ${FFMPEG_${component}_DEFINITIONS}") + message(DEBUG "[FindFFMPEG]: FFMPEG_${component}_VERSION: ${FFMPEG_${component}_VERSION}") + message(DEBUG "[FindFFMPEG]: PC_FFMPEG_${component}_VERSION: ${PC_FFMPEG_${component}_VERSION}") + message(DEBUG "[FindFFMPEG]: PC_FFMPEG_${component}_INCLUDE_DIRS: ${PC_FFMPEG_${component}_INCLUDE_DIRS}") + message(DEBUG "[FindFFMPEG]: PC_FFMPEG_${component}_LIBRARY_DIRS: ${PC_FFMPEG_${component}_LIBRARY_DIRS}") +endmacro() + +# ffmpeg_find_dll: Macro to find DLL for corresponding import library +macro(ffmpeg_find_dll) + cmake_path(GET FFMPEG_${component}_IMPLIB PARENT_PATH _implib_path) + cmake_path(SET _bin_path NORMALIZE "${FFMPEG_ROOT}/bin") + + string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" _dll_version "${FFMPEG_${component}_VERSION}") + + find_program( + FFMPEG_${component}_LIBRARY + NAMES ${component_name}-${_dll_version}.dll + HINTS ${_implib_path} ${_bin_path} + DOC "FFMPEG component ${component_name} DLL location" ) - mark_as_advanced("FFMPEG_${component}_LIBRARY") - if(FFMPEG_${component}_LIBRARY AND FFMPEG_${component}_INCLUDE_DIR) - set(_deps_found TRUE) - set(_deps_link) + if(NOT FFMPEG_${component}_LIBRARY) + set(FFMPEG_${component}_LIBRARY "${FFMPEG_${component}_IMPLIB}") + endif() - foreach(_ffmpeg_dep IN LISTS ARGN) - if(TARGET "FFMPEG::${_ffmpeg_dep}") - list(APPEND _deps_link "FFMPEG::${_ffmpeg_dep}") - else() - set(_deps_found FALSE) - endif() - endforeach() - - if(_deps_found) - if(NOT TARGET "FFMPEG::${component}") - add_library("FFMPEG::${component}" UNKNOWN IMPORTED) - set_target_properties("FFMPEG::${component}" PROPERTIES - IMPORTED_LOCATION "${FFMPEG_${component}_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${FFMPEG_${component}_INCLUDE_DIR}" - IMPORTED_LINK_INTERFACE_LIBRARIES "${_deps_link}" - ) - endif() + unset(_implib_path) + unset(_bin_path) + unset(_dll_version) +endmacro() + +# ffmpeg_check_version: Macro to help extract version number from FFMPEG headers +macro(ffmpeg_check_version) + if(PC_FFMPEG_${component}_VERSION) + set(FFMPEG_${component_libname}_VERSION ${PC_FFMPEG_${component}_VERSION}) + elseif(EXISTS "${FFMPEG_${component}_INCLUDE_DIR}/${component_libname}/version.h") + # get major version from version_major if version_major.h exists + if(EXISTS "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version_major.h") + set(_major_version_file "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version_major.h") + else() + # otherwise get major version from version.h + set(_major_version_file "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version.h") + endif() - set("FFMPEG_${component}_FOUND" 1 PARENT_SCOPE) + # get major version + file( + STRINGS + ${_major_version_file} + _version_string + REGEX "^.*VERSION_MAJOR[ \t]+[0-9]+[ \t]*$" + ) + string(REGEX REPLACE ".*VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" _version_major "${_version_string}") + + # get minor and micro version + file( + STRINGS + "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version.h" + _version_string + REGEX "^.*VERSION_(MINOR|MICRO)[ \t]+[0-9]+[ \t]*$" + ) + string(REGEX REPLACE ".*VERSION_MINOR[ \t]+([0-9]+).*" "\\1" _version_minor "${_version_string}") + string(REGEX REPLACE ".*VERSION_MICRO[ \t]+([0-9]+).*" "\\1" _version_micro "${_version_string}") - # get version - if(EXISTS "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version.h") - # get major version from version_major if version_major.h exists - if(EXISTS "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version_major.h") - set(_major_version_file "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version_major.h") - else() - # otherwise get major version from version.h - set(_major_version_file "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version.h") - endif() + if(NOT _version_major STREQUAL "" AND NOT _version_minor STREQUAL "" AND NOT _version_micro STREQUAL "") + set(FFMPEG_${component}_VERSION "${_version_major}.${_version_minor}.${_version_micro}") + set(FFMPEG_${component_libname}_VERSION "${_version_major}.${_version_minor}.${_version_micro}") + message(DEBUG "[FindFFMPEG]: found ${component}: ${_version_major}.${_version_minor}.${_version_micro}") + else() + message(AUTHOR_WARNING "Failed to find ${component_name} version.") + endif() - # get major version - file( - STRINGS - ${_major_version_file} - _version_string - REGEX "^.*VERSION_MAJOR[ \t]+[0-9]+[ \t]*$" - ) - string(REGEX REPLACE ".*VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" _version_major "${_version_string}") - - # get minor and micro version - file( - STRINGS - "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version.h" - _version_string - REGEX "^.*VERSION_(MINOR|MICRO)[ \t]+[0-9]+[ \t]*$" - ) - string(REGEX REPLACE ".*VERSION_MINOR[ \t]+([0-9]+).*" "\\1" _version_minor "${_version_string}") - string(REGEX REPLACE ".*VERSION_MICRO[ \t]+([0-9]+).*" "\\1" _version_micro "${_version_string}") - - if(NOT _version_major STREQUAL "" AND - NOT _version_minor STREQUAL "" AND - NOT _version_micro STREQUAL "") - set("FFMPEG_${component}_VERSION" "${_version_major}.${_version_minor}.${_version_micro}" PARENT_SCOPE) - set("FFMPEG_lib${component}_VERSION" "${_version_major}.${_version_minor}.${_version_micro}" CACHE INTERNAL "") - endif() + unset(_version_major) + unset(_version_minor) + unset(_version_micro) + unset(_version_string) + unset(_major_version_file) + else() + if(NOT FFMPEG_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find ${component_name} version.") + endif() - message(STATUS "found ${component}: ${_version_major}.${_version_minor}.${_version_micro}") - endif() + set(FFMPEG_${component_libname}_VERSION 0.0.0) + endif() +endmacro() + +# ffmpeg_set_soname: Set SONAME property on imported library targets +macro(ffmpeg_set_soname) + if(CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin") + execute_process( + COMMAND sh -c "otool -D '${FFMPEG_${component}_LIBRARY}' | grep -v '${FFMPEG_${component}_LIBRARY}'" + OUTPUT_VARIABLE _output + RESULT_VARIABLE _result + ) - set(version_header_path "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version.h") + if(_result EQUAL 0 AND _output MATCHES "^@rpath/") + set_property(TARGET FFMPEG::${component} PROPERTY IMPORTED_SONAME "${_output}") + endif() + elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|FreeBSD") + execute_process( + COMMAND sh -c "objdump -p '${FFMPEG_${component}_LIBRARY}' | grep SONAME" + OUTPUT_VARIABLE _output + RESULT_VARIABLE _result + ) - else() - set("FFMPEG_${component}_FOUND" 0 - PARENT_SCOPE) - set(what) + if(_result EQUAL 0) + string(REGEX REPLACE "[ \t]+SONAME[ \t]+([^ \t]+)" "\\1" _soname "${_output}") + set_property(TARGET FFMPEG::${component} PROPERTY IMPORTED_SONAME "${_soname}") + unset(_soname) + endif() + endif() - if(NOT FFMPEG_${component}_LIBRARY) - set(what "library") - endif() + unset(_output) + unset(_result) +endmacro() - if(NOT FFMPEG_${component}_INCLUDE_DIR) - if(what) - string(APPEND what " or headers") +macro(ffmpeg_create_target component) + if(FFMPEG_${component}_FOUND AND NOT TARGET FFMPEG::${component}) + if(IS_ABSOLUTE "${FFMPEG_${component}_LIBRARY}") + if(DEFINED FFMPEG_${component}_IMPLIB) + if(FFMPEG_${component}_IMPLIB STREQUAL FFMPEG_${component}_LIBRARY) + add_library(FFMPEG::${component} STATIC IMPORTED) else() - set(what "headers") + add_library(FFMPEG::${component} SHARED IMPORTED) + set_property(TARGET FFMPEG::${component} PROPERTY IMPORTED_IMPLIB "${FFMPEG_${component}_IMPLIB}") endif() + else() + add_library(FFMPEG::${component} UNKNOWN IMPORTED) + ffmpeg_set_soname() endif() - set("FFMPEG_${component}_NOT_FOUND_MESSAGE" - "Could not find the ${what} for ${component}." - PARENT_SCOPE - ) + set_property(TARGET FFMPEG::${component} PROPERTY IMPORTED_LOCATION "${FFMPEG_${component}_LIBRARY}") + else() + add_library(FFMPEG::${component} INTERFACE IMPORTED) + set_property(TARGET FFMPEG::${component} PROPERTY IMPORTED_LIBNAME "${FFMPEG_${component}_LIBRARY}") endif() - endif() -endfunction() -_ffmpeg_find(avutil avutil.h) -_ffmpeg_find(avresample avresample.h avutil) -_ffmpeg_find(swresample swresample.h avutil) -_ffmpeg_find(swscale swscale.h avutil) -_ffmpeg_find(avcodec avcodec.h avutil) -_ffmpeg_find(avformat avformat.h avcodec avutil) -_ffmpeg_find(avfilter avfilter.h avutil) -_ffmpeg_find(avdevice avdevice.h avformat avutil) + set_target_properties( + FFMPEG::${component} + PROPERTIES + INTERFACE_COMPILE_OPTIONS "${PC_FFMPEG_${component}_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${FFMPEG_${component}_INCLUDE_DIR}" + INSTALL_RPATH "$ORIGIN" + VERSION ${FFMPEG_${component_libname}_VERSION} + ) -if(NOT FFMPEG_FIND_COMPONENTS) - set(FFMPEG_FIND_COMPONENTS avutil swresample swscale avcodec avformat avfilter avdevice) # optional avresample -endif() + # get_target_property(_ffmpeg_interface_libraries FFMPEG::FFMPEG INTERFACE_LINK_LIBRARIES) -if(TARGET FFMPEG::avutil) - set(_ffmpeg_version_header_path "${FFMPEG_avutil_INCLUDE_DIR}/libavutil/ffversion.h") + # if(NOT FFMPEG::${component} IN_LIST _ffmpeg_interface_libraries) + # set_property(TARGET FFMPEG::FFMPEG APPEND PROPERTY INTERFACE_LINK_LIBRARIES FFMPEG::${component}) + # endif() + endif() +endmacro() - if(EXISTS "${_ffmpeg_version_header_path}") - file(STRINGS "${_ffmpeg_version_header_path}" _ffmpeg_version - REGEX "FFMPEG_VERSION" - ) - string(REGEX REPLACE ".*\"n?\(.*\)\"" "\\1" FFMPEG_VERSION "${_ffmpeg_version}") - unset(_ffmpeg_version) - else() - set(FFMPEG_VERSION FFMPEG_VERSION-NOTFOUND) +foreach(component IN LISTS FFMPEG_FIND_COMPONENTS) + if(NOT component IN_LIST _DEFAULT_COMPONENTS) + message(FATAL_ERROR "Unknown FFMPEG component specified: ${component}.") endif() - unset(_ffmpeg_version_header_path) -endif() + if(NOT FFMPEG_${component}_FOUND) + ffmpeg_find_component(${component}) + endif() -set(FFMPEG_INCLUDE_DIRS) -set(FFMPEG_LIBRARIES) -set(__ffmpeg_version_vars) -set(_ffmpeg_required_vars) - -foreach(_ffmpeg_component IN LISTS FFMPEG_FIND_COMPONENTS) - if(TARGET "FFMPEG::${_ffmpeg_component}") - set(FFMPEG_${_ffmpeg_component}_INCLUDE_DIRS - "${FFMPEG_${_ffmpeg_component}_INCLUDE_DIR}") - set(FFMPEG_${_ffmpeg_component}_LIBRARIES - "${FFMPEG_${_ffmpeg_component}_LIBRARY}") - list(APPEND FFMPEG_INCLUDE_DIRS - "${FFMPEG_${_ffmpeg_component}_INCLUDE_DIRS}") - list(APPEND FFMPEG_LIBRARIES - "${FFMPEG_${_ffmpeg_component}_LIBRARIES}") - - if(FFMEG_FIND_REQUIRED_${_ffmpeg_component}) - list(APPEND _ffmpeg_required_vars - "FFMPEG_${_ffmpeg_required_vars}_INCLUDE_DIRS" - "FFMPEG_${_ffmpeg_required_vars}_LIBRARIES" - ) - endif() + if(FFMPEG_${component}_FOUND) + set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${FFMPEG_${component}_LIBRARY}) + set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} ${FFMPEG_${component}_DEFINITIONS}) + set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} ${FFMPEG_${component}_INCLUDE_DIR}) endif() endforeach() -unset(_ffmpeg_component) +if(NOT FFMPEG_avutil_FOUND) + ffmpeg_find_component(avutil) +endif() -if(FFMPEG_INCLUDE_DIRS) - list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS) +if(EXISTS "${FFMPEG_avutil_INCLUDE_DIR}/libavutil/ffversion.h") + file( + STRINGS + "${FFMPEG_avutil_INCLUDE_DIR}/libavutil/ffversion.h" + _version_string + REGEX "FFMPEG_VERSION" + ) + string(REGEX REPLACE ".*\"n?\(.*\)\"" "\\1" FFMPEG_VERSION "${_version_string}") endif() -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(FFMPEG - REQUIRED_VARS FFMPEG_INCLUDE_DIRS FFMPEG_LIBRARIES ${_ffmpeg_required_vars} +unset(_version_string) + +list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS) +list(REMOVE_DUPLICATES FFMPEG_LIBRARIES) +list(REMOVE_DUPLICATES FFMPEG_DEFINITIONS) + +if(CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin|Windows") + set(FFMPEG_ERROR_REASON "Ensure that obs-deps is provided as part of CMAKE_PREFIX_PATH.") +elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|FreeBSD") + set(FFMPEG_ERROR_REASON "Ensure that required FFMPEG libraries are installed on the system.") +endif() + +find_package_handle_standard_args( + FFMPEG + REQUIRED_VARS FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIRS VERSION_VAR FFMPEG_VERSION HANDLE_COMPONENTS + REASON_FAILURE_MESSAGE "${FFMPEG_ERROR_REASON}" +) + +if(FFMPEG_FOUND AND NOT TARGET FFMPEG::FFMPEG) + add_library(FFMPEG::FFMPEG INTERFACE IMPORTED) + + foreach(component IN LISTS FFMPEG_FIND_COMPONENTS) + ffmpeg_create_target(${component}) + + if(FFMPEG_${component}_FOUND) + set_property(TARGET FFMPEG::FFMPEG APPEND PROPERTY INTERFACE_LINK_LIBRARIES FFMPEG::${component}) + endif() + endforeach() +endif() + +include(FeatureSummary) +set_package_properties( + FFMPEG + PROPERTIES + URL "https://www.ffmpeg.org" + DESCRIPTION "A complete, cross-platform solution to record, convert and stream audio and video." ) -unset(_ffmpeg_required_vars) From 6412a5b1b7396e67a6344ac625c79bdccc8937fa Mon Sep 17 00:00:00 2001 From: rainy liu Date: Wed, 25 Sep 2024 23:42:00 +0800 Subject: [PATCH 35/41] fix win linux --- .github/workflows/android.yml | 7 +++---- .github/workflows/apple.yml | 6 +++--- .github/workflows/linux.yml | 4 +--- .github/workflows/windows.yml | 39 +++++++++++++++++++---------------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 33be958..1f43ecd 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -6,7 +6,7 @@ on: pull_request: branches: ["main"] env: - ANDROID_PLATFORM: android-21 + ANDROID_PLATFORM: android-24 FFMPEG_ROOT: /tmp/ffmpeg jobs: @@ -29,6 +29,7 @@ jobs: -DANDROID_ARM_NEON=ON \ -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ + -DWITH_ANDROID_MEDIANDK=ON \ steps: - uses: actions/checkout@v4 - name: setup-opencv-source @@ -41,7 +42,7 @@ jobs: run: | wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/android/ffmpeg-6.1-android-lite.tar.xz mkdir -p tmp - tar xvf ffmpeg.tar.xz -C tmp --strip-components=1 + tar xf ffmpeg.tar.xz -C tmp --strip-components=1 mkdir -p $FFMPEG_ROOT cp -rf tmp/include $FFMPEG_ROOT @@ -52,12 +53,10 @@ jobs: mkdir -p $FFMPEG_ROOT/cmake cp -rf ${{ github.workspace }}/cmake/ffmpeg-config.cmake $FFMPEG_ROOT/cmake/ - echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> "$GITHUB_ENV" rm -rf tmp - name: build run: | - echo "$GITHUB_ENV" cd ${{ env.SOURCE_DIR }} mkdir build && cd build cmake `cat ${{ github.workspace }}/options.txt` \ diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml index 9ca6bf8..5f1486a 100644 --- a/.github/workflows/apple.yml +++ b/.github/workflows/apple.yml @@ -50,7 +50,7 @@ jobs: run: | wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/iOS/ffmpeg-6.1-iOS-lite-shared.tar.xz mkdir -p $FFMPEG_ROOT - tar xvf ffmpeg.tar.xz -C $FFMPEG_ROOT --strip-components=1 + tar xf ffmpeg.tar.xz -C $FFMPEG_ROOT --strip-components=1 mkdir -p $FFMPEG_ROOT/cmake cp -rf ${{ github.workspace }}/cmake/ffmpeg-config.cmake $FFMPEG_ROOT/cmake/ - name: build @@ -129,7 +129,7 @@ jobs: run: | wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/iOSSimulator/ffmpeg-6.1-iOSSimulator-lite-shared.tar.xz mkdir -p $FFMPEG_ROOT - tar xvf ffmpeg.tar.xz -C $FFMPEG_ROOT --strip-components=1 + tar xf ffmpeg.tar.xz -C $FFMPEG_ROOT --strip-components=1 mkdir -p $FFMPEG_ROOT/cmake cp -rf ${{ github.workspace }}/cmake/ffmpeg-config.cmake $FFMPEG_ROOT/cmake/ - name: build @@ -205,7 +205,7 @@ jobs: run: | wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/macOS/ffmpeg-6.1-macOS-lite.tar.xz mkdir -p $FFMPEG_ROOT - tar xvf ffmpeg.tar.xz -C $FFMPEG_ROOT --strip-components=1 + tar xf ffmpeg.tar.xz -C $FFMPEG_ROOT --strip-components=1 mkdir -p $FFMPEG_ROOT/cmake cp -rf ${{ github.workspace }}/cmake/ffmpeg-config.cmake $FFMPEG_ROOT/cmake/ - name: build diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 9746b2e..51efd75 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -7,7 +7,6 @@ on: branches: ["main"] env: - ANDROID_PLATFORM: android-21 FFMPEG_ROOT: /tmp/ffmpeg jobs: @@ -56,7 +55,7 @@ jobs: run: | wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-6.1-linux-clang-lite.tar.xz mkdir -p tmp - tar xvf ffmpeg.tar.xz -C tmp --strip-components=1 + tar xf ffmpeg.tar.xz -C tmp --strip-components=1 mkdir -p $FFMPEG_ROOT cp -rf tmp/include $FFMPEG_ROOT @@ -67,7 +66,6 @@ jobs: mkdir -p $FFMPEG_ROOT/cmake cp -rf ${{ github.workspace }}/cmake/ffmpeg-config.cmake $FFMPEG_ROOT/cmake/ - echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> "$GITHUB_ENV" rm -rf tmp - name: build diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index c17bf4b..755a245 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -6,6 +6,9 @@ on: pull_request: branches: ["main"] +env: + FFMPEG_ROOT: ${{ github.workspace }}/ffmpeg + jobs: windows: strategy: @@ -40,16 +43,16 @@ jobs: wget -q https://sourceforge.net/projects/avbuild/files/windows-desktop/ffmpeg-6.1-windows-desktop-vs2022-lite.7z 7z x ffmpeg-6.1-windows-desktop-vs2022-lite.7z Move-Item -Force ffmpeg-6.1-windows-desktop-vs2022-lite tmp - mkdir -Force ${{ env.FFMPEG_ROOT }} + mkdir -Force $env:FFMPEG_ROOT - Move-Item -Force tmp/include ${{ env.FFMPEG_ROOT }}/ - Move-Item -Force tmp/bin/${{ matrix.os.arch }} ${{ env.FFMPEG_ROOT }}/bin - Move-Item -Force tmp/lib/${{ matrix.os.arch }} ${{ env.FFMPEG_ROOT }}/lib - Move-Item -Force tmp/COPYING.LGPLv2.1 ${{ env.FFMPEG_ROOT }}/ - Move-Item -Force tmp/RELEASE_NOTES ${{ env.FFMPEG_ROOT }}/ + Move-Item -Force tmp/include $env:FFMPEG_ROOT/ + Move-Item -Force tmp/bin/${{ matrix.os.arch }} $env:FFMPEG_ROOT/bin + Move-Item -Force tmp/lib/${{ matrix.os.arch }} $env:FFMPEG_ROOT/lib + Move-Item -Force tmp/COPYING.LGPLv2.1 $env:FFMPEG_ROOT/ + Move-Item -Force tmp/RELEASE_NOTES $env:FFMPEG_ROOT/ - mkdir ${{ env.FFMPEG_ROOT }}/cmake -Force - cp -Force ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ env.FFMPEG_ROOT }}/cmake/ + mkdir $env:FFMPEG_ROOT/cmake -Force + cp -Force ${{ github.workspace }}/cmake/ffmpeg-config.cmake $env:FFMPEG_ROOT/cmake/ Remove-Item tmp -Recurse -Force -Confirm:$false - name: make directory @@ -58,7 +61,7 @@ jobs: mkdir build cd ${{ env.SOURCE_DIR }}/build cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. ` - -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" + -DFFMPEG_DIR="$env:FFMPEG_ROOT/cmake" cmake --build . --config Release --target install -j 4 - name: package run: | @@ -123,16 +126,16 @@ jobs: wget -q https://sourceforge.net/projects/avbuild/files/windows-desktop/ffmpeg-6.1-windows-desktop-vs2022-lite.7z 7z x ffmpeg-6.1-windows-desktop-vs2022-lite.7z Move-Item -Force ffmpeg-6.1-windows-desktop-vs2022-lite tmp - mkdir -Force ${{ env.FFMPEG_ROOT }} + mkdir -Force $env:FFMPEG_ROOT - Move-Item -Force tmp/include ${{ env.FFMPEG_ROOT }}/ - Move-Item -Force tmp/bin/${{ matrix.os.arch }} ${{ env.FFMPEG_ROOT }}/bin - Move-Item -Force tmp/lib/${{ matrix.os.arch }} ${{ env.FFMPEG_ROOT }}/lib - Move-Item -Force tmp/COPYING.LGPLv2.1 ${{ env.FFMPEG_ROOT }}/ - Move-Item -Force tmp/RELEASE_NOTES ${{ env.FFMPEG_ROOT }}/ + Move-Item -Force tmp/include $env:FFMPEG_ROOT/ + Move-Item -Force tmp/bin/${{ matrix.os.arch }} $env:FFMPEG_ROOT/bin + Move-Item -Force tmp/lib/${{ matrix.os.arch }} $env:FFMPEG_ROOT/lib + Move-Item -Force tmp/COPYING.LGPLv2.1 $env:FFMPEG_ROOT/ + Move-Item -Force tmp/RELEASE_NOTES $env:FFMPEG_ROOT/ - mkdir ${{ env.FFMPEG_ROOT }}/cmake -Force - cp -Force ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ env.FFMPEG_ROOT }}/cmake/ + mkdir $env:FFMPEG_ROOT/cmake -Force + cp -Force ${{ github.workspace }}/cmake/ffmpeg-config.cmake $env:FFMPEG_ROOT/cmake/ - name: build run: | cd ${{ env.SOURCE_DIR }} @@ -140,7 +143,7 @@ jobs: cd ${{ env.SOURCE_DIR }}/build cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. ` -DWITH_IPP=OFF ` - -DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" + -DFFMPEG_DIR="$env:FFMPEG_ROOT/cmake" cd ${{ env.SOURCE_DIR }}/build cmake --build . --config Release --target install -j 4 - name: package From 69ff918153689bc87ffb4c16f485a1ecd013d9cf Mon Sep 17 00:00:00 2001 From: rainy liu Date: Wed, 25 Sep 2024 23:57:09 +0800 Subject: [PATCH 36/41] add OPENCV_FFMPEG_SKIP_BUILD_CHECK for windows --- .github/workflows/linux.yml | 102 ++++++++++++++++++++++++++++------ .github/workflows/windows.yml | 8 ++- 2 files changed, 91 insertions(+), 19 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 51efd75..6bad83e 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -10,13 +10,12 @@ env: FFMPEG_ROOT: /tmp/ffmpeg jobs: - linux: + linux-x64: runs-on: ubuntu-latest strategy: matrix: opencv-version: [4.10.0] os: - - { arch: arm64, ffmpeg_arch: arm64 } - { arch: x64, ffmpeg_arch: amd64 } env: COMMON_CMAKE_OPTIONS: | @@ -25,13 +24,7 @@ jobs: -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ steps: - - name: setup arm64 - if: matrix.os.arch == 'arm64' - run: | - sudo apt-get update - sudo apt-get install g++-aarch64-linux-gnu - - name: setup x64 - if: matrix.os.arch == 'x64' + - name: setup run: | sudo apt-get update sudo apt-get install libgtk-3-dev @@ -44,13 +37,6 @@ jobs: echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> "$GITHUB_ENV" echo "PACKAGE_NAME=libopencv-linux-${{ matrix.os.arch }}" >> "$GITHUB_ENV" echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> "$GITHUB_ENV" - - name: set toolchain - run: | - if [ "${{ matrix.os.arch }}" = "arm64" ]; then - echo "TOOLCHAIN_FILE='-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/aarch64-linux-gnu.toolchain.cmake'" >> "$GITHUB_ENV" - else - echo "TOOLCHAIN_FILE=" >> "$GITHUB_ENV" - fi - name: setup ffmpeg run: | wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-6.1-linux-clang-lite.tar.xz @@ -74,7 +60,91 @@ jobs: mkdir build && cd build cmake `cat ${{ github.workspace }}/options.txt` \ ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ + -DFFMPEG_DIR="$FFMPEG_ROOT/cmake" \ + -DFFMPEG_ARCH=${{ matrix.os.ffmpeg_arch }} + cmake --build . -j $(nproc) + cmake --build . --target install + - name: package + run: | + mkdir ${{ env.PACKAGE_NAME }} + cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/ + + cp -rf $FFMPEG_ROOT ${{ env.PACKAGE_NAME }}/ffmpeg + + tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . + - name: test + run: | + cd test + mkdir build && cd build + cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ ${{ env.TOOLCHAIN_FILE }} \ + -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} .. + cmake --build . -j $(nproc) + - name: upload + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.tar.gz + - name: release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: true + prerelease: false + files: | + ${{ env.PACKAGE_NAME }}.tar.gz + + linux-arm64: + runs-on: ubuntu-latest + strategy: + matrix: + opencv-version: [4.10.0] + os: + - { arch: arm64, ffmpeg_arch: arm64 } + env: + COMMON_CMAKE_OPTIONS: | + -DCMAKE_INSTALL_PREFIX=install \ + -DCMAKE_BUILD_TYPE=Release \ + -DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \ + -DCMAKE_POLICY_DEFAULT_CMP0074=NEW \ + steps: + - name: setup + run: | + sudo apt-get update + sudo apt-get install g++-aarch64-linux-gnu + + - uses: actions/checkout@v4 + - name: setup-opencv-source + run: | + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv + git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib + echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> "$GITHUB_ENV" + echo "PACKAGE_NAME=libopencv-linux-${{ matrix.os.arch }}" >> "$GITHUB_ENV" + echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> "$GITHUB_ENV" + - name: setup ffmpeg + run: | + wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-6.1-linux-clang-lite.tar.xz + mkdir -p tmp + tar xf ffmpeg.tar.xz -C tmp --strip-components=1 + + mkdir -p $FFMPEG_ROOT + cp -rf tmp/include $FFMPEG_ROOT + cp -rf tmp/lib/${{ matrix.os.ffmpeg_arch }} $FFMPEG_ROOT/lib + cp -rf tmp/bin/${{ matrix.os.ffmpeg_arch }} $FFMPEG_ROOT/bin + cp -rf tmp/COPYING.LGPLv2.1 $FFMPEG_ROOT + cp -rf tmp/RELEASE_NOTES $FFMPEG_ROOT + + mkdir -p $FFMPEG_ROOT/cmake + cp -rf ${{ github.workspace }}/cmake/ffmpeg-config.cmake $FFMPEG_ROOT/cmake/ + + rm -rf tmp + - name: build + run: | + cd ${{ env.SOURCE_DIR }} + mkdir build && cd build + cmake `cat ${{ github.workspace }}/options.txt` \ + ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ + -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/aarch64-linux-gnu.toolchain.cmake \ -DFFMPEG_DIR="$FFMPEG_ROOT/cmake" \ -DFFMPEG_ARCH=${{ matrix.os.ffmpeg_arch }} cmake --build . -j $(nproc) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 755a245..05a9f33 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -55,13 +55,14 @@ jobs: cp -Force ${{ github.workspace }}/cmake/ffmpeg-config.cmake $env:FFMPEG_ROOT/cmake/ Remove-Item tmp -Recurse -Force -Confirm:$false - - name: make directory + - name: build run: | cd ${{ env.SOURCE_DIR }} mkdir build cd ${{ env.SOURCE_DIR }}/build cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. ` - -DFFMPEG_DIR="$env:FFMPEG_ROOT/cmake" + -DFFMPEG_DIR="$env:FFMPEG_ROOT/cmake" ` + -DOPENCV_FFMPEG_SKIP_BUILD_CHECK=ON cmake --build . --config Release --target install -j 4 - name: package run: | @@ -143,7 +144,8 @@ jobs: cd ${{ env.SOURCE_DIR }}/build cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. ` -DWITH_IPP=OFF ` - -DFFMPEG_DIR="$env:FFMPEG_ROOT/cmake" + -DFFMPEG_DIR="$env:FFMPEG_ROOT/cmake" ` + -DOPENCV_FFMPEG_SKIP_BUILD_CHECK=ON cd ${{ env.SOURCE_DIR }}/build cmake --build . --config Release --target install -j 4 - name: package From cec9ede4e161b4c2d3217824b3c74d3de7a61c03 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Thu, 26 Sep 2024 16:30:21 +0800 Subject: [PATCH 37/41] fix --- .github/workflows/android.yml | 1 + .github/workflows/apple.yml | 3 + .github/workflows/linux.yml | 34 +-- .github/workflows/windows.yml | 15 +- cmake/ffmpeg-config.cmake | 529 ++++++++++++++++++---------------- test/CMakeLists.txt | 5 +- 6 files changed, 295 insertions(+), 292 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 1f43ecd..554ad74 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -82,6 +82,7 @@ jobs: -DANDROID_ABI="${{ matrix.abi }}" \ -DANDROID_ARM_NEON=ON \ -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/sdk/native/jni \ + -DFFMPEG_DIR="$FFMPEG_ROOT/cmake" \ .. cmake --build . -j $(nproc) - name: upload diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml index 5f1486a..a45550a 100644 --- a/.github/workflows/apple.yml +++ b/.github/workflows/apple.yml @@ -77,6 +77,7 @@ jobs: mkdir build && cd build cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ -DPLATFORM=OS64 \ + -DFFMPEG_DIR="$FFMPEG_ROOT/cmake" \ -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} cmake --build . -j 4 - name: upload @@ -157,6 +158,7 @@ jobs: mkdir build && cd build cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ -DPLATFORM=${{ matrix.platform.name }} \ + -DFFMPEG_DIR="$FFMPEG_ROOT/cmake" \ -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} cmake --build . -j 4 - name: upload @@ -231,6 +233,7 @@ jobs: cd test mkdir build && cd build cmake ${{ env.COMMON_CMAKE_OPTIONS }} -DPLATFORM=${{ matrix.osname.platform }} \ + -DFFMPEG_DIR="$FFMPEG_ROOT/cmake" \ -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} \ .. cmake --build . -j 4 diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 6bad83e..9741154 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -39,21 +39,12 @@ jobs: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> "$GITHUB_ENV" - name: setup ffmpeg run: | - wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-6.1-linux-clang-lite.tar.xz - mkdir -p tmp - tar xf ffmpeg.tar.xz -C tmp --strip-components=1 - + wget -q -O ffmpeg.tar.xz https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-n6.1-latest-linux64-lgpl-shared-6.1.tar.xz mkdir -p $FFMPEG_ROOT - cp -rf tmp/include $FFMPEG_ROOT - cp -rf tmp/lib/${{ matrix.os.ffmpeg_arch }} $FFMPEG_ROOT/lib - cp -rf tmp/bin/${{ matrix.os.ffmpeg_arch }} $FFMPEG_ROOT/bin - cp -rf tmp/COPYING.LGPLv2.1 $FFMPEG_ROOT - cp -rf tmp/RELEASE_NOTES $FFMPEG_ROOT + tar xf ffmpeg.tar.xz -C $FFMPEG_ROOT --strip-components=1 mkdir -p $FFMPEG_ROOT/cmake cp -rf ${{ github.workspace }}/cmake/ffmpeg-config.cmake $FFMPEG_ROOT/cmake/ - - rm -rf tmp - name: build run: | cd ${{ env.SOURCE_DIR }} @@ -78,7 +69,8 @@ jobs: mkdir build && cd build cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ ${{ env.TOOLCHAIN_FILE }} \ - -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} .. + -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} \ + -DFFMPEG_DIR=$FFMPEG_ROOT/cmake .. cmake --build . -j $(nproc) - name: upload uses: actions/upload-artifact@v4 @@ -123,21 +115,12 @@ jobs: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> "$GITHUB_ENV" - name: setup ffmpeg run: | - wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-6.1-linux-clang-lite.tar.xz - mkdir -p tmp - tar xf ffmpeg.tar.xz -C tmp --strip-components=1 - + wget -q -O ffmpeg.tar.xz https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-n6.1-latest-linuxarm64-lgpl-shared-6.1.tar.xz mkdir -p $FFMPEG_ROOT - cp -rf tmp/include $FFMPEG_ROOT - cp -rf tmp/lib/${{ matrix.os.ffmpeg_arch }} $FFMPEG_ROOT/lib - cp -rf tmp/bin/${{ matrix.os.ffmpeg_arch }} $FFMPEG_ROOT/bin - cp -rf tmp/COPYING.LGPLv2.1 $FFMPEG_ROOT - cp -rf tmp/RELEASE_NOTES $FFMPEG_ROOT + tar xf ffmpeg.tar.xz -C $FFMPEG_ROOT --strip-components=1 mkdir -p $FFMPEG_ROOT/cmake cp -rf ${{ github.workspace }}/cmake/ffmpeg-config.cmake $FFMPEG_ROOT/cmake/ - - rm -rf tmp - name: build run: | cd ${{ env.SOURCE_DIR }} @@ -162,8 +145,9 @@ jobs: cd test mkdir build && cd build cmake ${{ env.COMMON_CMAKE_OPTIONS }} \ - ${{ env.TOOLCHAIN_FILE }} \ - -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} .. + -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/aarch64-linux-gnu.toolchain.cmake \ + -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} \ + -DFFMPEG_DIR=$FFMPEG_ROOT/cmake .. cmake --build . -j $(nproc) - name: upload uses: actions/upload-artifact@v4 diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 05a9f33..75a942c 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -77,6 +77,7 @@ jobs: -DCMAKE_INSTALL_PREFIX=install ` -A x64 ` -DOpenCV_DIR="${{ github.workspace }}\${{ env.PACKAGE_NAME }}" ` + -DFFMPEG_DIR="$env:FFMPEG_ROOT/cmake" ` -DOpenCV_STATIC=ON .. cmake --build . --config Release -j 4 - name: upload @@ -124,16 +125,9 @@ jobs: run: | echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $env:GITHUB_ENV choco install wget --no-progress - wget -q https://sourceforge.net/projects/avbuild/files/windows-desktop/ffmpeg-6.1-windows-desktop-vs2022-lite.7z - 7z x ffmpeg-6.1-windows-desktop-vs2022-lite.7z - Move-Item -Force ffmpeg-6.1-windows-desktop-vs2022-lite tmp - mkdir -Force $env:FFMPEG_ROOT - - Move-Item -Force tmp/include $env:FFMPEG_ROOT/ - Move-Item -Force tmp/bin/${{ matrix.os.arch }} $env:FFMPEG_ROOT/bin - Move-Item -Force tmp/lib/${{ matrix.os.arch }} $env:FFMPEG_ROOT/lib - Move-Item -Force tmp/COPYING.LGPLv2.1 $env:FFMPEG_ROOT/ - Move-Item -Force tmp/RELEASE_NOTES $env:FFMPEG_ROOT/ + wget -q https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-n6.1-latest-win64-lgpl-shared-6.1.zip + unzip -q ffmpeg-n6.1-latest-win64-lgpl-shared-6.1.zip + Move-Item -Force ffmpeg-n6.1-latest-win64-lgpl-shared-6.1 $env:FFMPEG_ROOT mkdir $env:FFMPEG_ROOT/cmake -Force cp -Force ${{ github.workspace }}/cmake/ffmpeg-config.cmake $env:FFMPEG_ROOT/cmake/ @@ -161,6 +155,7 @@ jobs: -DCMAKE_INSTALL_PREFIX=install ` -A ARM64 ` -DOpenCV_DIR="${{ github.workspace }}\${{ env.PACKAGE_NAME }}" ` + -DFFMPEG_DIR="$env:FFMPEG_ROOT/cmake" ` -DOpenCV_STATIC=ON .. cmake --build . --config Release -j 4 - name: upload diff --git a/cmake/ffmpeg-config.cmake b/cmake/ffmpeg-config.cmake index 16441ad..83b5d2a 100644 --- a/cmake/ffmpeg-config.cmake +++ b/cmake/ffmpeg-config.cmake @@ -93,47 +93,48 @@ The following cache variables may also be set: #]=======================================================================] +option(FFMPEG_USE_STATIC_LIBS "Use static libs (only for windows now)" ON) + include(FindPackageHandleStandardArgs) if(NOT DEFINED FFMPEG_ROOT) - get_filename_component(FFMPEG_ROOT "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) + get_filename_component(FFMPEG_ROOT "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) endif() # some builds have multiple architectures like `lib/arm64` if(NOT DEFINED FFMPEG_ARCH) - message(WARNING "FFMPEG_ARCH not defined, set to: ${CMAKE_SYSTEM_PROCESSOR}") - string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} FFMPEG_ARCH) + message(STATUS "FFMPEG_ARCH not defined, set to: ${CMAKE_SYSTEM_PROCESSOR}") + string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} FFMPEG_ARCH) endif() -message(STATUS "FFMPEG:") -message(STATUS " FFMPEG_ROOT: ${FFMPEG_ROOT}") -message(STATUS " FFMPEG_ARCH: ${FFMPEG_ARCH}") +message(STATUS "FFMPEG_ROOT: ${FFMPEG_ROOT}") +message(STATUS "FFMPEG_ARCH: ${FFMPEG_ARCH}") # https://stackoverflow.com/a/46057018/18539998 if(ANDROID) - set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) - set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) - set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH) endif() set( - _DEFAULT_COMPONENTS - avcodec - avdevice - avformat - avfilter - avresample - avutil - postproc - swscale - swresample + _DEFAULT_COMPONENTS + avcodec + avdevice + avformat + avfilter + avresample + avutil + postproc + swscale + swresample ) set(FFMPEG_FIND_COMPONENTS - avcodec - avformat - avutil - swscale + avcodec + avformat + avutil + swscale ) set(component_avcodec libavcodec avcodec avcodec.h) @@ -147,310 +148,328 @@ set(component_swscale libswscale swscale swscale.h) set(component_swresample libswresample swresample swresample.h) if(NOT FFMPEG_FIND_COMPONENTS) - set(FFMPEG_FIND_COMPONENTS ${_DEFAULT_COMPONENTS}) + set(FFMPEG_FIND_COMPONENTS ${_DEFAULT_COMPONENTS}) endif() # ffmpeg_find_component: Find and set up requested FFMPEG component macro(ffmpeg_find_component component) - list(GET component_${component} 0 component_libname) - list(GET component_${component} 1 component_name) - list(GET component_${component} 2 component_header) + list(GET component_${component} 0 component_libname) + list(GET component_${component} 1 component_name) + list(GET component_${component} 2 component_header) - if(NOT CMAKE_HOST_SYSTEM_NAME MATCHES "Windows") - find_package(PkgConfig) - set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${FFMPEG_ROOT}/lib/pkgconfig") + if(NOT CMAKE_HOST_SYSTEM_NAME MATCHES "Windows") + find_package(PkgConfig) + set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${FFMPEG_ROOT}/lib/pkgconfig") - if(PKG_CONFIG_FOUND) - pkg_search_module(PC_FFMPEG_${component} QUIET ${component_libname}) - endif() + if(PKG_CONFIG_FOUND) + pkg_search_module(PC_FFMPEG_${component} QUIET ${component_libname}) endif() - - find_path( - FFMPEG_${component}_INCLUDE_DIR - NAMES ${component_libname}/${component_header} ${component_libname}/version.h - HINTS ${PC_FFMPEG_${component}_INCLUDE_DIRS} - PATHS - "${FFMPEG_ROOT}/include" - ~/Library/Frameworks - /Library/Frameworks - /usr/local/include - /usr/include - /sw/include # Fink - /opt/local/include # DarwinPorts - /opt/csw/include # Blastwave - /opt/include - /usr/freeware/include - DOC "FFMPEG component ${component_name} include directory" + endif() + + find_path( + FFMPEG_${component}_INCLUDE_DIR + NAMES ${component_libname}/${component_header} ${component_libname}/version.h + HINTS ${PC_FFMPEG_${component}_INCLUDE_DIRS} + PATHS + "${FFMPEG_ROOT}/include" + ~/Library/Frameworks + /Library/Frameworks + /usr/local/include + /usr/include + /sw/include # Fink + /opt/local/include # DarwinPorts + /opt/csw/include # Blastwave + /opt/include + /usr/freeware/include + DOC "FFMPEG component ${component_name} include directory" + ) + + ffmpeg_check_version() + + if(CMAKE_HOST_SYSTEM_NAME MATCHES "Windows") + find_library( + FFMPEG_${component}_IMPLIB + NAMES ${component_libname} ${component_name} + HINTS ${FFMPEG_ROOT}/lib + PATHS + ${FFMPEG_ROOT}/lib/${FFMPEG_ARCH} + DOC "FFMPEG component ${component_name} import library location" ) - ffmpeg_check_version() - - if(CMAKE_HOST_SYSTEM_NAME MATCHES "Windows") - find_library( - FFMPEG_${component}_IMPLIB - NAMES ${component_libname} ${component_name} - HINTS ${FFMPEG_ROOT}/lib - PATHS - ${FFMPEG_ROOT}/lib/${FFMPEG_ARCH} - DOC "FFMPEG component ${component_name} import library location" - ) - - ffmpeg_find_dll() + if(FFMPEG_USE_STATIC_LIBS) + set(FFMPEG_${component}_LIBRARY "${FFMPEG_${component}_IMPLIB}") else() - find_library( - FFMPEG_${component}_LIBRARY - NAMES ${component_libname} ${component_name} - HINTS ${PC_FFMPEG_${component}_LIBRARY_DIRS} - PATHS - "${FFMPEG_ROOT}/lib" - "${FFMPEG_ROOT}/lib/${FFMPEG_ARCH}" - ~/Library/Frameworks - /Library/Frameworks - /usr/local/lib - /usr/local/lib64 - /usr/lib - /usr/lib64 - /sw/lib - /opt/local/lib - /opt/csw/lib - /opt/lib - /usr/freeware/lib64 - "${FFMPEG_ROOT}/bin" - "${FFMPEG_ROOT}/bin/${FFMPEG_ARCH}" - DOC "FFMPEG component ${component_name} location" - ) - endif() - - if(FFMPEG_${component}_LIBRARY AND FFMPEG_${component}_INCLUDE_DIR) - set(FFMPEG_${component}_FOUND TRUE) - set(FFMPEG_${component}_LIBRARIES ${${_library_var}}) - set(FFMPEG_${component}_INCLUDE_DIRS ${FFMPEG_${component}_INCLUDE_DIR}) - set(FFMPEG_${component}_DEFINITIONS ${PC_FFMPEG_${component}_CFLAGS_OTHER}) - mark_as_advanced(FFMPEG_${component}_LIBRARY FFMPEG_${component}_INCLUDE_DIR FFMPEG_${component}_IMPLIB) + ffmpeg_find_dll() endif() - message(DEBUG "[FindFFMPEG]: ${component_name}:") - message(DEBUG "[FindFFMPEG]: LIBRARY: ${FFMPEG_${component}_LIBRARY}") - message(DEBUG "[FindFFMPEG]: IMPLIB: ${FFMPEG_${component}_IMPLIB}") - message(DEBUG "[FindFFMPEG]: INCLUDE: ${FFMPEG_${component}_INCLUDE_DIR}") - message(DEBUG "[FindFFMPEG]: DEFINITIONS: ${FFMPEG_${component}_DEFINITIONS}") - message(DEBUG "[FindFFMPEG]: FFMPEG_${component}_VERSION: ${FFMPEG_${component}_VERSION}") - message(DEBUG "[FindFFMPEG]: PC_FFMPEG_${component}_VERSION: ${PC_FFMPEG_${component}_VERSION}") - message(DEBUG "[FindFFMPEG]: PC_FFMPEG_${component}_INCLUDE_DIRS: ${PC_FFMPEG_${component}_INCLUDE_DIRS}") - message(DEBUG "[FindFFMPEG]: PC_FFMPEG_${component}_LIBRARY_DIRS: ${PC_FFMPEG_${component}_LIBRARY_DIRS}") + else() + find_library( + FFMPEG_${component}_LIBRARY + NAMES ${component_libname} ${component_name} + HINTS ${PC_FFMPEG_${component}_LIBRARY_DIRS} + PATHS + "${FFMPEG_ROOT}/lib" + "${FFMPEG_ROOT}/lib/${FFMPEG_ARCH}" + ~/Library/Frameworks + /Library/Frameworks + /usr/local/lib + /usr/local/lib64 + /usr/lib + /usr/lib64 + /sw/lib + /opt/local/lib + /opt/csw/lib + /opt/lib + /usr/freeware/lib64 + "${FFMPEG_ROOT}/bin" + "${FFMPEG_ROOT}/bin/${FFMPEG_ARCH}" + DOC "FFMPEG component ${component_name} location" + ) + endif() + + if(FFMPEG_${component}_LIBRARY AND FFMPEG_${component}_INCLUDE_DIR) + set(FFMPEG_${component}_FOUND TRUE) + set(FFMPEG_${component}_LIBRARIES ${${_library_var}}) + set(FFMPEG_${component}_INCLUDE_DIRS ${FFMPEG_${component}_INCLUDE_DIR}) + set(FFMPEG_${component}_DEFINITIONS ${PC_FFMPEG_${component}_CFLAGS_OTHER}) + mark_as_advanced(FFMPEG_${component}_LIBRARY FFMPEG_${component}_INCLUDE_DIR FFMPEG_${component}_IMPLIB) + endif() + + message(DEBUG "[FindFFMPEG]: ${component_name}:") + message(DEBUG "[FindFFMPEG]: LIBRARY: ${FFMPEG_${component}_LIBRARY}") + message(DEBUG "[FindFFMPEG]: IMPLIB: ${FFMPEG_${component}_IMPLIB}") + message(DEBUG "[FindFFMPEG]: INCLUDE: ${FFMPEG_${component}_INCLUDE_DIR}") + message(DEBUG "[FindFFMPEG]: DEFINITIONS: ${FFMPEG_${component}_DEFINITIONS}") + message(DEBUG "[FindFFMPEG]: FFMPEG_${component}_VERSION: ${FFMPEG_${component}_VERSION}") + message(DEBUG "[FindFFMPEG]: PC_FFMPEG_${component}_VERSION: ${PC_FFMPEG_${component}_VERSION}") + message(DEBUG "[FindFFMPEG]: PC_FFMPEG_${component}_INCLUDE_DIRS: ${PC_FFMPEG_${component}_INCLUDE_DIRS}") + message(DEBUG "[FindFFMPEG]: PC_FFMPEG_${component}_LIBRARY_DIRS: ${PC_FFMPEG_${component}_LIBRARY_DIRS}") endmacro() # ffmpeg_find_dll: Macro to find DLL for corresponding import library macro(ffmpeg_find_dll) - cmake_path(GET FFMPEG_${component}_IMPLIB PARENT_PATH _implib_path) - cmake_path(SET _bin_path NORMALIZE "${FFMPEG_ROOT}/bin") + cmake_path(GET FFMPEG_${component}_IMPLIB PARENT_PATH _implib_path) + cmake_path(SET _bin_path NORMALIZE "${FFMPEG_ROOT}/bin") - string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" _dll_version "${FFMPEG_${component}_VERSION}") + string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" _dll_version "${FFMPEG_${component}_VERSION}") - find_program( - FFMPEG_${component}_LIBRARY - NAMES ${component_name}-${_dll_version}.dll - HINTS ${_implib_path} ${_bin_path} - DOC "FFMPEG component ${component_name} DLL location" - ) + find_program( + FFMPEG_${component}_LIBRARY + NAMES ${component_name}-${_dll_version}.dll + HINTS ${_implib_path} ${_bin_path} + DOC "FFMPEG component ${component_name} DLL location" + ) - if(NOT FFMPEG_${component}_LIBRARY) - set(FFMPEG_${component}_LIBRARY "${FFMPEG_${component}_IMPLIB}") - endif() + if(NOT FFMPEG_${component}_LIBRARY) + set(FFMPEG_${component}_LIBRARY "${FFMPEG_${component}_IMPLIB}") + endif() - unset(_implib_path) - unset(_bin_path) - unset(_dll_version) + unset(_implib_path) + unset(_bin_path) + unset(_dll_version) endmacro() # ffmpeg_check_version: Macro to help extract version number from FFMPEG headers macro(ffmpeg_check_version) - if(PC_FFMPEG_${component}_VERSION) - set(FFMPEG_${component_libname}_VERSION ${PC_FFMPEG_${component}_VERSION}) - elseif(EXISTS "${FFMPEG_${component}_INCLUDE_DIR}/${component_libname}/version.h") - # get major version from version_major if version_major.h exists - if(EXISTS "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version_major.h") - set(_major_version_file "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version_major.h") - else() - # otherwise get major version from version.h - set(_major_version_file "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version.h") - endif() + if(PC_FFMPEG_${component}_VERSION) + set(FFMPEG_${component_libname}_VERSION ${PC_FFMPEG_${component}_VERSION}) + elseif(EXISTS "${FFMPEG_${component}_INCLUDE_DIR}/${component_libname}/version.h") + # get major version from version_major if version_major.h exists + if(EXISTS "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version_major.h") + set(_major_version_file "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version_major.h") + else() + # otherwise get major version from version.h + set(_major_version_file "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version.h") + endif() - # get major version - file( - STRINGS - ${_major_version_file} - _version_string - REGEX "^.*VERSION_MAJOR[ \t]+[0-9]+[ \t]*$" - ) - string(REGEX REPLACE ".*VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" _version_major "${_version_string}") - - # get minor and micro version - file( - STRINGS - "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version.h" - _version_string - REGEX "^.*VERSION_(MINOR|MICRO)[ \t]+[0-9]+[ \t]*$" - ) - string(REGEX REPLACE ".*VERSION_MINOR[ \t]+([0-9]+).*" "\\1" _version_minor "${_version_string}") - string(REGEX REPLACE ".*VERSION_MICRO[ \t]+([0-9]+).*" "\\1" _version_micro "${_version_string}") - - if(NOT _version_major STREQUAL "" AND NOT _version_minor STREQUAL "" AND NOT _version_micro STREQUAL "") - set(FFMPEG_${component}_VERSION "${_version_major}.${_version_minor}.${_version_micro}") - set(FFMPEG_${component_libname}_VERSION "${_version_major}.${_version_minor}.${_version_micro}") - message(DEBUG "[FindFFMPEG]: found ${component}: ${_version_major}.${_version_minor}.${_version_micro}") - else() - message(AUTHOR_WARNING "Failed to find ${component_name} version.") - endif() + # get major version + file( + STRINGS + ${_major_version_file} + _version_string + REGEX "^.*VERSION_MAJOR[ \t]+[0-9]+[ \t]*$" + ) + string(REGEX REPLACE ".*VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" _version_major "${_version_string}") - unset(_version_major) - unset(_version_minor) - unset(_version_micro) - unset(_version_string) - unset(_major_version_file) + # get minor and micro version + file( + STRINGS + "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version.h" + _version_string + REGEX "^.*VERSION_(MINOR|MICRO)[ \t]+[0-9]+[ \t]*$" + ) + string(REGEX REPLACE ".*VERSION_MINOR[ \t]+([0-9]+).*" "\\1" _version_minor "${_version_string}") + string(REGEX REPLACE ".*VERSION_MICRO[ \t]+([0-9]+).*" "\\1" _version_micro "${_version_string}") + + if(NOT _version_major STREQUAL "" AND NOT _version_minor STREQUAL "" AND NOT _version_micro STREQUAL "") + set(FFMPEG_${component}_VERSION "${_version_major}.${_version_minor}.${_version_micro}") + set(FFMPEG_${component_libname}_VERSION "${_version_major}.${_version_minor}.${_version_micro}") + message(DEBUG "[FindFFMPEG]: found ${component}: ${_version_major}.${_version_minor}.${_version_micro}") else() - if(NOT FFMPEG_FIND_QUIETLY) - message(AUTHOR_WARNING "Failed to find ${component_name} version.") - endif() + message(AUTHOR_WARNING "Failed to find ${component_name} version.") + endif() - set(FFMPEG_${component_libname}_VERSION 0.0.0) + unset(_version_major) + unset(_version_minor) + unset(_version_micro) + unset(_version_string) + unset(_major_version_file) + else() + if(NOT FFMPEG_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find ${component_name} version.") endif() + + set(FFMPEG_${component_libname}_VERSION 0.0.0) + endif() endmacro() # ffmpeg_set_soname: Set SONAME property on imported library targets macro(ffmpeg_set_soname) - if(CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin") - execute_process( - COMMAND sh -c "otool -D '${FFMPEG_${component}_LIBRARY}' | grep -v '${FFMPEG_${component}_LIBRARY}'" - OUTPUT_VARIABLE _output - RESULT_VARIABLE _result - ) - - if(_result EQUAL 0 AND _output MATCHES "^@rpath/") - set_property(TARGET FFMPEG::${component} PROPERTY IMPORTED_SONAME "${_output}") - endif() - elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|FreeBSD") - execute_process( - COMMAND sh -c "objdump -p '${FFMPEG_${component}_LIBRARY}' | grep SONAME" - OUTPUT_VARIABLE _output - RESULT_VARIABLE _result - ) - - if(_result EQUAL 0) - string(REGEX REPLACE "[ \t]+SONAME[ \t]+([^ \t]+)" "\\1" _soname "${_output}") - set_property(TARGET FFMPEG::${component} PROPERTY IMPORTED_SONAME "${_soname}") - unset(_soname) - endif() + if(CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin") + execute_process( + COMMAND sh -c "otool -D '${FFMPEG_${component}_LIBRARY}' | grep -v '${FFMPEG_${component}_LIBRARY}'" + OUTPUT_VARIABLE _output + RESULT_VARIABLE _result + ) + + if(_result EQUAL 0 AND _output MATCHES "^@rpath/") + set_property(TARGET FFMPEG::${component} PROPERTY IMPORTED_SONAME "${_output}") endif() + elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|FreeBSD") + execute_process( + COMMAND sh -c "objdump -p '${FFMPEG_${component}_LIBRARY}' | grep SONAME" + OUTPUT_VARIABLE _output + RESULT_VARIABLE _result + ) - unset(_output) - unset(_result) + if(_result EQUAL 0) + string(REGEX REPLACE "[ \t]+SONAME[ \t]+([^ \t]+)" "\\1" _soname "${_output}") + set_property(TARGET FFMPEG::${component} PROPERTY IMPORTED_SONAME "${_soname}") + unset(_soname) + endif() + endif() + + unset(_output) + unset(_result) endmacro() macro(ffmpeg_create_target component) - if(FFMPEG_${component}_FOUND AND NOT TARGET FFMPEG::${component}) - if(IS_ABSOLUTE "${FFMPEG_${component}_LIBRARY}") - if(DEFINED FFMPEG_${component}_IMPLIB) - if(FFMPEG_${component}_IMPLIB STREQUAL FFMPEG_${component}_LIBRARY) - add_library(FFMPEG::${component} STATIC IMPORTED) - else() - add_library(FFMPEG::${component} SHARED IMPORTED) - set_property(TARGET FFMPEG::${component} PROPERTY IMPORTED_IMPLIB "${FFMPEG_${component}_IMPLIB}") - endif() - else() - add_library(FFMPEG::${component} UNKNOWN IMPORTED) - ffmpeg_set_soname() - endif() - - set_property(TARGET FFMPEG::${component} PROPERTY IMPORTED_LOCATION "${FFMPEG_${component}_LIBRARY}") + if(FFMPEG_${component}_FOUND AND NOT TARGET FFMPEG::${component}) + if(IS_ABSOLUTE "${FFMPEG_${component}_LIBRARY}") + if(DEFINED FFMPEG_${component}_IMPLIB) + if(FFMPEG_${component}_IMPLIB STREQUAL FFMPEG_${component}_LIBRARY) + add_library(FFMPEG::${component} STATIC IMPORTED) else() - add_library(FFMPEG::${component} INTERFACE IMPORTED) - set_property(TARGET FFMPEG::${component} PROPERTY IMPORTED_LIBNAME "${FFMPEG_${component}_LIBRARY}") - endif() - - set_target_properties( + add_library(FFMPEG::${component} SHARED IMPORTED) + set_target_properties( FFMPEG::${component} PROPERTIES - INTERFACE_COMPILE_OPTIONS "${PC_FFMPEG_${component}_CFLAGS_OTHER}" - INTERFACE_INCLUDE_DIRECTORIES "${FFMPEG_${component}_INCLUDE_DIR}" - INSTALL_RPATH "$ORIGIN" - VERSION ${FFMPEG_${component_libname}_VERSION} - ) + IMPORTED_IMPLIB "${FFMPEG_${component}_IMPLIB}" + ) + endif() + else() + add_library(FFMPEG::${component} UNKNOWN IMPORTED) + ffmpeg_set_soname() + endif() + + set_target_properties( + FFMPEG::${component} + PROPERTIES + IMPORTED_LOCATION "${FFMPEG_${component}_LIBRARY}" + ) + else() + add_library(FFMPEG::${component} INTERFACE IMPORTED) + set_target_properties( + FFMPEG::${component} + PROPERTIES + IMPORTED_LIBNAME "${FFMPEG_${component}_LIBRARY}" + ) + endif() - # get_target_property(_ffmpeg_interface_libraries FFMPEG::FFMPEG INTERFACE_LINK_LIBRARIES) + set_target_properties( + FFMPEG::${component} + PROPERTIES + INTERFACE_COMPILE_OPTIONS "${PC_FFMPEG_${component}_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${FFMPEG_${component}_INCLUDE_DIR}" + VERSION ${FFMPEG_${component_libname}_VERSION} + ) - # if(NOT FFMPEG::${component} IN_LIST _ffmpeg_interface_libraries) - # set_property(TARGET FFMPEG::FFMPEG APPEND PROPERTY INTERFACE_LINK_LIBRARIES FFMPEG::${component}) - # endif() - endif() + # get_target_property(_ffmpeg_interface_libraries FFMPEG::FFMPEG INTERFACE_LINK_LIBRARIES) + + # if(NOT FFMPEG::${component} IN_LIST _ffmpeg_interface_libraries) + # set_property(TARGET FFMPEG::FFMPEG APPEND PROPERTY INTERFACE_LINK_LIBRARIES FFMPEG::${component}) + # endif() + endif() endmacro() foreach(component IN LISTS FFMPEG_FIND_COMPONENTS) - if(NOT component IN_LIST _DEFAULT_COMPONENTS) - message(FATAL_ERROR "Unknown FFMPEG component specified: ${component}.") - endif() - - if(NOT FFMPEG_${component}_FOUND) - ffmpeg_find_component(${component}) - endif() - - if(FFMPEG_${component}_FOUND) - set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${FFMPEG_${component}_LIBRARY}) - set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} ${FFMPEG_${component}_DEFINITIONS}) - set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} ${FFMPEG_${component}_INCLUDE_DIR}) - endif() + if(NOT component IN_LIST _DEFAULT_COMPONENTS) + message(FATAL_ERROR "Unknown FFMPEG component specified: ${component}.") + endif() + + if(NOT FFMPEG_${component}_FOUND) + ffmpeg_find_component(${component}) + endif() + + if(FFMPEG_${component}_FOUND) + set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${FFMPEG_${component}_LIBRARY}) + set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} ${FFMPEG_${component}_DEFINITIONS}) + set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} ${FFMPEG_${component}_INCLUDE_DIR}) + endif() endforeach() if(NOT FFMPEG_avutil_FOUND) - ffmpeg_find_component(avutil) + ffmpeg_find_component(avutil) endif() if(EXISTS "${FFMPEG_avutil_INCLUDE_DIR}/libavutil/ffversion.h") - file( - STRINGS - "${FFMPEG_avutil_INCLUDE_DIR}/libavutil/ffversion.h" - _version_string - REGEX "FFMPEG_VERSION" - ) - string(REGEX REPLACE ".*\"n?\(.*\)\"" "\\1" FFMPEG_VERSION "${_version_string}") + file( + STRINGS + "${FFMPEG_avutil_INCLUDE_DIR}/libavutil/ffversion.h" + _version_string + REGEX "FFMPEG_VERSION" + ) + string(REGEX REPLACE ".*\"n?\(.*\)\"" "\\1" FFMPEG_VERSION "${_version_string}") endif() unset(_version_string) +message(STATUS "FFMPEG_VERSION: ${FFMPEG_VERSION}") + list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS) list(REMOVE_DUPLICATES FFMPEG_LIBRARIES) list(REMOVE_DUPLICATES FFMPEG_DEFINITIONS) if(CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin|Windows") - set(FFMPEG_ERROR_REASON "Ensure that obs-deps is provided as part of CMAKE_PREFIX_PATH.") + set(FFMPEG_ERROR_REASON "Ensure that obs-deps is provided as part of CMAKE_PREFIX_PATH.") elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|FreeBSD") - set(FFMPEG_ERROR_REASON "Ensure that required FFMPEG libraries are installed on the system.") + set(FFMPEG_ERROR_REASON "Ensure that required FFMPEG libraries are installed on the system.") endif() find_package_handle_standard_args( - FFMPEG - REQUIRED_VARS FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIRS - VERSION_VAR FFMPEG_VERSION - HANDLE_COMPONENTS - REASON_FAILURE_MESSAGE "${FFMPEG_ERROR_REASON}" + FFMPEG + REQUIRED_VARS FFMPEG_ROOT FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIRS + VERSION_VAR FFMPEG_VERSION + HANDLE_COMPONENTS + REASON_FAILURE_MESSAGE "${FFMPEG_ERROR_REASON}" ) if(FFMPEG_FOUND AND NOT TARGET FFMPEG::FFMPEG) - add_library(FFMPEG::FFMPEG INTERFACE IMPORTED) + add_library(FFMPEG::FFMPEG INTERFACE IMPORTED) - foreach(component IN LISTS FFMPEG_FIND_COMPONENTS) - ffmpeg_create_target(${component}) + foreach(component IN LISTS FFMPEG_FIND_COMPONENTS) + ffmpeg_create_target(${component}) - if(FFMPEG_${component}_FOUND) - set_property(TARGET FFMPEG::FFMPEG APPEND PROPERTY INTERFACE_LINK_LIBRARIES FFMPEG::${component}) - endif() - endforeach() + if(FFMPEG_${component}_FOUND) + set_property(TARGET FFMPEG::FFMPEG APPEND PROPERTY INTERFACE_LINK_LIBRARIES FFMPEG::${component}) + endif() + endforeach() endif() include(FeatureSummary) set_package_properties( - FFMPEG - PROPERTIES - URL "https://www.ffmpeg.org" - DESCRIPTION "A complete, cross-platform solution to record, convert and stream audio and video." + FFMPEG + PROPERTIES + URL "https://www.ffmpeg.org" + DESCRIPTION "A complete, cross-platform solution to record, convert and stream audio and video." ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a52aafc..0908ced 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -13,8 +13,9 @@ if(LINUX OR APPLE) endif() find_package(OpenCV REQUIRED) +find_package(FFMPEG REQUIRED) add_executable(opencv-mobile-test main.cpp) -target_include_directories(opencv-mobile-test PRIVATE ${OpenCV_INCLUDE_DIRS}) +target_include_directories(opencv-mobile-test PRIVATE ${OpenCV_INCLUDE_DIRS} ${FFMPEG_INCLUDE_DIRS}) -target_link_libraries(opencv-mobile-test opencv_highgui opencv_core opencv_imgproc) +target_link_libraries(opencv-mobile-test opencv_highgui opencv_core opencv_imgproc ${FFMPEG_LIBRARIES}) From d6393b4492a93e3f32ed34a137fa2036d7f8a5e8 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Thu, 26 Sep 2024 16:49:37 +0800 Subject: [PATCH 38/41] finish --- cmake/ffmpeg-config.cmake | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cmake/ffmpeg-config.cmake b/cmake/ffmpeg-config.cmake index 83b5d2a..fe41691 100644 --- a/cmake/ffmpeg-config.cmake +++ b/cmake/ffmpeg-config.cmake @@ -130,12 +130,12 @@ set( swresample ) -set(FFMPEG_FIND_COMPONENTS - avcodec - avformat - avutil - swscale -) +# set(FFMPEG_FIND_COMPONENTS +# avcodec +# avformat +# avutil +# swscale +# ) set(component_avcodec libavcodec avcodec avcodec.h) set(component_avdevice libavdevice avdevice avdevice.h) From 70c48b737abe1d167dfa88a381f80be48eb515e4 Mon Sep 17 00:00:00 2001 From: rainy liu Date: Fri, 27 Sep 2024 11:18:45 +0800 Subject: [PATCH 39/41] fix windows linux --- .github/workflows/linux.yml | 12 +++------ .github/workflows/windows.yml | 49 +++++++++++++++++------------------ README.md | 7 +++++ cmake/ffmpeg-config.cmake | 2 +- 4 files changed, 36 insertions(+), 34 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 9741154..b6d3a6a 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -39,11 +39,9 @@ jobs: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> "$GITHUB_ENV" - name: setup ffmpeg run: | - wget -q -O ffmpeg.tar.xz https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-n6.1-latest-linux64-lgpl-shared-6.1.tar.xz - mkdir -p $FFMPEG_ROOT - tar xf ffmpeg.tar.xz -C $FFMPEG_ROOT --strip-components=1 - + wget -q -O ffmpeg.tar.xz https://github.com/rainyl/FFmpeg-Builds/releases/download/latest/ffmpeg-n6.1-latest-linux64-lgpl-shared-6.1.tar.xz mkdir -p $FFMPEG_ROOT/cmake + tar xf ffmpeg.tar.xz -C $FFMPEG_ROOT --strip-components=1 cp -rf ${{ github.workspace }}/cmake/ffmpeg-config.cmake $FFMPEG_ROOT/cmake/ - name: build run: | @@ -115,11 +113,9 @@ jobs: echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> "$GITHUB_ENV" - name: setup ffmpeg run: | - wget -q -O ffmpeg.tar.xz https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-n6.1-latest-linuxarm64-lgpl-shared-6.1.tar.xz - mkdir -p $FFMPEG_ROOT - tar xf ffmpeg.tar.xz -C $FFMPEG_ROOT --strip-components=1 - + wget -q -O ffmpeg.tar.xz https://github.com/rainyl/FFmpeg-Builds/releases/download/latest/ffmpeg-n6.1-latest-linuxarm64-lgpl-shared-6.1.tar.xz mkdir -p $FFMPEG_ROOT/cmake + tar xf ffmpeg.tar.xz -C $FFMPEG_ROOT --strip-components=1 cp -rf ${{ github.workspace }}/cmake/ffmpeg-config.cmake $FFMPEG_ROOT/cmake/ - name: build run: | diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 75a942c..ed0310e 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -36,33 +36,28 @@ jobs: git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $env:GITHUB_ENV echo "PACKAGE_NAME=libopencv-windows-${{ matrix.os.arch }}" >> $env:GITHUB_ENV + - name: download ffmpeg + uses: robinraju/release-downloader@v1.10 + with: + repository: "rainyl/FFmpeg-Builds" + latest: true + fileName: "ffmpeg-n6.1-latest-win64-lgpl-shared-6.1.zip" + out-file-path: 'ffmpeg_tmp' + extract: true - name: setup ffmpeg run: | + ls ffmpeg_tmp echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $env:GITHUB_ENV - choco install wget --no-progress - wget -q https://sourceforge.net/projects/avbuild/files/windows-desktop/ffmpeg-6.1-windows-desktop-vs2022-lite.7z - 7z x ffmpeg-6.1-windows-desktop-vs2022-lite.7z - Move-Item -Force ffmpeg-6.1-windows-desktop-vs2022-lite tmp - mkdir -Force $env:FFMPEG_ROOT - - Move-Item -Force tmp/include $env:FFMPEG_ROOT/ - Move-Item -Force tmp/bin/${{ matrix.os.arch }} $env:FFMPEG_ROOT/bin - Move-Item -Force tmp/lib/${{ matrix.os.arch }} $env:FFMPEG_ROOT/lib - Move-Item -Force tmp/COPYING.LGPLv2.1 $env:FFMPEG_ROOT/ - Move-Item -Force tmp/RELEASE_NOTES $env:FFMPEG_ROOT/ - - mkdir $env:FFMPEG_ROOT/cmake -Force + mkdir -Force $env:FFMPEG_ROOT/cmake + Move-Item -Force ffmpeg_tmp\*\* $env:FFMPEG_ROOT cp -Force ${{ github.workspace }}/cmake/ffmpeg-config.cmake $env:FFMPEG_ROOT/cmake/ - - Remove-Item tmp -Recurse -Force -Confirm:$false - name: build run: | cd ${{ env.SOURCE_DIR }} mkdir build cd ${{ env.SOURCE_DIR }}/build cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. ` - -DFFMPEG_DIR="$env:FFMPEG_ROOT/cmake" ` - -DOPENCV_FFMPEG_SKIP_BUILD_CHECK=ON + -DFFMPEG_DIR="$env:FFMPEG_ROOT/cmake" cmake --build . --config Release --target install -j 4 - name: package run: | @@ -121,15 +116,20 @@ jobs: git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> $env:GITHUB_ENV echo "PACKAGE_NAME=libopencv-windows-${{ matrix.os.arch }}" >> $env:GITHUB_ENV + - name: download ffmpeg + uses: robinraju/release-downloader@v1.10 + with: + repository: "rainyl/FFmpeg-Builds" + latest: true + fileName: "ffmpeg-n6.1-latest-winarm64-lgpl-shared-6.1.zip" + out-file-path: 'ffmpeg_tmp' + extract: true - name: setup ffmpeg run: | + ls ffmpeg_tmp echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> $env:GITHUB_ENV - choco install wget --no-progress - wget -q https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-n6.1-latest-win64-lgpl-shared-6.1.zip - unzip -q ffmpeg-n6.1-latest-win64-lgpl-shared-6.1.zip - Move-Item -Force ffmpeg-n6.1-latest-win64-lgpl-shared-6.1 $env:FFMPEG_ROOT - - mkdir $env:FFMPEG_ROOT/cmake -Force + mkdir -Force $env:FFMPEG_ROOT/cmake + Move-Item -Force ffmpeg_tmp\*\* $env:FFMPEG_ROOT cp -Force ${{ github.workspace }}/cmake/ffmpeg-config.cmake $env:FFMPEG_ROOT/cmake/ - name: build run: | @@ -138,8 +138,7 @@ jobs: cd ${{ env.SOURCE_DIR }}/build cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. ` -DWITH_IPP=OFF ` - -DFFMPEG_DIR="$env:FFMPEG_ROOT/cmake" ` - -DOPENCV_FFMPEG_SKIP_BUILD_CHECK=ON + -DFFMPEG_DIR="$env:FFMPEG_ROOT/cmake" cd ${{ env.SOURCE_DIR }}/build cmake --build . --config Release --target install -j 4 - name: package diff --git a/README.md b/README.md index 6b68f9a..8d3c5a6 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,9 @@ # opencv.full Prebuilt opencv static library for opencv_dart to speedup compile + +## Acknowledgement + +- prbuilt ffmpeg for android macos ios are from avbuild (https://github.com/wang-bin/avbuild) +- prebuilt ffmpeg for linux and windows are from https://github.com/BtbN/FFmpeg-Builds +- https://github.com/obsproject/obs-studio/blob/master/cmake/finders/FindFFmpeg.cmake +- https://github.com/Kitware/VTK/blob/master/CMake/FindFFMPEG.cmake diff --git a/cmake/ffmpeg-config.cmake b/cmake/ffmpeg-config.cmake index fe41691..70e4868 100644 --- a/cmake/ffmpeg-config.cmake +++ b/cmake/ffmpeg-config.cmake @@ -319,7 +319,7 @@ macro(ffmpeg_check_version) message(AUTHOR_WARNING "Failed to find ${component_name} version.") endif() - set(FFMPEG_${component_libname}_VERSION 0.0.0) + # set(FFMPEG_${component_libname}_VERSION 0.0.0) endif() endmacro() From f6aa18b2080068adaedaeb7c3fbcdc5b04edc0cb Mon Sep 17 00:00:00 2001 From: rainy liu Date: Fri, 27 Sep 2024 11:32:36 +0800 Subject: [PATCH 40/41] add ffmpeg in windows tar.gz --- .github/workflows/windows.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index ed0310e..c7d4934 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -63,7 +63,8 @@ jobs: run: | mkdir ${{ env.PACKAGE_NAME }} Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build\install\*" -Destination "${{ env.PACKAGE_NAME }}" - tar -zcvf ${{ env.PACKAGE_NAME }}.tar.gz ${{ env.PACKAGE_NAME }} + cp -Force $FFMPEG_ROOT ${{ env.PACKAGE_NAME }}/ffmpeg + tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . - name: test run: | cd test @@ -145,7 +146,8 @@ jobs: run: | mkdir ${{ env.PACKAGE_NAME }} Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build\install\*" -Destination "${{ env.PACKAGE_NAME }}" - tar -zcvf ${{ env.PACKAGE_NAME }}.tar.gz ${{ env.PACKAGE_NAME }} + cp -Force $env:FFMPEG_ROOT ${{ env.PACKAGE_NAME }}/ffmpeg + tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . - name: test run: | cd test From 4442e08b41fc65b22da06a1dc0334e7e4514c95d Mon Sep 17 00:00:00 2001 From: rainy liu Date: Fri, 27 Sep 2024 11:53:14 +0800 Subject: [PATCH 41/41] fix windows --- .github/workflows/windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index c7d4934..4002830 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -63,7 +63,7 @@ jobs: run: | mkdir ${{ env.PACKAGE_NAME }} Copy-Item -Verbose -Recurse -Path "${{ env.SOURCE_DIR }}\build\install\*" -Destination "${{ env.PACKAGE_NAME }}" - cp -Force $FFMPEG_ROOT ${{ env.PACKAGE_NAME }}/ffmpeg + cp -Force $env:FFMPEG_ROOT ${{ env.PACKAGE_NAME }}/ffmpeg tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz . - name: test run: |