Skip to content

enable gcc11 before compile #93

enable gcc11 before compile

enable gcc11 before compile #93

Workflow file for this run

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: oraclelinux: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":${{ github.workspace }} -w ${{ github.workspace }} ${{ 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
yum install -y oraclelinux-developer-release-el7
yum install -y oracle-epel-release-el7
yum install -y oracle-softwarecollection-release-el7
yum-config-manager --enable ol7_developer
yum-config-manager --enable ol7_developer_epel
yum-config-manager --enable ol7_software_collections
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 groupinstall -y "Development Tools"
yum install -y devtoolset-11-gcc devtoolset-11-gcc-c++ cmake3
yum clean all
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"
elif [[ ${{ matrix.os }} == "centos.7" ]]; then
source /opt/rh/devtoolset-11/enable
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