switch to gcc11 #86
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build-OpenCV | |
| on: | |
| push: | |
| branches: [ main, feature/docker ] | |
| paths: [ .github/workflows/opencv.yml ] | |
| workflow_dispatch: | |
| env: | |
| OPENCV_VERSION: 4.11.0 | |
| OPENCV_CMAKE_ARGS: >- | |
| -D CMAKE_BUILD_TYPE=RELEASE | |
| -D OPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" | |
| -D CMAKE_INSTALL_PREFIX="${{ github.workspace }}/opencv/build/install" | |
| -D BUILD_LIST=core,imgproc,imgcodecs | |
| -D BUILD_PNG=ON | |
| -D BUILD_TIFF=ON | |
| -D ENABLE_CXX11=ON | |
| -D BUILD_SHARED_LIBS=OFF | |
| -D BUILD_EXAMPLES=OFF | |
| -D BUILD_DOCS=OFF | |
| -D BUILD_PERF_TESTS=OFF | |
| -D BUILD_TESTS=OFF | |
| -D BUILD_JAVA=OFF | |
| -D WITH_GSTREAMER=OFF | |
| -D WITH_ADE=OFF | |
| -D WITH_FFMPEG=OFF | |
| -D WITH_V4L=OFF | |
| -D WITH_1394=OFF | |
| -D WITH_GTK=OFF | |
| -D WITH_OPENEXR=OFF | |
| -D WITH_PROTOBUF=OFF | |
| -D WITH_QUIRC=OFF | |
| -D OPENCV_ENABLE_NONFREE=OFF | |
| jobs: | |
| build: | |
| defaults: | |
| run: | |
| shell: bash | |
| runs-on: ${{ matrix.runs-on }} | |
| strategy: | |
| matrix: | |
| include: | |
| - { os: linux, arch: x64, runs-on: ubuntu-22.04 } | |
| - { os: centos.7, arch: x64, runs-on: ubuntu-22.04, image: centos:7 } | |
| # - { os: ubuntu.24.04, arch: x64, runs-on: ubuntu-24.04 } | |
| # - { os: linux, arch: arm64, runs-on: ubuntu-22.04-arm } | |
| # - { os: ubuntu.24.04, arch: arm64, runs-on: ubuntu-24.04-arm } | |
| # - { os: win, arch: x64, runs-on: windows-2022 } | |
| # - { os: win, arch: x86, runs-on: windows-2022 } | |
| # - { os: win11, arch: x64, runs-on: windows-2025 } | |
| # - { os: win, arch: arm64, runs-on: windows-11-arm } | |
| # - { os: osx, arch: x64, runs-on: macos-13 } | |
| # - { os: osx, arch: arm64, runs-on: macos-14 } | |
| # - { os: osx.15, arch: arm64, runs-on: macos-15 } | |
| steps: | |
| - name: Checkout OpenCV repo | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: opencv/opencv | |
| ref: ${{ env.OPENCV_VERSION }} | |
| path: opencv | |
| fetch-depth: 1 | |
| - name: Checkout OpenCV Contrib repo | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: opencv/opencv_contrib | |
| ref: ${{ env.OPENCV_VERSION }} | |
| path: opencv_contrib | |
| fetch-depth: 1 | |
| - name: Pull Docker Image | |
| if: matrix.image != '' | |
| run: | | |
| docker pull ${{ matrix.image }} | |
| - name: Start Docker Container | |
| if: matrix.image != '' | |
| run: | | |
| docker run -d --name builder -v "$PWD":/work -w /work ${{ matrix.image }} tail -f /dev/null | |
| - name: Initialize Docker Container | |
| if: matrix.image != '' | |
| run: | | |
| if [[ "${{ matrix.os }}" == "centos.7" ]]; then | |
| script=$( | |
| cat <<'EOS' | |
| set -eux | |
| sed -i 's|^mirrorlist=|#mirrorlist=|g' /etc/yum.repos.d/CentOS-*.repo | |
| sed -i 's|^#baseurl=|baseurl=|g' /etc/yum.repos.d/CentOS-*.repo | |
| sed -i 's|mirror.centos.org|vault.centos.org|g' /etc/yum.repos.d/CentOS-*.repo | |
| yum clean all | |
| yum makecache | |
| EOS | |
| ) | |
| fi | |
| echo "Executing script in Docker container: $script" | |
| docker exec builder bash -c "$script" | |
| - name: Install Dependencies in Docker Container | |
| if: matrix.image != '' | |
| run: | | |
| if [[ "${{ matrix.os }}" == "centos.7" ]]; then | |
| script=$( | |
| cat <<'EOS' | |
| yum install -y epel-release | |
| yum install -y gcc cmake3 devtoolset-11-gcc devtoolset-11-gcc-c++ | |
| source /opt/rh/devtoolset-11/enable | |
| echo "source /opt/rh/devtoolset-11/enable" > /etc/profile.d/enable-gcc11.sh | |
| ln -s /usr/bin/cmake3 /usr/bin/cmake | |
| EOS | |
| ) | |
| fi | |
| echo "Executing script in Docker container: $script" | |
| docker exec builder bash -c "$script" | |
| - name: Configure OpenCV | |
| run: | | |
| script=$( | |
| cat <<'EOS' | |
| cd opencv && mkdir build && cd build | |
| EXTRA_FLAGS="" | |
| if [[ "${{ matrix.os }}" == "win" && "${{ matrix.arch }}" == "arm64" ]]; then | |
| EXTRA_FLAGS+=" -DWITH_IPP=OFF -DCPU_BASELINE=NEON -A ARM64" | |
| elif [[ "${{ matrix.os }}" == "win" && "${{ matrix.arch }}" == "x86" ]]; then | |
| EXTRA_FLAGS+=" -A Win32" | |
| fi | |
| cmake ${{ env.OPENCV_CMAKE_ARGS }} $EXTRA_FLAGS .. | |
| EOS | |
| ) | |
| if [[ "${{ matrix.image }}" == "" ]]; then | |
| bash -c "$script" | |
| else | |
| docker exec builder bash -c "$script" | |
| fi | |
| - name: Build OpenCV | |
| run: | | |
| script=$( | |
| cat <<'EOS' | |
| cd opencv/build | |
| if [[ "${{ matrix.os }}" =~ ^win ]]; then | |
| cmake --build . --config Release | |
| else | |
| make -j$(nproc) | |
| fi | |
| EOS | |
| ) | |
| if [[ "${{ matrix.image }}" == "" ]]; then | |
| bash -c "$script" | |
| else | |
| docker exec builder bash -c "$script" | |
| fi | |
| - name: Install OpenCV | |
| run: | | |
| script=$( | |
| cat <<'EOS' | |
| cd opencv/build | |
| if [[ "${{ matrix.os }}" =~ ^win ]]; then | |
| cmake --install . --config Release | |
| else | |
| make install | |
| fi | |
| EOS | |
| ) | |
| if [[ "${{ matrix.image }}" == "" ]]; then | |
| bash -c "$script" | |
| else | |
| docker exec builder bash -c "$script" | |
| fi | |
| - name: Show Build Artifacts | |
| run: | | |
| cd opencv/build && ls -lR | |
| - name: Make artifacts | |
| run: | | |
| mkdir artifacts | |
| cp -r opencv/build/install/* artifacts | |
| - name: Upload Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: opencv-${{ matrix.os }}-${{ matrix.arch }} | |
| path: artifacts |