PR #21773 opened by Marvin Scholz (ePirat) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21773 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21773.patch
Introduce a function (require_pkg_config_cxx) to properly check for C++ pkg-config dependencies with a class name and remove the confusingly named require_cpp and check_lib_cpp which were added for it before, as those have nothing to do with the C pre-processor so should be named _cxx but we already have functions for that purpose, so there is little value in keeping them. >From f1cecb551298a373e58ee001fe2fa86c02070c16 Mon Sep 17 00:00:00 2001 From: Marvin Scholz <[email protected]> Date: Wed, 18 Sep 2024 23:18:46 +0200 Subject: [PATCH 1/4] configure: add {test,check,require}_pkg_config_cxx This is necessary to check for C++ only pkg-config dependencies --- configure | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/configure b/configure index 8a397598cd..9e2dfe4050 100755 --- a/configure +++ b/configure @@ -1642,6 +1642,26 @@ test_pkg_config_cpp(){ set_sanitized "${name}_incflags" $pkg_incflags } +test_pkg_config_cxx(){ + log test_pkg_config_cxx "$@" + name="$1" + pkg_version="$2" + pkg="${2%% *}" + headers="$3" + classes="$4" + shift 4 + disable $name + test_cmd $pkg_config --exists --print-errors $pkg_version || return + pkg_cflags=$($pkg_config --cflags $pkg_config_flags $pkg) + pkg_libs=$($pkg_config --libs $pkg_config_flags $pkg) + pkg_incdir=$($pkg_config --variable=includedir $pkg_config_flags $pkg) + check_class_headers_cxx "$headers" "$classes" $pkg_cflags $pkg_libs "-lstdc++" "$@" && + enable $name && + set_sanitized "${name}_cflags" $pkg_cflags && + set_sanitized "${name}_incdir" $pkg_incdir && + set_sanitized "${name}_extralibs" $pkg_libs "-lstdc++" +} + check_pkg_config(){ log check_pkg_config "$@" name="$1" @@ -1656,6 +1676,13 @@ check_pkg_config_cpp(){ eval add_cflags \$${name}_cflags } +check_pkg_config_cxx(){ + log check_pkg_config_cxx "$@" + name="$1" + test_pkg_config_cxx "$@" && + eval add_cxxflags \$${name}_cflags +} + check_pkg_config_header_only(){ log check_pkg_config_cpp "$@" name="$1" @@ -1809,6 +1836,12 @@ require_pkg_config_cpp(){ check_pkg_config_cpp "$@" || die "ERROR: $pkg_version not found using pkg-config$pkg_config_fail_message" } +require_pkg_config_cxx(){ + log require_pkg_config_cxx "$@" + pkg_version="$2" + check_pkg_config_cxx "$@" || die "ERROR: $pkg_version not found using pkg-config$pkg_config_fail_message" +} + test_host_cc(){ log test_host_cc "$@" cat > $TMPC -- 2.52.0 >From 8017a0e92fbbfa8bae68a9b14f2a9707ec261fee Mon Sep 17 00:00:00 2001 From: Marvin Scholz <[email protected]> Date: Tue, 17 Feb 2026 14:17:16 +0100 Subject: [PATCH 2/4] configure: do not require default-constructible class When checking for C++ classes in check_class_headers_cxx, the test code required the class to be default-constructible, which is not always the case. For the sake of the test, it is enough to check that referencing the class succeeds. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 9e2dfe4050..063930bea8 100755 --- a/configure +++ b/configure @@ -1499,7 +1499,7 @@ check_class_headers_cxx(){ echo "int main(void) { " i=1 for class in $classes; do - echo "$class obj$i;" + echo "$class *obj$i;" i=$(expr $i + 1) done echo "return 0; }" -- 2.52.0 >From 5fde80eda180f37760164cf6af45f701de14b8c4 Mon Sep 17 00:00:00 2001 From: Marvin Scholz <[email protected]> Date: Tue, 17 Feb 2026 14:25:16 +0100 Subject: [PATCH 3/4] configure: cleanup libopencolorio check Do a proper pkg-config check instead of just blindly compiling a test program even if pkg-config doesn't find anything. --- configure | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/configure b/configure index 063930bea8..35fb6ae9ee 100755 --- a/configure +++ b/configure @@ -7338,10 +7338,7 @@ enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb enabled libopencv && { check_pkg_config libopencv opencv4 opencv2/core/core_c.h cvCreateImageHeader || require libopencv opencv2/core/core_c.h cvCreateImageHeader -lopencv_core -lopencv_imgproc; } -enabled libopencolorio && add_cxxflags $(pkg-config --cflags OpenColorIO) && - OCIO_LIBS=$($pkg_config --libs OpenColorIO) && - require_cpp OpenColorIO OpenColorIO/OpenColorIO.h "namespace OCIO = OCIO_NAMESPACE; OCIO::ConfigRcPtr cfg = OCIO::Config::Create();" $OCIO_LIBS -lstdc++ && - append libopencolorio_extralibs "$OCIO_LIBS -lstdc++" +enabled libopencolorio && require_pkg_config_cxx libopencolorio "OpenColorIO" OpenColorIO/OpenColorIO.h OCIO_NAMESPACE::Config enabled libopenh264 && require_pkg_config libopenh264 "openh264 >= 1.3.0" wels/codec_api.h WelsGetCodecVersion enabled libopenjpeg && { check_pkg_config libopenjpeg "libopenjp2 >= 2.1.0" openjpeg.h opj_version || { require_pkg_config libopenjpeg "libopenjp2 >= 2.1.0" openjpeg.h opj_version -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } } -- 2.52.0 >From e0fdd396ecf35092d51be1dd65622b6144848941 Mon Sep 17 00:00:00 2001 From: Marvin Scholz <[email protected]> Date: Tue, 17 Feb 2026 14:26:25 +0100 Subject: [PATCH 4/4] configure: remove require_cpp, check_lib_cpp Remove the improperly named check functions that were added for the opencolorio detection in 677cf95ea4be805fa326adb082eff666a2e790ea. Those are not needed anymore and there are already require_cxx and check_lib_cxx for this purpose. --- configure | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/configure b/configure index 35fb6ae9ee..d226e1f5f3 100755 --- a/configure +++ b/configure @@ -1580,17 +1580,6 @@ check_lib(){ enable $name && eval ${name}_extralibs="\$@" } -check_lib_cpp(){ - log check_lib_cpp "$@" - name="$1" - headers="$2" - code="$3" - shift 3 - disable $name - test_code ld "$headers" "$code" cxx "$@" && - enable $name && eval ${name}_extralibs="\$@" -} - check_lib_cxx(){ log check_lib_cxx "$@" name="$1" @@ -1804,14 +1793,6 @@ require_cxx(){ check_lib_cxx "$name" "$@" || die "ERROR: $name_version not found" } -require_cpp(){ - log require_cpp "$@" - name_version="$1" - name="${1%% *}" - shift - check_lib_cpp "$name" "$@" || die "ERROR: $name_version not found" -} - require_headers(){ log require_headers "$@" headers="$1" -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
