Skip to content

Commit

Permalink
[sentry-native] Fix cmake package import/export (microsoft#28686)
Browse files Browse the repository at this point in the history
* [sentry-native] Fix cmake package import/export

* Revise zlib dependency
  • Loading branch information
dg0yt authored Jan 13, 2023
1 parent d73cbb6 commit 472ed32
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 22 deletions.
49 changes: 43 additions & 6 deletions ports/sentry-native/fix-config-cmake.patch
Original file line number Diff line number Diff line change
@@ -1,12 +1,50 @@
diff --git a/external/crashpad/crashpad-config.cmake.in b/external/crashpad/crashpad-config.cmake.in
index 846797d..d7c4ae6 100644
--- a/external/crashpad/crashpad-config.cmake.in
+++ b/external/crashpad/crashpad-config.cmake.in
@@ -1,6 +1,9 @@
include("${CMAKE_CURRENT_LIST_DIR}/crashpad-targets.cmake")

if(@CRASHPAD_ZLIB_SYSTEM@)
+ include(CMakeFindDependencyMacro)
+ find_dependency(ZLIB)
+elseif(0)
find_package(ZLIB REQUIRED)
target_include_directories(crashpad::zlib INTERFACE ${ZLIB_INCLUDE_DIRS})
target_compile_definitions(crashpad::zlib INTERFACE ${ZLIB_COMPILE_DEFINITIONS})
diff --git a/external/crashpad/third_party/zlib/CMakeLists.txt b/external/crashpad/third_party/zlib/CMakeLists.txt
index eeb449f..59a6ff1 100644
--- a/external/crashpad/third_party/zlib/CMakeLists.txt
+++ b/external/crashpad/third_party/zlib/CMakeLists.txt
@@ -1,15 +1,10 @@
if(CRASHPAD_ZLIB_SYSTEM)
add_library(crashpad_zlib INTERFACE)
- string(REPLACE ";" "$<SEMICOLON>" GENEX_ZLIB_LIBRARIES "${ZLIB_LIBRARIES}")
- target_include_directories(crashpad_zlib INTERFACE
- $<BUILD_INTERFACE:${ZLIB_INCLUDE_DIRS}>
- )
target_compile_definitions(crashpad_zlib INTERFACE
ZLIB_CONST
CRASHPAD_ZLIB_SOURCE_SYSTEM
- $<BUILD_INTERFACE:${ZLIB_COMPILE_DEFINITIONS}>
)
- target_link_libraries(crashpad_zlib INTERFACE $<BUILD_INTERFACE:${GENEX_ZLIB_LIBRARIES}>)
+ target_link_libraries(crashpad_zlib INTERFACE ZLIB::ZLIB)
else()
add_library(crashpad_zlib STATIC
zlib/adler32.c
diff --git a/sentry-config.cmake.in b/sentry-config.cmake.in
index 89ea345..c14b31c 100644
index 89ea345..acbd5e2 100644
--- a/sentry-config.cmake.in
+++ b/sentry-config.cmake.in
@@ -3,9 +3,11 @@
@@ -3,9 +3,14 @@
set(SENTRY_BACKEND @SENTRY_BACKEND@)
set(SENTRY_TRANSPORT @SENTRY_TRANSPORT@)

+include(CMakeFindDependencyMacro)
+if("@SENTRY_LINK_PTHREAD@")
+ find_dependency(Threads)
+endif()
+
if(SENTRY_BACKEND STREQUAL "crashpad")
if(@SENTRY_CRASHPAD_SYSTEM@)
Expand All @@ -15,13 +53,12 @@ index 89ea345..c14b31c 100644
else()
include("${CMAKE_CURRENT_LIST_DIR}/sentry_crashpad-targets.cmake")
endif()
@@ -14,7 +16,7 @@ endif()
@@ -14,7 +19,5 @@ endif()
include("${CMAKE_CURRENT_LIST_DIR}/sentry-targets.cmake")

if(SENTRY_TRANSPORT STREQUAL "curl" AND NOT @BUILD_SHARED_LIBS@)
- find_package(CURL REQUIRED)
+ find_dependency(CURL)
set_property(TARGET sentry::sentry APPEND
- set_property(TARGET sentry::sentry APPEND
- PROPERTY INTERFACE_LINK_LIBRARIES ${CURL_LIBRARIES})
+ PROPERTY INTERFACE_LINK_LIBRARIES CURL::libcurl)
+ find_dependency(CURL)
endif()
3 changes: 1 addition & 2 deletions ports/sentry-native/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ vcpkg_extract_source_archive(
PATCHES
fix-warningC5105.patch
fix-config-cmake.patch
use-zlib-target.patch
)

if (NOT DEFINED SENTRY_BACKEND)
if(MSVC AND CMAKE_GENERATOR_TOOLSET MATCHES "_xp$")
set(SENTRY_BACKEND "breakpad")
elseif(APPLE OR WIN32)
set(SENTRY_BACKEND "crashpad")
set(SENTRY_BACKEND "crashpad") # needs zlib
elseif(LINUX)
set(SENTRY_BACKEND "breakpad")
else()
Expand Down
12 changes: 0 additions & 12 deletions ports/sentry-native/use-zlib-target.patch

This file was deleted.

6 changes: 5 additions & 1 deletion ports/sentry-native/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "sentry-native",
"version": "0.5.3",
"port-version": 1,
"description": "Sentry SDK for C, C++ and native applications.",
"homepage": "https://sentry.io/",
"license": "MIT",
Expand All @@ -18,6 +19,9 @@
"name": "vcpkg-cmake-config",
"host": true
},
"zlib"
{
"name": "zlib",
"platform": "ios | osx | windows"
}
]
}
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -6978,7 +6978,7 @@
},
"sentry-native": {
"baseline": "0.5.3",
"port-version": 0
"port-version": 1
},
"septag-dmon": {
"baseline": "2022-02-08",
Expand Down
5 changes: 5 additions & 0 deletions versions/s-/sentry-native.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "5ac3f218a83c74fd1479bb64ae8fd07e04a7309e",
"version": "0.5.3",
"port-version": 1
},
{
"git-tree": "15c6d0c378a9b3db466534495786b58b171957be",
"version": "0.5.3",
Expand Down

0 comments on commit 472ed32

Please sign in to comment.