Skip to content

Conversation

@nmandelblit
Copy link

@nmandelblit nmandelblit commented Oct 10, 2025

Summary

  • Added support for generating and installing a .pc file for pkg-config
  • Controlled by the SENTRY_INSTALL_PKGCONFIG CMake option
  • Uses the existing sentry.pc.in template to generate the pkg-config file
  • Installs the generated file to the standard pkg-config directory (${CMAKE_INSTALL_LIBDIR}/pkgconfig)

Benefits

This allows downstream projects to easily discover and link against sentry-native using pkg-config:

pkg-config --cflags --libs sentry

Test plan

  • Build with SENTRY_INSTALL_PKGCONFIG enabled
  • Verify sentry.pc file is generated in build directory
  • Verify sentry.pc file is installed to correct location
  • Test that pkg-config can find and use the installed file

cursor[bot]

This comment was marked as outdated.

sentry.pc.in Outdated
@@ -0,0 +1,11 @@
prefix=@PREFIX@
exec_prefix=${prefix}
libdir=${prefix}/lib

Choose a reason for hiding this comment

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

Potential bug: The pkg-config template hardcodes the library directory to lib, but the actual installation may use lib64 on some systems, causing linker errors.
  • Description: The pkg-config template file sentry.pc.in hardcodes the library directory with libdir=${prefix}/lib. However, the actual library installation uses the CMAKE_INSTALL_LIBDIR variable, which resolves to lib64 on many common 64-bit Linux distributions like RHEL, Fedora, and CentOS. This discrepancy causes pkg-config to provide an incorrect library path to downstream projects. As a result, the linker will fail to find the sentry library because it searches in the wrong directory, preventing dependent applications from building successfully on these platforms.

  • Suggested fix: The sentry.pc.in template should not hardcode the libdir. Instead, it should be configured by CMake during the build process. Replace the hardcoded libdir=${prefix}/lib line with a placeholder like libdir=@CMAKE_INSTALL_FULL_LIBDIR@. Then, in CMakeLists.txt, use the configure_file command to substitute this placeholder with the correct value from CMAKE_INSTALL_LIBDIR when generating the final sentry.pc file.
    severity: 0.75, confidence: 0.95

Did we get this right? 👍 / 👎 to inform future reviews.

cursor[bot]

This comment was marked as outdated.

@nmandelblit nmandelblit force-pushed the add-pc-pkgconfig branch 2 times, most recently from 06fe500 to c4b2054 Compare October 10, 2025 13:44
- Added support for generating and installing a .pc file for pkg-config
- Controlled by the SENTRY_INSTALL_PKGCONFIG CMake option
- Uses CMAKE_INSTALL_LIBDIR and CMAKE_INSTALL_INCLUDEDIR to support non-standard layouts (e.g., lib64)
- Installs the generated file to the standard pkg-config directory
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.

3 participants