Skip to content

Add custom FindGStreamer#1

Open
mikusaq wants to merge 8 commits intomainfrom
BAF-1258/custom-find-gstreamer
Open

Add custom FindGStreamer#1
mikusaq wants to merge 8 commits intomainfrom
BAF-1258/custom-find-gstreamer

Conversation

@mikusaq
Copy link
Copy Markdown
Collaborator

@mikusaq mikusaq commented Apr 10, 2026

Adds custom FindGStreamer for usage with Bacpack system. Also adds diff output compared to official FindGStreamer, BringAuto's specific tools and usage in README.

Summary by CodeRabbit

  • New Features

    • Added a CMake find module for GStreamer with support for plugins, APIs, and bundled dependencies
    • Added configurable options for bundling dependencies and discovering runtime plugins
    • Added helper tools for installing and patching runtime plugins
  • Documentation

    • Added comprehensive usage documentation for GStreamer CMake integration

@mikusaq mikusaq requested a review from koudis April 10, 2026 07:54
@mikusaq mikusaq self-assigned this Apr 10, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 10, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

A CMake module suite for discovering and managing GStreamer packages, including configuration for finding the GStreamer SDK, creating imported targets for core libraries and plugins, resolving runtime dependencies via readelf, and providing helper functions for pkg-config management and plugin installation/patching.

Changes

Cohort / File(s) Summary
Core CMake Finder Modules
FindGStreamer.cmake, GStreamerConfig.cmake, FindGStreamer_TOOL.cmake
Introduces GStreamer package discovery via pkg-config with support for both shared and static linking modes. Defines imported targets for core library, plugins, APIs, and dependencies. Creates runtime plugin dependency resolution via readelf. Provides helper functions for fixing pkg-config prefixes and installing/patching plugins with patchelf.
Build & Installation Configuration
CMakeLists.txt
Defines a CMake project for building and installing the GStreamer finder modules into the standard CMake data directory under ${CMAKE_INSTALL_DATADIR}/cmake/GStreamer.
Documentation
README.md
Expands documentation to describe upstream provenance, finder behaviors including bundled dependency handling, runtime plugin dependency resolution, and concrete usage instructions for configuration and installation.
Change Specification
diff/FindGStreamer.diff
Details refinements to the main finder module, including new GStreamer_BUNDLE_DEPS option, helper functions for dependency extraction and import target creation, plugin target type changes to UNKNOWN IMPORTED, and runtime plugin DT_NEEDED dependency resolution with deduplication.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add custom FindGStreamer' directly and accurately reflects the main change—introducing a new CMake FindGStreamer module with BringAuto-specific enhancements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch BAF-1258/custom-find-gstreamer

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

🧹 Nitpick comments (3)
FindGStreamer.cmake (2)

600-606: Silent failure if readelf is unavailable or fails.

readelf -d errors are suppressed with ERROR_QUIET and no RESULT_VARIABLE is checked. If readelf is not installed or fails, the dependency resolution silently produces no results, which may lead to missing runtime dependencies.

Proposed fix to warn on failure
         execute_process(
             COMMAND readelf -d "${_gst_rplugin_file}"
             OUTPUT_VARIABLE _gst_readelf_out
-            ERROR_QUIET
+            ERROR_VARIABLE _gst_readelf_err
+            RESULT_VARIABLE _gst_readelf_result
         )
+        if(NOT _gst_readelf_result EQUAL 0)
+            message(WARNING "GStreamer: readelf failed on ${_gst_rplugin} (is readelf installed?): ${_gst_readelf_err}")
+            continue()
+        endif()
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@FindGStreamer.cmake` around lines 600 - 606, The current execute_process call
that runs "readelf -d ${_gst_rplugin_file}" silences errors with ERROR_QUIET and
does not check a RESULT_VARIABLE, so if readelf is missing or fails
_gst_readelf_out will be empty and string(REGEX MATCHALL ...) on
_gst_readelf_out will silently yield no _gst_needed_entries; modify the
execute_process invocation to capture and check a RESULT_VARIABLE (e.g.,
_gst_readelf_result) and, if non-zero, emit a warning via message(WARNING ...)
that includes the command, the _gst_rplugin_file and either the captured
ERROR_VARIABLE or the empty _gst_readelf_out so users know readelf failed, while
keeping fallback behavior for environments that cannot run readelf.

587-590: Hardcoded architecture path may miss libraries on other architectures.

The SDK library directories include a hardcoded x86_64-linux-gnu path. On ARM64 or other architectures, the multiarch path would be different (e.g., aarch64-linux-gnu).

Consider deriving the multiarch triplet dynamically
     set(_gst_sdk_lib_dirs
         "${GStreamer_ROOT_DIR}/lib"
-        "${GStreamer_ROOT_DIR}/lib/x86_64-linux-gnu"
+        "${GStreamer_ROOT_DIR}/lib/${CMAKE_LIBRARY_ARCHITECTURE}"
     )

CMAKE_LIBRARY_ARCHITECTURE is set by CMake on multiarch systems. If cross-compiling or on non-multiarch systems, you may also want a fallback.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@FindGStreamer.cmake` around lines 587 - 590, The hardcoded multiarch path in
the _gst_sdk_lib_dirs list can miss libraries on non-x86_64 systems; update the
list to construct the multiarch directory using CMAKE_LIBRARY_ARCHITECTURE
(fallback to CMAKE_HOST_SYSTEM_PROCESSOR or a simple processor-to-triplet
mapping if CMAKE_LIBRARY_ARCHITECTURE is empty) instead of the literal
"x86_64-linux-gnu", referencing the existing _gst_sdk_lib_dirs variable and
GStreamer_ROOT_DIR so the second entry becomes
"${GStreamer_ROOT_DIR}/lib/${CMAKE_LIBRARY_ARCHITECTURE}" (or the computed
fallback) to cover ARM64 and other architectures.
Tools.cmake (1)

22-28: Consider checking patchelf exit status.

EXECUTE_PROCESS runs patchelf but doesn't capture or check RESULT_VARIABLE. If patchelf fails (missing tool, permission denied, etc.), the install proceeds silently without warning.

Proposed fix to capture and report failures
     INSTALL(CODE "
         FILE(GLOB _plugins \"\${CMAKE_INSTALL_PREFIX}/${_gip_dest}/libgst*.so\")
         FOREACH(_p IN LISTS _plugins)
             GET_FILENAME_COMPONENT(_pname \"\${_p}\" NAME)
             MESSAGE(STATUS \"patchelf update R/RUNPATH: ${_gip_dest}/\${_pname}\")
-            EXECUTE_PROCESS(COMMAND patchelf --set-rpath \"\$ORIGIN/..\" \"\${_p}\")
+            EXECUTE_PROCESS(
+                COMMAND patchelf --set-rpath \"\$ORIGIN/..\" \"\${_p}\"
+                RESULT_VARIABLE _patchelf_result
+            )
+            IF(NOT _patchelf_result EQUAL 0)
+                MESSAGE(WARNING \"patchelf failed on \${_pname} with code \${_patchelf_result}\")
+            ENDIF()
         ENDFOREACH()
     ")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Tools.cmake` around lines 22 - 28, The INSTALL(CODE ...) block calls
EXECUTE_PROCESS to run patchelf but doesn't check its exit status; update the
EXECUTE_PROCESS invocation in that block (the one running patchelf on _p) to set
RESULT_VARIABLE (and optionally ERROR_VARIABLE/OUTPUT_VARIABLE), then after
EXECUTE_PROCESS check the RESULT_VARIABLE and if non-zero emit a clear
MESSAGE(FATAL_ERROR "...") or MESSAGE(STATUS/ERROR with details including the
variable values) so installation fails or reports an error when patchelf fails;
refer to the existing FILE(GLOB _plugins), FOREACH(_p IN LISTS _plugins),
GET_FILENAME_COMPONENT(_pname ...) and the patchelf EXECUTE_PROCESS call to
locate where to add these checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@FindGStreamer.cmake`:
- Line 58: Fix the markdown/doc typo by adding the missing closing backtick for
the variable name `GStreamer_USE_STATIC_LIBS` in the documentation string where
it appears; locate the occurrence of GStreamer_USE_STATIC_LIBS in
FindGStreamer.cmake and wrap it with a matching pair of backticks (i.e.,
`GStreamer_USE_STATIC_LIBS`) so the variable is properly formatted as inline
code.
- Around line 469-471: The removal call list(REMOVE_AT _gst_plugin_deps 0) can
crash when _gst_plugin_deps is empty; update the logic around the
_gst_dep_libs(...) result to check if _gst_plugin_deps is NOT EMPTY before
calling list(REMOVE_AT ...) and before invoking
_gst_create_imported_dep_targets, and apply the identical guard to the other
occurrence around lines with the same pattern (the second block that sets
_gst_plugin_deps and calls list(REMOVE_AT ...) and
_gst_create_imported_dep_targets) so both places safely skip the REMOVE_AT when
the list is empty.
- Around line 246-249: The non-Apple branch incorrectly uses undefined variable
${TARGET} when setting properties; change the call to set_target_properties to
use the macro parameter ${GST_TARGET} instead (i.e., update
set_target_properties(${TARGET} PROPERTIES INTERFACE_LINK_OPTIONS ...) to
set_target_properties(${GST_TARGET} PROPERTIES INTERFACE_LINK_OPTIONS
"${${PC_STATIC_LDFLAGS_OTHER}}")). Ensure you only replace the identifier in
this invocation so other uses of TARGET (if any) are not affected.

In `@GStreamerConfig.cmake`:
- Around line 1-6: Update the header comment to clarify that GStreamer_DIR is a
CMake cache/variable (not an environment variable) used as a hint for
find_package(GStreamer), and show how to set it (e.g., via -DGStreamer_DIR=/path
or set in the CMake GUI/cache) or suggest using CMAKE_PREFIX_PATH as an
alternative; reference the symbols GStreamer_DIR and find_package(GStreamer) so
readers know where this value is consumed.

In `@README.md`:
- Around line 74-77: The README snippet uses the wrong SDK root variable name;
replace the mismatched `${GSTREAMER_DIR}` with the module's correct
`GStreamer_ROOT_DIR` so the example call to BA_FIX_PKGCONFIG and the subsequent
find_package(GStreamer REQUIRED) match the actual variable name used by the
module; update the example to use `${GStreamer_ROOT_DIR}` consistently.
- Around line 34-38: The README incorrectly suggests exporting GStreamer_DIR as
a shell environment variable; clarify that GStreamer_DIR is a CMake cache
variable used by find_package, and instruct users to pass it to CMake with
-DGStreamer_DIR=... or to set it inside their CMakeLists.txt (or via
cmake-gui/ccmake) rather than exporting it in ~/.bashrc; reference the
GStreamer_DIR name and the find_package call so maintainers know where to update
the text.
- Around line 30-32: Replace the incorrect git clone URL in README.md (the line
containing "git clone https://github.com/bacpack-system/ba-find-gstreamer
~/ba-find-gstreamer") with the correct repository URL
"https://github.com/bringauto/find-gstreamer.git" so the example clone command
uses the actual repository location; update the command string accordingly and
include the .git suffix.

In `@Tools.cmake`:
- Around line 13-14: The FATAL_ERROR message uses the wrong function name;
update the MESSAGE(FATAL_ERROR ...) text to reference the correct function
BA_INSTALL_AND_PATCHELF_GSTREAMER_PLUGINS (the check guarding _gip_DESTINATION)
so the error reads something like "BA_INSTALL_AND_PATCHELF_GSTREAMER_PLUGINS:
DESTINATION is required"; locate the conditional that checks IF(NOT
_gip_DESTINATION) and replace the existing "GStreamer_install_plugins" string
with "BA_INSTALL_AND_PATCHELF_GSTREAMER_PLUGINS".

---

Nitpick comments:
In `@FindGStreamer.cmake`:
- Around line 600-606: The current execute_process call that runs "readelf -d
${_gst_rplugin_file}" silences errors with ERROR_QUIET and does not check a
RESULT_VARIABLE, so if readelf is missing or fails _gst_readelf_out will be
empty and string(REGEX MATCHALL ...) on _gst_readelf_out will silently yield no
_gst_needed_entries; modify the execute_process invocation to capture and check
a RESULT_VARIABLE (e.g., _gst_readelf_result) and, if non-zero, emit a warning
via message(WARNING ...) that includes the command, the _gst_rplugin_file and
either the captured ERROR_VARIABLE or the empty _gst_readelf_out so users know
readelf failed, while keeping fallback behavior for environments that cannot run
readelf.
- Around line 587-590: The hardcoded multiarch path in the _gst_sdk_lib_dirs
list can miss libraries on non-x86_64 systems; update the list to construct the
multiarch directory using CMAKE_LIBRARY_ARCHITECTURE (fallback to
CMAKE_HOST_SYSTEM_PROCESSOR or a simple processor-to-triplet mapping if
CMAKE_LIBRARY_ARCHITECTURE is empty) instead of the literal "x86_64-linux-gnu",
referencing the existing _gst_sdk_lib_dirs variable and GStreamer_ROOT_DIR so
the second entry becomes
"${GStreamer_ROOT_DIR}/lib/${CMAKE_LIBRARY_ARCHITECTURE}" (or the computed
fallback) to cover ARM64 and other architectures.

In `@Tools.cmake`:
- Around line 22-28: The INSTALL(CODE ...) block calls EXECUTE_PROCESS to run
patchelf but doesn't check its exit status; update the EXECUTE_PROCESS
invocation in that block (the one running patchelf on _p) to set RESULT_VARIABLE
(and optionally ERROR_VARIABLE/OUTPUT_VARIABLE), then after EXECUTE_PROCESS
check the RESULT_VARIABLE and if non-zero emit a clear MESSAGE(FATAL_ERROR
"...") or MESSAGE(STATUS/ERROR with details including the variable values) so
installation fails or reports an error when patchelf fails; refer to the
existing FILE(GLOB _plugins), FOREACH(_p IN LISTS _plugins),
GET_FILENAME_COMPONENT(_pname ...) and the patchelf EXECUTE_PROCESS call to
locate where to add these checks.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 20d1ca19-c194-439c-94e4-92e988ed7889

📥 Commits

Reviewing files that changed from the base of the PR and between b837cfc and 0a23fb9.

📒 Files selected for processing (5)
  • FindGStreamer.cmake
  • GStreamerConfig.cmake
  • README.md
  • Tools.cmake
  • diff/FindGStreamer.diff

Comment thread FindGStreamer.cmake Outdated
Comment thread FindGStreamer.cmake
Comment thread FindGStreamer.cmake
Comment thread GStreamerConfig.cmake
Comment thread README.md
Comment thread README.md
Comment thread README.md
Comment thread Tools.cmake Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@FindGStreamer.cmake`:
- Line 429: The guard compares the wrong-cased variable: change checks using
"${_gst_plugin}" to use the loop variable "${_gst_PLUGIN}" so the IN_LIST check
against _gst_CUSTOM_TARGETS works; update every occurrence where _gst_plugin
(lowercase) is used in the IN_LIST guard (e.g., the checks currently using
"${_gst_plugin}") to "${_gst_PLUGIN}" to match the loop variable and prevent
duplicate target creation.
- Around line 451-453: When pkg_check_modules succeeds but
_gst_find_plugin_library returns empty, the component variable
GStreamer_${_gst_PLUGIN}_FOUND (and similarly GStreamer_${_gst_API}_FOUND in the
GSTREAMER_APIS loop) should be set to FALSE before continuing so
HANDLE_COMPONENTS doesn't report a found component with no importable library;
modify the GSTREAMER_PLUGINS and GSTREAMER_APIS loops to check if
_gst_plugin_library (or equivalent _gst_api_library) is empty and explicitly set
GStreamer_${_gst_PLUGIN}_FOUND=FALSE (or GStreamer_${_gst_API}_FOUND=FALSE)
prior to calling continue(), keeping the pkg_check_modules result intact but
ensuring the FOUND flag reflects the missing library.
- Line 253: Guard the list(GET ...) call against empty pkg-config results:
before calling list(GET PC_GStreamer_${_plugin}_LIBRARIES 0 _lib_name) check
that the variable PC_GStreamer_${_plugin}_LIBRARIES is non-empty (e.g. with
list(LENGTH PC_GStreamer_${_plugin}_LIBRARIES _len) and if(_len GREATER 0) or an
if(PC_GStreamer_${_plugin}_LIBRARIES) conditional) and only call list(GET ...)
when the length is > 0 so header-only packages (or empty library lists) don’t
cause a hard error during configure.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 39ba8fc5-8623-47a3-a221-8a85400e21d9

📥 Commits

Reviewing files that changed from the base of the PR and between 0a23fb9 and 6297c1a.

📒 Files selected for processing (4)
  • FindGStreamer.cmake
  • README.md
  • Tools.cmake
  • diff/FindGStreamer.diff
✅ Files skipped from review due to trivial changes (2)
  • README.md
  • Tools.cmake
🚧 Files skipped from review as they are similar to previous changes (1)
  • diff/FindGStreamer.diff

Comment thread FindGStreamer.cmake
Comment thread FindGStreamer.cmake
Comment thread FindGStreamer.cmake
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@FindGStreamer.cmake`:
- Around line 15-16: The documentation in this module references the wrong CMake
option name: update all occurrences of the documented static-link toggle from
GStreamer_STATIC to the actual option name GStreamer_USE_STATIC_LIBS (including
the description at the top and the other occurrences noted around the later doc
block), so that cmake --help-module points to the correct variable; ensure the
descriptive text and any short option mention exactly match the symbol
GStreamer_USE_STATIC_LIBS used by the FindGStreamer logic.
- Around line 573-652: Wrap the Linux/ELF-specific plugin discovery and readelf
logic (the block that builds GStreamer_PLUGIN_TARGETS, globbing libgst*.so and
using execute_process(readelf -d ...) and _gst_create_imported_dep_targets for
GSTREAMER_RUNTIME_PLUGINS) inside a platform guard so it only runs on Linux/ELF
hosts; use the same CMAKE_HOST_SYSTEM_NAME pattern used elsewhere (e.g., check
for CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" or UNIX AND NOT APPLE) so
macOS/Windows skip the .so/readelf logic and avoid spurious failures.
- Around line 111-118: The code currently mutates ENV{PKG_CONFIG_PATH} and
ENV{PKG_CONFIG_DONT_DEFINE_PREFIX} globally in FindGStreamer.cmake; preserve the
caller's environment by saving the original ENV values (e.g., store previous
ENV{PKG_CONFIG_PATH} and ENV{PKG_CONFIG_DONT_DEFINE_PREFIX} into local
variables) before you set them in the Windows and non-Windows branches, and
restore those saved ENV variables (or unset them if they were not set) at the
same point where PKG_CONFIG_EXECUTABLE is restored; apply the same
save/modify/restore pattern for the duplicate occurrence around lines 659–661 so
find_package(GStreamer) leaves no lasting ENV side effects.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5be25ddc-d053-4289-bf94-da82c8a607c7

📥 Commits

Reviewing files that changed from the base of the PR and between 6297c1a and 4a64984.

📒 Files selected for processing (2)
  • FindGStreamer.cmake
  • diff/FindGStreamer.diff
🚧 Files skipped from review as they are similar to previous changes (1)
  • diff/FindGStreamer.diff

Comment thread FindGStreamer.cmake Outdated
Comment thread FindGStreamer.cmake
Comment thread FindGStreamer.cmake
Comment thread README.md

## Installation

Clone the repository to a stable location:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: In BA projects I would prefer to add FindGStreamer as a package. Just add CMakeLists, install FindGstreamer and create a standard CMake package.
Maybe add a section about how to use it with the packager?

Then the following is possible without installing FindGstreamer manually:

BA_PACKAGE_LIBRARY(FindGStreamer vx.x.x OUTPUT_PATH_VAR GStreamer_DIR)
BA_PACKAGE_LIBRARY(gstreamerv 1.28.1 OUTPUT_PATH_VAR GStreamer_ROOT_DIR)
....
find_package(GStreamer REQUIRED)

Copy link
Copy Markdown
Collaborator Author

@mikusaq mikusaq Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, done. But look at the installation path, now in order to include it in rtsp-server I need to run:

BA_PACKAGE_LIBRARY(find-gstreamer v1.0.0 OUTPUT_PATH_VAR FindGStreamer_DIR)
...
INCLUDE(${FindGStreamer_DIR}/share/cmake/GStreamer/FindGStreamer_TOOL.cmake)

Which does not seem very clear, should I change it somehow, what do you think?
The include is needed, because I need to call FindGStreamer_TOOL_FIX_PKGCONFIG before FIND_PACKAGE(GStreamer) to fix the install prefixes beforehand.

Comment thread Tools.cmake Outdated
Comment thread Tools.cmake Outdated
Comment thread Tools.cmake Outdated
Comment thread Tools.cmake Outdated
mikusaq added 3 commits April 17, 2026 10:18
Add function documentation. Using FIND_PROGRAM for patchelf. Unifies function
parameter handling. Remove using external parameters.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
FindGStreamer_TOOL.cmake (2)

13-19: Consider anchoring the /INSTALL replacement to avoid unintended matches.

STRING(REPLACE "/INSTALL" "${_bfp_DIR}" ...) will replace every occurrence of the substring /INSTALL in the .pc file, including within longer paths or comments that happen to contain that literal (e.g., /INSTALLED, /path/to/INSTALL/... — any occurrence). For .pc files this is typically safe because /INSTALL is used as a sentinel prefix at the start of path values, but if the sentinel ever collides with real content the rewrite will silently corrupt the file.

If the sentinel is always a leading path component, consider using STRING(REGEX REPLACE "(^|=| |:)/INSTALL(/|$)" ...) or a more specific sentinel like /INSTALL_PREFIX_PLACEHOLDER to reduce ambiguity. Not a blocker given the controlled SDK build, just a robustness note.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@FindGStreamer_TOOL.cmake` around lines 13 - 19, The current blind replacement
of "/INSTALL" can corrupt unrelated occurrences; update the rewrite to only
replace the sentinel when it appears as a leading path component or a clearly
delimited token by switching from STRING(REPLACE ...) to STRING(REGEX REPLACE
...) and match anchors around /INSTALL (e.g. beginning of line, after '=' or
whitespace, and followed by '/' or end) when transforming pc_content into
pc_content_fixed; locate the logic that iterates PC_FILES and reads/writes
pc_file (PC_FILES, pc_file, FILE(READ), FILE(WRITE), pc_content,
pc_content_fixed) and apply the anchored regex replacement there or
alternatively require a more specific sentinel like /INSTALL_PREFIX_PLACEHOLDER
and replace that exact token instead.

39-43: Absolute DESTINATION will break the install-time glob.

Line 45 constructs the glob path as ${CMAKE_INSTALL_PREFIX}/${_gip_dest}. If a caller passes an absolute path to DESTINATION (which install(... DESTINATION) itself accepts and treats as absolute), the glob will resolve to a nonsensical path like /opt/foo//abs/path and silently find nothing, so no plugins get patched. Consider either documenting that DESTINATION must be relative, or handling the absolute case explicitly (e.g., use IS_ABSOLUTE and skip the prefix join).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@FindGStreamer_TOOL.cmake` around lines 39 - 43, The install DESTINATION may
be absolute so the later glob that builds "${CMAKE_INSTALL_PREFIX}/${_gip_dest}"
can produce incorrect paths; update the logic around SET(_gip_dest
"${_gip_DESTINATION}") to detect absolute paths (use CMake's IS_ABSOLUTE test on
_gip_DESTINATION) and, if absolute, set _gip_dest to the absolute value
unchanged, otherwise prepend CMAKE_INSTALL_PREFIX (or the intended prefix) as
before; reference the variables _gip_DESTINATION and _gip_dest and the
INSTALL(IMPORTED_RUNTIME_ARTIFACTS ...) block when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@FindGStreamer_TOOL.cmake`:
- Around line 44-51: The INSTALL(CODE ...) block runs patchelf via
EXECUTE_PROCESS using the cached variable _gip_PATCHELF but currently ignores
failures; update the EXECUTE_PROCESS call inside the INSTALL(CODE) so it
captures the result (use RESULT_VARIABLE) and makes errors fatal (use
COMMAND_ERROR_IS_FATAL or test the result and call MESSAGE(FATAL_ERROR)), and
after resolving/using _gip_PATCHELF add a runtime check (inside the same
INSTALL(CODE)) to verify the patchelf path exists and fail the install if
missing; alternatively resolve patchelf inside the install script (use
FIND_PROGRAM there) instead of relying on the configure-time _gip_PATCHELF to
avoid bake-in on different install hosts.

---

Nitpick comments:
In `@FindGStreamer_TOOL.cmake`:
- Around line 13-19: The current blind replacement of "/INSTALL" can corrupt
unrelated occurrences; update the rewrite to only replace the sentinel when it
appears as a leading path component or a clearly delimited token by switching
from STRING(REPLACE ...) to STRING(REGEX REPLACE ...) and match anchors around
/INSTALL (e.g. beginning of line, after '=' or whitespace, and followed by '/'
or end) when transforming pc_content into pc_content_fixed; locate the logic
that iterates PC_FILES and reads/writes pc_file (PC_FILES, pc_file, FILE(READ),
FILE(WRITE), pc_content, pc_content_fixed) and apply the anchored regex
replacement there or alternatively require a more specific sentinel like
/INSTALL_PREFIX_PLACEHOLDER and replace that exact token instead.
- Around line 39-43: The install DESTINATION may be absolute so the later glob
that builds "${CMAKE_INSTALL_PREFIX}/${_gip_dest}" can produce incorrect paths;
update the logic around SET(_gip_dest "${_gip_DESTINATION}") to detect absolute
paths (use CMake's IS_ABSOLUTE test on _gip_DESTINATION) and, if absolute, set
_gip_dest to the absolute value unchanged, otherwise prepend
CMAKE_INSTALL_PREFIX (or the intended prefix) as before; reference the variables
_gip_DESTINATION and _gip_dest and the INSTALL(IMPORTED_RUNTIME_ARTIFACTS ...)
block when making the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5f285bf3-3964-4147-9874-5ba1cf0fdf0f

📥 Commits

Reviewing files that changed from the base of the PR and between 578bbba and ca8c775.

📒 Files selected for processing (4)
  • CMakeLists.txt
  • FindGStreamer_TOOL.cmake
  • GStreamerConfig.cmake
  • README.md
✅ Files skipped from review due to trivial changes (2)
  • GStreamerConfig.cmake
  • CMakeLists.txt

Comment thread FindGStreamer_TOOL.cmake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants