-
-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix 'crashpad' Remove NOT condition for SENTRY_BUILD_SHARED_LIBS as it blocks adding crashpad handler target.cmake #1007
Conversation
…e when built with shared libs ON
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1007 +/- ##
==========================================
- Coverage 86.53% 83.86% -2.67%
==========================================
Files 40 53 +13
Lines 3736 5443 +1707
Branches 0 1207 +1207
==========================================
+ Hits 3233 4565 +1332
- Misses 503 764 +261
- Partials 0 114 +114 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why sentry_crashpad-targets.cmake used to be included only for static library?
This is a bug.
Could it be included for both static and dynamic?
Yes.
improvement: find_dependency for ZLIB instead of find_package - as we are calling from *.cmake file
https://cmake.org/cmake/help/latest/module/CMakeFindDependencyMacro.html
Yes, that makes sense.
Thanks a lot for your contribution ❤️
In sentry-config.cmake.in there should be probably also following include that defines FindDependency. I am not sure if project includes this macro somewhere. #sentry-config.cmake.in ... |
We will have to add it to the crashpad subproject too. I will finalize it there. |
|
Thanks, @dg0yt, TIL! The docs only mention that |
It takes a few more changes to properly support config search mode: |
Thanks a lot! To be clear: all includes, or only the dependent includes? This would be the "all" variant: @PACKAGE_INIT@
set(SENTRY_BACKEND @SENTRY_BACKEND@)
set(SENTRY_TRANSPORT @SENTRY_TRANSPORT@)
set(SENTRY_BUILD_SHARED_LIBS @SENTRY_BUILD_SHARED_LIBS@)
set(SENTRY_LINK_PTHREAD @SENTRY_LINK_PTHREAD@)
if(SENTRY_BACKEND STREQUAL "crashpad" AND NOT MSVC AND NOT SENTRY_BUILD_SHARED_LIBS)
find_dependency(ZLIB)
endif()
if(SENTRY_BACKEND STREQUAL "breakpad" AND NOT SENTRY_BUILD_SHARED_LIBS)
set(SENTRY_BREAKPAD_SYSTEM @SENTRY_BREAKPAD_SYSTEM@)
if(SENTRY_BREAKPAD_SYSTEM)
find_dependency(PkgConfig)
pkg_check_modules(BREAKPAD REQUIRED IMPORTED_TARGET breakpad-client)
endif()
endif()
if(SENTRY_TRANSPORT STREQUAL "curl" AND (NOT @BUILD_SHARED_LIBS@ OR NOT SENTRY_BUILD_SHARED_LIBS))
find_dependency(CURL)
set_property(TARGET sentry::sentry APPEND
PROPERTY INTERFACE_LINK_LIBRARIES ${CURL_LIBRARIES})
endif()
if(SENTRY_LINK_PTHREAD AND NOT SENTRY_BUILD_SHARED_LIBS)
find_dependency(Threads)
endif()
if(SENTRY_BACKEND STREQUAL "crashpad")
include("${CMAKE_CURRENT_LIST_DIR}/sentry_crashpad-targets.cmake")
endif()
include("${CMAKE_CURRENT_LIST_DIR}/sentry-targets.cmake") vs. "only dependent" variant: @PACKAGE_INIT@
set(SENTRY_BACKEND @SENTRY_BACKEND@)
set(SENTRY_TRANSPORT @SENTRY_TRANSPORT@)
set(SENTRY_BUILD_SHARED_LIBS @SENTRY_BUILD_SHARED_LIBS@)
set(SENTRY_LINK_PTHREAD @SENTRY_LINK_PTHREAD@)
if(SENTRY_BACKEND STREQUAL "crashpad")
if(NOT MSVC AND NOT SENTRY_BUILD_SHARED_LIBS)
find_dependency(ZLIB)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/sentry_crashpad-targets.cmake")
endif()
if(SENTRY_BACKEND STREQUAL "breakpad" AND NOT SENTRY_BUILD_SHARED_LIBS)
set(SENTRY_BREAKPAD_SYSTEM @SENTRY_BREAKPAD_SYSTEM@)
if(SENTRY_BREAKPAD_SYSTEM)
find_dependency(PkgConfig)
pkg_check_modules(BREAKPAD REQUIRED IMPORTED_TARGET breakpad-client)
endif()
endif()
if(SENTRY_TRANSPORT STREQUAL "curl" AND (NOT @BUILD_SHARED_LIBS@ OR NOT SENTRY_BUILD_SHARED_LIBS))
find_dependency(CURL)
set_property(TARGET sentry::sentry APPEND
PROPERTY INTERFACE_LINK_LIBRARIES ${CURL_LIBRARIES})
endif()
if(SENTRY_LINK_PTHREAD AND NOT SENTRY_BUILD_SHARED_LIBS)
find_dependency(Threads)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/sentry-targets.cmake") |
General rule: all In your second example, when checking for The problem may sound a little bit hypothetical. But finding the root cause may be hard to track it down in case of subtle runtime errors caused by linking mixed providers. And it is easy to do it in a more robust way. If
or given that |
This is precisely the kind of issue I would like to prevent, so thanks for the explanation. |
Followup to the above conversation here: #1013 |
When sentry lib is built as shared library (SENTRY_BUILD_SHARED_LIBS = ON) - that is default value
then sentry_crashpad-targets.cmake is not included.
Thus
$<TARGET_FILE:sentry_crashpad::crashpad_handler>
won't work.
Open question:
https://cmake.org/cmake/help/latest/module/CMakeFindDependencyMacro.html