Skip to content

Commit 7582025

Browse files
committed
feat: Add pkg-config support
- 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
1 parent 5d60bff commit 7582025

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
**Features**:
66

7+
- Add pkg-config support ([#1411](https://github.com/getsentry/sentry-native/pull/1411))
78
- Add support for outgoing W3C traceparent header propagation with the `propagate_traceparent` option. ([#1394](https://github.com/getsentry/sentry-native/pull/1394))
89

910
**Fixes**:

CMakeLists.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}")
193193
endif()
194194

195195
option(SENTRY_ENABLE_INSTALL "Enable sentry installation" "${SENTRY_MAIN_PROJECT}")
196+
option(SENTRY_INSTALL_PKGCONFIG "Generate and install pkg-config file" ON)
196197

197198
if(MSVC AND CMAKE_GENERATOR_TOOLSET MATCHES "_xp$")
198199
message(WARNING "Crashpad is not supported for MSVC with XP toolset. Default backend was switched to 'breakpad'")
@@ -819,3 +820,29 @@ if(SENTRY_BUILD_SHARED_LIBS)
819820
"$<$<PLATFORM_ID:Android>:-Wl,-z,max-page-size=16384>"
820821
)
821822
endif()
823+
824+
# Generate and install pkg-config file
825+
if(SENTRY_INSTALL_PKGCONFIG)
826+
set(PREFIX "${CMAKE_INSTALL_PREFIX}")
827+
set(PKGCONFIG_VERSION "${SENTRY_VERSION_FULL}")
828+
# Use absolute paths for libdir and includedir to support non-standard layouts (e.g., lib64)
829+
if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
830+
set(PKGCONFIG_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
831+
else()
832+
set(PKGCONFIG_LIBDIR "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
833+
endif()
834+
if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
835+
set(PKGCONFIG_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
836+
else()
837+
set(PKGCONFIG_INCLUDEDIR "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
838+
endif()
839+
configure_file(
840+
"${CMAKE_CURRENT_SOURCE_DIR}/sentry.pc.in"
841+
"${CMAKE_CURRENT_BINARY_DIR}/sentry.pc"
842+
@ONLY
843+
)
844+
sentry_install(
845+
FILES "${CMAKE_CURRENT_BINARY_DIR}/sentry.pc"
846+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
847+
)
848+
endif()

sentry.pc.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
prefix=@PREFIX@
2+
exec_prefix=${prefix}
3+
libdir=@PKGCONFIG_LIBDIR@
4+
includedir=@PKGCONFIG_INCLUDEDIR@
5+
6+
Name: sentry
7+
Description: Sentry SDK for C, C++ and native applications
8+
Version: @PKGCONFIG_VERSION@
9+
URL: https://sentry.io/
10+
Libs: -L${libdir} -lsentry
11+
Cflags: -I${includedir}

0 commit comments

Comments
 (0)