From 7fa1c7a246d2b00b6d1713f11786b6c72783bd4e Mon Sep 17 00:00:00 2001 From: mertefesensoy Date: Thu, 20 Aug 2026 08:16:25 +0000 Subject: [PATCH 1/2] build: make pkg-config optional for the system libunwind/breakpad options `SENTRY_LIBUNWIND_SYSTEM` and `SENTRY_BREAKPAD_SYSTEM` located their dependencies with `find_package(PkgConfig REQUIRED)` + `pkg_check_modules(... REQUIRED ...)`, and the exported `sentry-config.cmake` repeated that for consumers of a static build. Those are the only places in this project that ever touch pkg-config, and only on Linux, but because the requirement is unconditional and hard, packagers have to provide the tool on every platform they build sentry-native for -- including Windows and macOS, where it is never invoked. Add `cmake/sentry-find-system-library.cmake`, which prefers the pkg-config metadata when both the tool and the `.pc` module are present and otherwise resolves the library and its headers with `find_library()` / `find_path()`. Both branches define the same imported target (`sentry::libunwind`, `sentry::libunwind-ptrace`, `sentry::breakpad-client`), so the call sites and the installed config no longer care which lookup succeeded, and a missing dependency now reports what could not be found instead of failing inside FindPkgConfig. The module is installed next to `sentry-config.cmake` so consumers of a static build recreate the targets the same way. As a side effect the crash daemon's `libunwind-ptrace` lookup no longer depends on an earlier `find_package(PkgConfig)` call having run elsewhere in the file. Verified on Linux for the system-libunwind path (static and shared, `SENTRY_BACKEND=native`) and the system-breakpad path, each with pkg-config available, with pkg-config unavailable, and with pkg-config present but the `.pc` module missing; including install and a downstream `find_package(sentry)` build in each case. --- CHANGELOG.md | 1 + CMakeLists.txt | 23 ++--- README.md | 9 +- cmake/sentry-find-system-library.cmake | 112 +++++++++++++++++++++++++ sentry-config.cmake.in | 7 +- 5 files changed, 135 insertions(+), 17 deletions(-) create mode 100644 cmake/sentry-find-system-library.cmake diff --git a/CHANGELOG.md b/CHANGELOG.md index 98eacde709..36287b9ec1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - Native: store daemon logs, minidumps, crash envelopes, and scratch files in `.run` directories so they are cleaned up with the run instead of accumulating in the database root. Minidumps can still be retained with `cache_keep`, which stores `.dmp` sidecars alongside cached envelopes. ([#1976](https://github.com/getsentry/sentry-native/pull/1976)) - Linux/ARM32: prevent recursive crashes when libunwind receives an unmapped initial instruction pointer during crash handling. ([#1977](https://github.com/getsentry/sentry-native/pull/1977)) +- CMake: `pkg-config` is no longer a hard build requirement. `SENTRY_LIBUNWIND_SYSTEM` and `SENTRY_BREAKPAD_SYSTEM` still prefer the `pkg-config` metadata of the system package, but now fall back to `find_library()`/`find_path()` when the tool or the `.pc` file is missing. The same applies to the exported CMake config, which no longer requires consumers of a static build to have `pkg-config` installed. ## 0.16.3 diff --git a/CMakeLists.txt b/CMakeLists.txt index e955145be8..ad90eebe65 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -640,6 +640,7 @@ if(WIN32) endif() include(cmake/utils.cmake) +include(cmake/sentry-find-system-library.cmake) if (WIN32 AND SENTRY_BUILD_SHARED_LIBS) sentry_add_version_resource(sentry "Client Library") endif() @@ -705,12 +706,11 @@ endif() if(SENTRY_WITH_LIBUNWIND) if(LINUX) if(SENTRY_LIBUNWIND_SYSTEM) - find_package(PkgConfig REQUIRED) - pkg_check_modules(LIBUNWIND REQUIRED IMPORTED_TARGET libunwind) + sentry_find_libunwind() if(SENTRY_BUILD_SHARED_LIBS) - target_link_libraries(sentry PRIVATE PkgConfig::LIBUNWIND) + target_link_libraries(sentry PRIVATE sentry::libunwind) else() - target_link_libraries(sentry PUBLIC PkgConfig::LIBUNWIND) + target_link_libraries(sentry PUBLIC sentry::libunwind) endif() else() # Use vendored libunwind @@ -802,13 +802,12 @@ elseif(SENTRY_BACKEND_BREAKPAD) option(SENTRY_BREAKPAD_SYSTEM "Use system breakpad" OFF) if(SENTRY_BREAKPAD_SYSTEM) target_compile_definitions(sentry PRIVATE SENTRY_BREAKPAD_SYSTEM) - # system breakpad is using pkg-config, see `external/breakpad/breakpad-client.pc.in` - find_package(PkgConfig REQUIRED) - pkg_check_modules(BREAKPAD REQUIRED IMPORTED_TARGET breakpad-client) + # system breakpad ships pkg-config metadata, see `external/breakpad/breakpad-client.pc.in` + sentry_find_breakpad_client() if(SENTRY_BUILD_SHARED_LIBS) - target_link_libraries(sentry PRIVATE PkgConfig::BREAKPAD) + target_link_libraries(sentry PRIVATE sentry::breakpad-client) else() - target_link_libraries(sentry PUBLIC PkgConfig::BREAKPAD) + target_link_libraries(sentry PUBLIC sentry::breakpad-client) endif() else() add_subdirectory(external) @@ -934,8 +933,8 @@ elseif(SENTRY_BACKEND_NATIVE) if(SENTRY_WITH_LIBUNWIND AND LINUX) if(SENTRY_LIBUNWIND_SYSTEM) - pkg_check_modules(LIBUNWIND_PTRACE REQUIRED IMPORTED_TARGET libunwind-ptrace) - target_link_libraries(sentry-crash PRIVATE PkgConfig::LIBUNWIND PkgConfig::LIBUNWIND_PTRACE) + sentry_find_libunwind_ptrace() + target_link_libraries(sentry-crash PRIVATE sentry::libunwind sentry::libunwind-ptrace) else() # Use unwind_remote for the daemon (includes ptrace accessors # for remote DWARF unwinding of the crashed process) @@ -1018,6 +1017,8 @@ sentry_install( FILES "${PROJECT_BINARY_DIR}/sentry-config.cmake" "${PROJECT_BINARY_DIR}/sentry-config-version.cmake" + # `sentry-config.cmake` recreates the system-library targets for consumers of a static build + "${SENTRY_SOURCE_DIR}/cmake/sentry-find-system-library.cmake" DESTINATION "${CMAKE_INSTALL_CMAKEDIR}") if(WIN32 AND MSVC AND SENTRY_BUILD_SHARED_LIBS) sentry_install(FILES $ diff --git a/README.md b/README.md index d9c63cc171..c895fa592a 100644 --- a/README.md +++ b/README.md @@ -266,8 +266,8 @@ using `cmake -D BUILD_SHARED_LIBS=OFF ..`. This instructs the build system to use system-installed breakpad libraries instead of the in-tree version. - `SENTRY_LIBUNWIND_SYSTEM` (Default: `OFF`, only for Linux): - This instructs the build system to use a system-installed `libunwind` (found via `pkg-config`) instead of the - vendored copy in `vendor/libunwind`. + This instructs the build system to use a system-installed `libunwind` instead of the vendored copy in + `vendor/libunwind`. In contrast to the vendored `libunwind` which is always built as a static archive and either linked into the resulting shared library or colocated with the other static artifacts, with `SENTRY_LIBUNWIND_SYSTEM=ON`, the library @@ -275,6 +275,11 @@ using `cmake -D BUILD_SHARED_LIBS=OFF ..`. controls how the dependency is exposed to consuming CMake projects, not the library type of the system `libunwind` itself. Ensure matching build and target environments when using system packages. + Both `SENTRY_BREAKPAD_SYSTEM` and `SENTRY_LIBUNWIND_SYSTEM` read the `pkg-config` metadata of the system package + when `pkg-config`/`pkgconf` is installed, and fall back to CMake's own `find_library()`/`find_path()` lookup when it + is not, so `pkg-config` is a convenience rather than a build requirement for either option. The only remaining + build-time user of `pkg-config` is the vendored `crashpad`, and only on Linux with `CRASHPAD_ENABLE_STACKTRACE=ON`. + - `SENTRY_TRANSPORT_COMPRESSION` (Default: `OFF`): Adds Gzip transport compression. Requires `zlib`. diff --git a/cmake/sentry-find-system-library.cmake b/cmake/sentry-find-system-library.cmake new file mode 100644 index 0000000000..f06542b15b --- /dev/null +++ b/cmake/sentry-find-system-library.cmake @@ -0,0 +1,112 @@ +# Locates a system library, preferring `pkg-config` metadata when both the tool and the requested module are +# available, and falling back to plain `find_library()`/`find_path()` when they are not. +# +# `pkg-config` is only ever consulted for the optional `SENTRY_LIBUNWIND_SYSTEM` and `SENTRY_BREAKPAD_SYSTEM` code +# paths, and only on Linux. Requesting it with `find_package(PkgConfig REQUIRED)` nevertheless turned the tool into a +# hard build requirement for anyone packaging sentry-native, which is why package managers end up declaring it on +# every platform, including those where it is never invoked. +# +# On success the imported target `TGT` is defined regardless of which of the two lookups provided it, so neither the +# call sites nor the installed `sentry-config.cmake` have to branch on the outcome. +# +# sentry_find_system_library( +# PKG_CONFIG_MODULE +# LIBRARY_NAMES ... +# [HEADER_NAMES
...] +# [HEADER_PATH_SUFFIXES ...]) +function(sentry_find_system_library TGT) + cmake_parse_arguments(SFSL "" "PKG_CONFIG_MODULE" "LIBRARY_NAMES;HEADER_NAMES;HEADER_PATH_SUFFIXES" ${ARGN}) + + if(TARGET "${TGT}") + return() + endif() + + string(MAKE_C_IDENTIFIER "${TGT}" prefix) + string(TOUPPER "${prefix}" prefix) + + # `pkg-config` resolves transitive `Requires:` and `Libs.private:` entries for us, so prefer it when available. + find_package(PkgConfig QUIET) + if(PKG_CONFIG_FOUND) + pkg_check_modules("${prefix}" QUIET IMPORTED_TARGET "${SFSL_PKG_CONFIG_MODULE}") + endif() + + if(TARGET "PkgConfig::${prefix}") + add_library("${TGT}" INTERFACE IMPORTED) + set_target_properties("${TGT}" PROPERTIES INTERFACE_LINK_LIBRARIES "PkgConfig::${prefix}") + return() + endif() + + # No usable `pkg-config` module, so resolve the library and its headers ourselves. + set(libraries "") + set(missing "") + foreach(name IN LISTS SFSL_LIBRARY_NAMES) + string(MAKE_C_IDENTIFIER "SENTRY_${prefix}_${name}_LIBRARY" cache_var) + find_library("${cache_var}" NAMES "${name}") + mark_as_advanced("${cache_var}") + if(${cache_var}) + list(APPEND libraries "${${cache_var}}") + else() + list(APPEND missing "lib${name}") + endif() + endforeach() + + set(include_dir "") + if(SFSL_HEADER_NAMES) + string(MAKE_C_IDENTIFIER "SENTRY_${prefix}_INCLUDE_DIR" cache_var) + if(SFSL_HEADER_PATH_SUFFIXES) + find_path("${cache_var}" NAMES ${SFSL_HEADER_NAMES} PATH_SUFFIXES ${SFSL_HEADER_PATH_SUFFIXES}) + else() + find_path("${cache_var}" NAMES ${SFSL_HEADER_NAMES}) + endif() + mark_as_advanced("${cache_var}") + if(${cache_var}) + set(include_dir "${${cache_var}}") + else() + list(GET SFSL_HEADER_NAMES 0 header) + list(APPEND missing "${header}") + endif() + endif() + + if(missing) + string(REPLACE ";" ", " missing "${missing}") + message(FATAL_ERROR + "Could not find the system dependency `${SFSL_PKG_CONFIG_MODULE}` needed for `${TGT}`.\n" + "Missing: ${missing}.\n" + "Install the matching development package, point CMake at it via `CMAKE_PREFIX_PATH`, or install " + "`pkg-config`/`pkgconf` so that `${SFSL_PKG_CONFIG_MODULE}.pc` can be used instead.") + endif() + + add_library("${TGT}" INTERFACE IMPORTED) + set_target_properties("${TGT}" PROPERTIES INTERFACE_LINK_LIBRARIES "${libraries}") + if(include_dir) + set_target_properties("${TGT}" PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${include_dir}") + endif() +endfunction() + +# The lookups below are shared between the build itself and the installed `sentry-config.cmake`, which has to recreate +# the same imported targets for consumers of a static sentry-native. Keeping them here means the two cannot drift. + +function(sentry_find_libunwind) + sentry_find_system_library(sentry::libunwind + PKG_CONFIG_MODULE libunwind + LIBRARY_NAMES unwind + HEADER_NAMES libunwind.h) +endfunction() + +function(sentry_find_libunwind_ptrace) + # `libunwind-ptrace.pc` pulls in `libunwind-generic`, so the fallback has to link it explicitly. + sentry_find_system_library(sentry::libunwind-ptrace + PKG_CONFIG_MODULE libunwind-ptrace + LIBRARY_NAMES unwind-ptrace unwind-generic + HEADER_NAMES libunwind-ptrace.h) +endfunction() + +function(sentry_find_breakpad_client) + # `breakpad-client.pc` exposes the headers below `${includedir}/breakpad`, matching the `client//...` + # includes in `src/backends/sentry_backend_breakpad.cpp`. + sentry_find_system_library(sentry::breakpad-client + PKG_CONFIG_MODULE breakpad-client + LIBRARY_NAMES breakpad_client + HEADER_NAMES google_breakpad/common/breakpad_types.h + HEADER_PATH_SUFFIXES breakpad) +endfunction() diff --git a/sentry-config.cmake.in b/sentry-config.cmake.in index 73ac15117c..a30b7c3c2d 100644 --- a/sentry-config.cmake.in +++ b/sentry-config.cmake.in @@ -1,5 +1,6 @@ @PACKAGE_INIT@ include(CMakeFindDependencyMacro) +include("${CMAKE_CURRENT_LIST_DIR}/sentry-find-system-library.cmake") set(SENTRY_BACKEND @SENTRY_BACKEND@) set(SENTRY_TRANSPORT @SENTRY_TRANSPORT@) @@ -16,12 +17,10 @@ if(NOT SENTRY_BUILD_SHARED_LIBS) find_dependency(ZLIB) endif() if(SENTRY_BACKEND STREQUAL "breakpad" AND SENTRY_BREAKPAD_SYSTEM) - find_dependency(PkgConfig) - pkg_check_modules(BREAKPAD REQUIRED IMPORTED_TARGET breakpad-client) + sentry_find_breakpad_client() endif() if(SENTRY_LIBUNWIND_SYSTEM) - find_dependency(PkgConfig) - pkg_check_modules(LIBUNWIND REQUIRED IMPORTED_TARGET libunwind) + sentry_find_libunwind() endif() if(SENTRY_TRANSPORT STREQUAL "curl" AND NOT SENTRY_LINK_CURL STREQUAL "OFF") find_dependency(CURL) From d7746bfe4a0a9ca6a3c2ae4836ac40c7cf8e0349 Mon Sep 17 00:00:00 2001 From: mertefesensoy Date: Sun, 23 Aug 2026 12:10:09 +0000 Subject: [PATCH 2/2] build: follow CMake's find-module idiom for the system library lookup Reviewer feedback on the previous version: the discovery logic was bespoke and noisier than it needed to be. It is -- CMake already treats this as a solved pattern, and 14 of the 162 find modules it ships follow it. `FindLibinput` is the closest match. Restructure `sentry_find_system_library()` the same way: * `pkg-config` supplies `HINTS` for `find_library()`/`find_path()` instead of being a second code path that returns a `PkgConfig::` target. One lookup now, not two, so there is no branch to get wrong. * `find_package_handle_standard_args()` replaces the hand-rolled `message(FATAL_ERROR)`, which brings the standard "Could NOT find X (missing: ...)" diagnostic and the usual found/required handling. * Carry `CFLAGS_OTHER` from the `.pc` onto the imported target when pkg-config did resolve, which the previous version dropped. The `pkg_check_modules()` call stays guarded: the command is defined by `FindPkgConfig` itself, so it does not exist when that module was never loaded (for instance under `CMAKE_DISABLE_FIND_PACKAGE_PkgConfig`). One behavioural consequence: with a single lookup path there is no transitive `Requires:` resolution, so `libunwind-ptrace` names `libunwind-generic` itself. The previous fallback already did this, and the daemon's `readelf -d` output is unchanged either way. `pthread` from `breakpad-client.pc` is likewise no longer picked up implicitly, but sentry links `Threads::Threads` independently via `SENTRY_LINK_PTHREAD`. Re-verified on Linux for system libunwind (static and shared, `SENTRY_BACKEND=native`) and system breakpad, in each of three states -- pkg-config installed, pkg-config physically removed from the machine, and pkg-config present with the `.pc` module missing -- including install and a downstream `find_package(sentry)` build and run, plus the not-found diagnostic and `make test-unit`. --- cmake/sentry-find-system-library.cmake | 126 ++++++++++++------------- 1 file changed, 59 insertions(+), 67 deletions(-) diff --git a/cmake/sentry-find-system-library.cmake b/cmake/sentry-find-system-library.cmake index f06542b15b..e0536b5cd9 100644 --- a/cmake/sentry-find-system-library.cmake +++ b/cmake/sentry-find-system-library.cmake @@ -1,110 +1,102 @@ -# Locates a system library, preferring `pkg-config` metadata when both the tool and the requested module are -# available, and falling back to plain `find_library()`/`find_path()` when they are not. +# Locates a system library the way CMake's own find modules do: `pkg-config` supplies search hints +# when it happens to be installed, and `find_library()`/`find_path()` do the actual lookup either way. +# See `FindLibinput`, `FindFontconfig` and the other bundled modules that follow the same shape. # -# `pkg-config` is only ever consulted for the optional `SENTRY_LIBUNWIND_SYSTEM` and `SENTRY_BREAKPAD_SYSTEM` code -# paths, and only on Linux. Requesting it with `find_package(PkgConfig REQUIRED)` nevertheless turned the tool into a -# hard build requirement for anyone packaging sentry-native, which is why package managers end up declaring it on -# every platform, including those where it is never invoked. +# The only places sentry-native consults `pkg-config` are the optional `SENTRY_LIBUNWIND_SYSTEM` and +# `SENTRY_BREAKPAD_SYSTEM` code paths, and only on Linux. Requesting it with +# `find_package(PkgConfig REQUIRED)` nevertheless turned the tool into a hard build requirement for +# anyone packaging sentry-native, which is why package managers end up declaring it on every platform, +# including those where it is never invoked. # -# On success the imported target `TGT` is defined regardless of which of the two lookups provided it, so neither the -# call sites nor the installed `sentry-config.cmake` have to branch on the outcome. +# Defines the imported target `TARGET` on success, and fails through +# `find_package_handle_standard_args()` with the usual "could not find" diagnostic otherwise. # -# sentry_find_system_library( +# sentry_find_system_library( +# TARGET # PKG_CONFIG_MODULE # LIBRARY_NAMES ... # [HEADER_NAMES
...] # [HEADER_PATH_SUFFIXES ...]) -function(sentry_find_system_library TGT) - cmake_parse_arguments(SFSL "" "PKG_CONFIG_MODULE" "LIBRARY_NAMES;HEADER_NAMES;HEADER_PATH_SUFFIXES" ${ARGN}) +function(sentry_find_system_library NAME) + cmake_parse_arguments(SFSL "" "TARGET;PKG_CONFIG_MODULE" + "LIBRARY_NAMES;HEADER_NAMES;HEADER_PATH_SUFFIXES" ${ARGN}) - if(TARGET "${TGT}") + if(TARGET "${SFSL_TARGET}") return() endif() - string(MAKE_C_IDENTIFIER "${TGT}" prefix) - string(TOUPPER "${prefix}" prefix) - - # `pkg-config` resolves transitive `Requires:` and `Libs.private:` entries for us, so prefer it when available. + # Hints only. A missing tool or a missing `.pc` file just leaves the hints empty. The guard is + # needed because `pkg_check_modules()` is defined by `FindPkgConfig` itself, so it does not exist + # when that module was never loaded. find_package(PkgConfig QUIET) if(PKG_CONFIG_FOUND) - pkg_check_modules("${prefix}" QUIET IMPORTED_TARGET "${SFSL_PKG_CONFIG_MODULE}") - endif() - - if(TARGET "PkgConfig::${prefix}") - add_library("${TGT}" INTERFACE IMPORTED) - set_target_properties("${TGT}" PROPERTIES INTERFACE_LINK_LIBRARIES "PkgConfig::${prefix}") - return() + pkg_check_modules(PC_${NAME} QUIET "${SFSL_PKG_CONFIG_MODULE}") endif() - # No usable `pkg-config` module, so resolve the library and its headers ourselves. set(libraries "") - set(missing "") - foreach(name IN LISTS SFSL_LIBRARY_NAMES) - string(MAKE_C_IDENTIFIER "SENTRY_${prefix}_${name}_LIBRARY" cache_var) - find_library("${cache_var}" NAMES "${name}") + set(required_vars "") + foreach(library_name IN LISTS SFSL_LIBRARY_NAMES) + string(MAKE_C_IDENTIFIER "${NAME}_${library_name}_LIBRARY" cache_var) + find_library("${cache_var}" NAMES "${library_name}" HINTS ${PC_${NAME}_LIBRARY_DIRS}) mark_as_advanced("${cache_var}") - if(${cache_var}) - list(APPEND libraries "${${cache_var}}") - else() - list(APPEND missing "lib${name}") - endif() + list(APPEND libraries "${${cache_var}}") + list(APPEND required_vars "${cache_var}") endforeach() - set(include_dir "") if(SFSL_HEADER_NAMES) - string(MAKE_C_IDENTIFIER "SENTRY_${prefix}_INCLUDE_DIR" cache_var) - if(SFSL_HEADER_PATH_SUFFIXES) - find_path("${cache_var}" NAMES ${SFSL_HEADER_NAMES} PATH_SUFFIXES ${SFSL_HEADER_PATH_SUFFIXES}) - else() - find_path("${cache_var}" NAMES ${SFSL_HEADER_NAMES}) - endif() - mark_as_advanced("${cache_var}") - if(${cache_var}) - set(include_dir "${${cache_var}}") - else() - list(GET SFSL_HEADER_NAMES 0 header) - list(APPEND missing "${header}") - endif() + find_path(${NAME}_INCLUDE_DIR + NAMES ${SFSL_HEADER_NAMES} + HINTS ${PC_${NAME}_INCLUDE_DIRS} + PATH_SUFFIXES ${SFSL_HEADER_PATH_SUFFIXES}) + mark_as_advanced(${NAME}_INCLUDE_DIR) + list(APPEND required_vars ${NAME}_INCLUDE_DIR) endif() - if(missing) - string(REPLACE ";" ", " missing "${missing}") - message(FATAL_ERROR - "Could not find the system dependency `${SFSL_PKG_CONFIG_MODULE}` needed for `${TGT}`.\n" - "Missing: ${missing}.\n" - "Install the matching development package, point CMake at it via `CMAKE_PREFIX_PATH`, or install " - "`pkg-config`/`pkgconf` so that `${SFSL_PKG_CONFIG_MODULE}.pc` can be used instead.") - endif() + # These lookups only run once the user has opted into a system library, so a miss is fatal. + # `find_package_handle_standard_args()` reads this to pick the failure mode and the message. + set(${NAME}_FIND_REQUIRED TRUE) + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(${NAME} REQUIRED_VARS ${required_vars}) - add_library("${TGT}" INTERFACE IMPORTED) - set_target_properties("${TGT}" PROPERTIES INTERFACE_LINK_LIBRARIES "${libraries}") - if(include_dir) - set_target_properties("${TGT}" PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${include_dir}") + add_library("${SFSL_TARGET}" INTERFACE IMPORTED) + set_target_properties("${SFSL_TARGET}" PROPERTIES INTERFACE_LINK_LIBRARIES "${libraries}") + if(${NAME}_INCLUDE_DIR) + set_target_properties("${SFSL_TARGET}" PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${${NAME}_INCLUDE_DIR}") + endif() + if(PC_${NAME}_CFLAGS_OTHER) + set_target_properties("${SFSL_TARGET}" PROPERTIES + INTERFACE_COMPILE_OPTIONS "${PC_${NAME}_CFLAGS_OTHER}") endif() endfunction() -# The lookups below are shared between the build itself and the installed `sentry-config.cmake`, which has to recreate -# the same imported targets for consumers of a static sentry-native. Keeping them here means the two cannot drift. +# The lookups below are shared between the build itself and the installed `sentry-config.cmake`, which +# has to recreate the same imported targets for consumers of a static sentry-native. Keeping them here +# means the two cannot drift. function(sentry_find_libunwind) - sentry_find_system_library(sentry::libunwind + sentry_find_system_library(SentryLibunwind + TARGET sentry::libunwind PKG_CONFIG_MODULE libunwind LIBRARY_NAMES unwind HEADER_NAMES libunwind.h) endfunction() function(sentry_find_libunwind_ptrace) - # `libunwind-ptrace.pc` pulls in `libunwind-generic`, so the fallback has to link it explicitly. - sentry_find_system_library(sentry::libunwind-ptrace + # `libunwind-ptrace.pc` declares `Requires: libunwind-generic libunwind`; the generic half has to + # be named here, and callers link `sentry::libunwind` alongside for the other. + sentry_find_system_library(SentryLibunwindPtrace + TARGET sentry::libunwind-ptrace PKG_CONFIG_MODULE libunwind-ptrace LIBRARY_NAMES unwind-ptrace unwind-generic HEADER_NAMES libunwind-ptrace.h) endfunction() function(sentry_find_breakpad_client) - # `breakpad-client.pc` exposes the headers below `${includedir}/breakpad`, matching the `client//...` - # includes in `src/backends/sentry_backend_breakpad.cpp`. - sentry_find_system_library(sentry::breakpad-client + # `breakpad-client.pc` exposes the headers below `${includedir}/breakpad`, matching the + # `client//...` includes in `src/backends/sentry_backend_breakpad.cpp`. + sentry_find_system_library(SentryBreakpadClient + TARGET sentry::breakpad-client PKG_CONFIG_MODULE breakpad-client LIBRARY_NAMES breakpad_client HEADER_NAMES google_breakpad/common/breakpad_types.h