opencv4{,-devel}: fix linking to ffmpegX for Python subports

This commit combines suggested fixes/changes from different PRs and also
applies them to the -devel port.

Closes: #33150
Closes: #33119
Closes: #33073
Closes: https://trac.macports.org/ticket/74070
This commit is contained in:
Renee Otten
2026-06-19 11:32:30 -04:00
parent 315af4ea15
commit 0e15bf6ca0
2 changed files with 44 additions and 84 deletions
+22 -42
View File
@@ -3,6 +3,7 @@
PortSystem 1.0
PortGroup cmake 1.1
PortGroup github 1.0
PortGroup ffmpeg 1.0
#==============================================================================
# IMPORTANT NOTE
@@ -54,7 +55,7 @@ if {${os.major} > 12} {
if {${opencv_latest}} {
github.setup opencv opencv 4.9.0
github.tarball_from releases
revision 9
revision 10
epoch 1
checksums-append \
@@ -65,7 +66,7 @@ if {${opencv_latest}} {
} else {
github.setup opencv opencv 4.5.0
github.tarball_from releases
revision 35
revision 36
checksums-append \
${distname}${extract.suffix} \
@@ -85,7 +86,7 @@ dist_subdir ${my_name}
# Python build support
#------------------------------------------------------------------------------
set default_python_branch \
3.13
3.14
set default_python_version \
[join [lrange [split ${default_python_branch} .] 0 1] ""]
set default_python_path \
@@ -116,7 +117,19 @@ platform darwin {
}
}
#worksrcdir ${parent_subport_name}-${version}
# FFmpeg variant selection — declared in common scope so Python subports inherit them
variant ffmpeg6 conflicts ffmpeg7 ffmpeg8 description {Link against ffmpeg 6} {
ffmpeg.version 6
}
variant ffmpeg7 conflicts ffmpeg6 ffmpeg8 description {Link against ffmpeg 7} {
ffmpeg.version 7
}
variant ffmpeg8 conflicts ffmpeg6 ffmpeg7 description {Link against ffmpeg 8} {
ffmpeg.version 8}
if {![variant_isset ffmpeg6] && ![variant_isset ffmpeg7]} {
default_variants +ffmpeg8
}
# Claims to only need c++11 but actually uses c++14 features
# core/cvstd_wrapper.hpp:45:40: warning: variable templates are a C++14 extension [-Wc++14-extensions]
@@ -125,10 +138,6 @@ compiler.cxx_standard \
${cxx_standard}
cmake.set_cxx_standard \
yes
configure.env-append \
PKG_CONFIG_PATH="${prefix}/libexec/ffmpeg4/lib/pkgconfig"
compiler.blacklist-append \
*gcc* \
@@ -141,9 +150,7 @@ depends_build-append \
path:bin/pkg-config:pkgconfig \
port:python${default_python_version}
depends_lib-append \
port:ade \
port:ffmpeg4 \
depends_lib-append port:ade \
port:imath \
path:include/turbojpeg.h:libjpeg-turbo \
port:libpng \
@@ -178,8 +185,7 @@ cmake.install_prefix \
${opencv_install_prefix}
cmake_share_module_dir \
${opencv_install_cmake}
cmake.install_rpath \
${opencv_install_lib}
cmake.install_rpath ${opencv_install_lib}
configure.args-append \
-DENABLE_CONFIG_VERIFICATION:BOOL=OFF \
@@ -354,7 +360,7 @@ platform darwin {
}
# Python Bindings
set python_branches {3.10 3.11 3.12 3.13}
set python_branches {3.10 3.11 3.12 3.13 3.14}
foreach python_branch ${python_branches} {
set python_version [join [lrange [split ${python_branch} .] 0 1] ""]
set python_path ${prefix}/bin/python${python_branch}
@@ -363,9 +369,9 @@ foreach python_branch ${python_branches} {
subport py${python_version}-${name} {
# NOTE: Only rev-bump subports, for major changes/additions
if {${opencv_latest}} {
revision 4
revision 5
} else {
revision 15
revision 16
}
conflicts-append \
@@ -375,8 +381,6 @@ foreach python_branch ${python_branches} {
depends_build-delete \
port:python${default_python_version}
depends_lib-delete \
port:ffmpeg4
depends_lib-append \
port:${name} \
port:py${python_version}-numpy \
@@ -658,30 +662,6 @@ if {${name} eq ${subport}} {
configure.args-append -DOPENCV_WECHAT_QRCODE_URL=file://${distpath}/
}
variant ffmpeg6 conflicts ffmpeg7 ffmpeg8 description {Link against ffmpeg 6} {
depends_lib-delete port:ffmpeg4
depends_lib-append port:ffmpeg6
configure.env-replace \
PKG_CONFIG_PATH="${prefix}/libexec/ffmpeg4/lib/pkgconfig" \
PKG_CONFIG_PATH="${prefix}/libexec/ffmpeg6/lib/pkgconfig"
}
variant ffmpeg7 conflicts ffmpeg6 ffmpeg8 description {Link against ffmpeg 7} {
depends_lib-delete port:ffmpeg4
depends_lib-append port:ffmpeg7
configure.env-replace \
PKG_CONFIG_PATH="${prefix}/libexec/ffmpeg4/lib/pkgconfig" \
PKG_CONFIG_PATH="${prefix}/libexec/ffmpeg7/lib/pkgconfig"
}
variant ffmpeg8 conflicts ffmpeg6 ffmpeg7 description {Link against ffmpeg 8} {
depends_lib-delete port:ffmpeg4
depends_lib-append port:ffmpeg8
configure.env-replace \
PKG_CONFIG_PATH="${prefix}/libexec/ffmpeg4/lib/pkgconfig" \
PKG_CONFIG_PATH="${prefix}/libexec/ffmpeg8/lib/pkgconfig"
}
variant qt4 conflicts qt5 description {Build with Qt4 Backend support} {
PortGroup qt4 1.0
+22 -42
View File
@@ -3,6 +3,7 @@
PortSystem 1.0
PortGroup cmake 1.1
PortGroup github 1.0
PortGroup ffmpeg 1.0
#==============================================================================
# IMPORTANT NOTE
@@ -54,7 +55,7 @@ if {${os.major} > 12} {
if {${opencv_latest}} {
github.setup opencv opencv 4.9.0
github.tarball_from releases
revision 9
revision 10
epoch 1
checksums-append \
@@ -85,7 +86,7 @@ dist_subdir ${my_name}
# Python build support
#------------------------------------------------------------------------------
set default_python_branch \
3.13
3.14
set default_python_version \
[join [lrange [split ${default_python_branch} .] 0 1] ""]
set default_python_path \
@@ -124,7 +125,19 @@ platform darwin {
}
}
#worksrcdir ${parent_subport_name}-${version}
# FFmpeg variant selection — declared in common scope so Python subports inherit them
variant ffmpeg6 conflicts ffmpeg7 ffmpeg8 description {Link against ffmpeg 6} {
ffmpeg.version 6
}
variant ffmpeg7 conflicts ffmpeg6 ffmpeg8 description {Link against ffmpeg 7} {
ffmpeg.version 7
}
variant ffmpeg8 conflicts ffmpeg6 ffmpeg7 description {Link against ffmpeg 8} {
ffmpeg.version 8}
if {![variant_isset ffmpeg6] && ![variant_isset ffmpeg7]} {
default_variants +ffmpeg8
}
# Claims to only need c++11 but actually uses c++14 features
# core/cvstd_wrapper.hpp:45:40: warning: variable templates are a C++14 extension [-Wc++14-extensions]
@@ -133,10 +146,6 @@ compiler.cxx_standard \
${cxx_standard}
cmake.set_cxx_standard \
yes
configure.env-append \
PKG_CONFIG_PATH="${prefix}/libexec/ffmpeg4/lib/pkgconfig"
compiler.blacklist-append \
{clang < 900} \
@@ -148,9 +157,7 @@ depends_build-append \
path:bin/pkg-config:pkgconfig \
port:python${default_python_version}
depends_lib-append \
port:ade \
port:ffmpeg4 \
depends_lib-append port:ade \
port:imath \
path:include/turbojpeg.h:libjpeg-turbo \
port:libpng \
@@ -185,8 +192,7 @@ cmake.install_prefix \
${opencv_install_prefix}
cmake_share_module_dir \
${opencv_install_cmake}
cmake.install_rpath \
${opencv_install_lib}
cmake.install_rpath ${opencv_install_lib}
configure.args-append \
-DENABLE_CONFIG_VERIFICATION:BOOL=OFF \
@@ -329,7 +335,7 @@ if {${universal_possible} && [variant_isset universal]} {
-DENABLE_PRECOMPILED_HEADERS:BOOL=OFF
}
if { ${configure.ccache} } {
if {${configure.ccache}} {
configure.args-replace \
-DENABLE_CCACHE:BOOL=OFF \
-DENABLE_CCACHE:BOOL=ON
@@ -416,9 +422,9 @@ foreach python_branch ${python_branches} {
subport py${python_version}-${name} {
# NOTE: Only rev-bump subports, for major changes/additions
if {${opencv_latest}} {
revision 4
revision 5
} else {
revision 21
revision 22
}
conflicts-append \
@@ -428,8 +434,6 @@ foreach python_branch ${python_branches} {
depends_build-delete \
port:python${default_python_version}
depends_lib-delete \
port:ffmpeg4
depends_lib-append \
port:${name} \
port:py${python_version}-numpy \
@@ -711,30 +715,6 @@ if {${name} eq ${subport}} {
configure.args-append -DOPENCV_WECHAT_QRCODE_URL=file://${distpath}/
}
variant ffmpeg6 conflicts ffmpeg7 ffmpeg8 description {Link against ffmpeg 5} {
depends_lib-delete port:ffmpeg4
depends_lib-append port:ffmpeg6
configure.env-replace \
PKG_CONFIG_PATH="${prefix}/libexec/ffmpeg4/lib/pkgconfig" \
PKG_CONFIG_PATH="${prefix}/libexec/ffmpeg6/lib/pkgconfig"
}
variant ffmpeg7 conflicts ffmpeg6 ffmpeg8 description {Link against ffmpeg 7} {
depends_lib-delete port:ffmpeg4
depends_lib-append port:ffmpeg7
configure.env-replace \
PKG_CONFIG_PATH="${prefix}/libexec/ffmpeg4/lib/pkgconfig" \
PKG_CONFIG_PATH="${prefix}/libexec/ffmpeg7/lib/pkgconfig"
}
variant ffmpeg8 conflicts ffmpeg6 ffmpeg7 description {Link against ffmpeg 8} {
depends_lib-delete port:ffmpeg4
depends_lib-append port:ffmpeg8
configure.env-replace \
PKG_CONFIG_PATH="${prefix}/libexec/ffmpeg4/lib/pkgconfig" \
PKG_CONFIG_PATH="${prefix}/libexec/ffmpeg8/lib/pkgconfig"
}
variant qt4 conflicts qt5 description {Build with Qt4 Backend support} {
PortGroup qt4 1.0
@@ -819,7 +799,7 @@ if {${name} eq ${subport}} {
}
}
# NOTE: Variant 'debug' is the only one that should be shared with Python subports
# NOTE: Variants 'debug' and 'ffmpeg{6,7,8}' are shared with Python subports
variant debug description {Build with debugging info} {
configure.args-replace \
-DBUILD_WITH_DEBUG_INFO:BOOL=OFF \