Skip to content
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

CMake dependency fixes #1011

Closed
wants to merge 1 commit into from
Closed

CMake dependency fixes #1011

wants to merge 1 commit into from

Conversation

dg0yt
Copy link

@dg0yt dg0yt commented Jun 18, 2024

Collection of review remarks, untested.

@@ -62,6 +62,7 @@ option(SENTRY_BUILD_EXAMPLES "Build sentry-native example(s)" "${SENTRY_MAIN_PRO

option(SENTRY_LINK_PTHREAD "Link platform threads library" ON)
if(SENTRY_LINK_PTHREAD)
set(THREADS_PREFER_PTHREAD_FLAG ON)
Copy link
Author

Choose a reason for hiding this comment

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

@@ -276,15 +277,15 @@ if(CMAKE_SYSTEM_NAME STREQUAL "OS400")
endif()

if(SENTRY_TRANSPORT_CURL)
if(NOT CURL_FOUND) # Some other lib might bring libcurl already
if(NOT TARGET CURL::libcurl) # Some other lib might bring libcurl already
Copy link
Author

Choose a reason for hiding this comment

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

There is no problem with calling find_package repeatedly. However, you are really interested in CURL::libcurl already being created, e.g. by a subproject.

find_package(CURL REQUIRED COMPONENTS AsynchDNS)
endif()

target_link_libraries(sentry PRIVATE CURL::libcurl)
endif()

if(SENTRY_TRANSPORT_COMPRESSION)
if(NOT ZLIB_FOUND)
if(NOT TARGET ZLIB::ZLIB)
find_package(ZLIB REQUIRED)
Copy link
Author

Choose a reason for hiding this comment

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

There is no problem with calling find_package repeatedly. However, you are really interested in ZLIB::ZLIB already being created, e.g. by a subproject.

else()
target_link_libraries(sentry PRIVATE ${_SENTRY_PLATFORM_LIBS})
endif()
target_link_libraries(sentry PRIVATE ${_SENTRY_PLATFORM_LIBS})
Copy link
Author

Choose a reason for hiding this comment

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

You want to export link libs for static linkage. PRIVATE does that.
PUBLIC is needed if include dirs etc. need to be used, too. This normally doesn't depend on the type of linkage but on the design of the headers.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Honestly, that use of PUBLIC predates my involvement, and I don't know why it was added in detail. I guess the difference resolves to a LINK_ONLY generator expression around the interface link libraries in the exported sentry target, so switching to PRIVATE in both cases shouldn't break anything.

Comment on lines 3 to 6
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@)
Copy link
Author

Choose a reason for hiding this comment

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

Note that in the following lines, there is now a mix of variables exported explicitly in this way, and variables expanded directly via "@VAR@".

Copy link
Collaborator

Choose a reason for hiding this comment

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

I already started with a similar clean-up; I guess you just wanted to summarize the changes here rather than actually work on a PR, right?

Copy link
Author

Choose a reason for hiding this comment

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

That's fine.

endif()
if(SENTRY_LINK_PTHREAD)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_dependency(Threads REQUIRED)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason why you left this REQUIRED here?

Copy link
Author

Choose a reason for hiding this comment

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

No, just an oversight. 🤦

if("@SENTRY_TRANSPORT_CURL@")
find_dependency(CURL COMPONENTS AsynchDNS)
endif()
if("@SENTRY_TRANSPORT_COMPRESSION@" AND "@CRASHPAD_ZLIB_SYSTEM@")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Again, I guess you just wanted to quickly summarize the changes, rather than do the whole PR, but since this refers to changes in #1005: while SENTRY_TRANSPORT_COMPRESSION is one of the reasons why the "system" zlib will be used, it is independent of crashpad.

@supervacuus
Copy link
Collaborator

Collection of review remarks, untested.

Thanks a lot for the summary and suggestions, but I will probably do a separate PR where I apply similar changes more globally.

@supervacuus
Copy link
Collaborator

Closing in favor of the tested and slightly extended variant #1013.

Thanks once more!

@dg0yt dg0yt deleted the cmake-config branch July 8, 2024 20:51
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.

2 participants