Skip to content

cmake: add support for transitive ZLIB target - #3123

Closed
skirk wants to merge 3 commits into
curl:masterfrom
skirk:master
Closed

skirk wants to merge 3 commits into
curl:masterfrom
skirk:master

Conversation

@skirk

@skirk skirk commented Oct 10, 2018

Copy link
Copy Markdown
Contributor

Create transitive CMake targets for ZLIB similarly to OpenSSL. The changes follow the convention as in #3055.

@bagder bagder added the cmake label Oct 10, 2018
@skirk

skirk commented Oct 11, 2018

Copy link
Copy Markdown
Contributor Author

This still also needs accompanying changes to CMake/curl-config.cmake.in. I will add that to the PR later today.

@skirk

skirk commented Oct 12, 2018

Copy link
Copy Markdown
Contributor Author

I would like to fix the appveyor build, but I fail to understand what's the issue from the logs. Any ideas?

@bagder

bagder commented Oct 24, 2018

Copy link
Copy Markdown
Member

I think the appveyor failure is just a flaky test and not your fault. I'll retrigger the build.

@bagder
bagder requested a review from snikulov October 24, 2018 09:29
@snikulov

Copy link
Copy Markdown
Contributor

@skirk Could you please elaborate more what issue you've tried to solve?
Are any particular troubles without those changes?

@skirk

skirk commented Oct 26, 2018

Copy link
Copy Markdown
Contributor Author

Hi @snikulov,

In my use case, I want to link ZLIB statically. Currently the default implementation of FindZlib favours
a shared library and that gets hard coded into INTERFACE_LINK_LIBRARIES of generated libcurl-target.cmake which forces shared linkage for the client app too.

The transitive target gives more control to the library user to control whether to link statically or shared without relying on clumsy hacks.

Also in terms of future proofing if usage requirements of ZLIB for some reason change, they will be transitioned with the target to the client app rather than being decomposed to _LIBS and _INCLUDE_DIRS variables which might strip some of those requirements.

Comment thread CMake/curl-config.cmake.in Outdated

if("@USE_OPENSSL@")
if("@USE_OPENSSL@" OR "@CURL_ZLIB@" )
include(CMakeFindDependencyMacro)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe somebody will add another dependency shortly.
So why not include CMakeFindDependencyMacro unconditionally?

include(CMakeFindDependencyMacro)
if("@USE_OPENSSL@")
  find_dependency(OpenSSL "@OPENSSL_VERSION_MAJOR@")
endif()
if("@USE_ZLIB@")
  find_dependency(ZLIB "@ZLIB_VERSION_MAJOR@")
endif()

Comment thread CMake/curl-config.cmake.in Outdated
find_dependency(OpenSSL "@OPENSSL_VERSION_MAJOR@")
if ("@USE_OPENSSL@")
find_dependency(OpenSSL "@OPENSSL_VERSION_MAJOR@")
endif()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AFAIR, indentation used in curl project is 2 spaces. Could you please fix? Looks like it has lurked from the previous review.

@skirk

skirk commented Oct 27, 2018

Copy link
Copy Markdown
Contributor Author

The commit above implements the requested changes. I also noticed the HAVE_ZLIB variable wasn't used anywhere so I changed it to USE_ZLIB to be consistent with the USE_OPENSSL.

Also removed the unnecessary quotes from the @variables so the results after configure_file is:
if(ON)
rather than
if("ON")

@snikulov snikulov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@bagder

bagder commented Oct 29, 2018

Copy link
Copy Markdown
Member

Thanks!

@bagder bagder closed this in e97679a Oct 29, 2018
@lock lock Bot locked as resolved and limited conversation to collaborators Jan 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Development

Successfully merging this pull request may close these issues.

3 participants