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: Use configuration package for zlib install target #295

Closed
wants to merge 1 commit into from

Conversation

rcdailey
Copy link

@rcdailey rcdailey commented Aug 30, 2017

Detailed changelog:

  • Use configuration package for zlib installation
    The configuration package is the ideal way to provide downstream targets information about zlib. It puts the burden of intrinsic knowledge of zlib's installation properties on the zlib project
    itself, rather than CMake which maintains the FindZLIB.cmake package module.

Example usage:

find_package( zlib CONFIG )
if( NOT zlib_DIR )
    message( STATUS "zlib config package not found" )
endif()

add_library( foo main.cpp )
target_link_libraries( foo PUBLIC zlib::zlib ) # `zlib::zlib` is the import target provided by the config package

@rcdailey
Copy link
Author

rcdailey commented Sep 1, 2017

@madler Is your repository dead? Should I contribute elsewhere? Does anyone know?

@madler
Copy link
Owner

madler commented Sep 1, 2017

No, not dead. Just a large backlog.

@madler
Copy link
Owner

madler commented Sep 1, 2017

By the way, I won't be removing zconf.h. This is explained elsewhere.

@rcdailey
Copy link
Author

rcdailey commented Sep 1, 2017 via email

@rcdailey
Copy link
Author

rcdailey commented Sep 1, 2017

Side note, I need to make the following changes:

  • Export targets using namespace (e.g. zlib::)
  • Export both static and shared libraries together, instead of requiring 2 different binary dirs.

@madler
Copy link
Owner

madler commented Sep 2, 2017

Sorry, yes, it does take a little digging to find things here. #163 has the answer.

@rcdailey
Copy link
Author

rcdailey commented Sep 3, 2017

@madler Thanks for finding that for me. So basically you're still trying to support the older build methods, right? I was assuming you should only support building with CMake. Is there a reason you can't drop support for the other build methods? CMake works on all platforms, after all...

Thanks for your feedback!

@rcdailey
Copy link
Author

rcdailey commented Sep 7, 2017

@timofonic What about it?

.gitattributes Outdated
# Linux-centric files maintain LF line endings on Windows platforms
*.sh eol=lf
Makefile* eol=lf
configure eol=lf

Choose a reason for hiding this comment

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

I think it would be helpful to make this a separate patch.
The smaller a patch, the easier it is to accept.

And this in particular is a separate concept from this pull request's title.

That said, I think this is a good idea to enforce text files use lf line endings. It would be unfortunate for someone to submit a pull request where their editor auto-converted opened files. But * text=auto is a tad dangerous. Maybe instead list out the file types we expect? I would include all code files.

Copy link
Author

Choose a reason for hiding this comment

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

@ProgramMax How is it dangerous? I recommend reading the gitattributes documentation page for more information on what this does.

Other great reading material:

Separate patch is a good idea, I will do that later. However it is likely that I close this PR and move it to the zlib-ng repository per a previous comment. This one is far too inactive and turnaround times for PRs are very long.

Choose a reason for hiding this comment

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

I read those before commenting. :) It is dangerous because it relies on Git to determine what is and isn't a text file. Git has gotten this wrong in the past. For example, in .png files: https://stackoverflow.com/questions/29435156/what-will-text-auto-eol-lf-in-gitattributes-do

Plus, some files which are text simply shouldn't be LF-formatted. For example, a Visual Studio solution or project file.

So I think it would make more sense to opt-in on the files which should be protected.

Copy link
Author

Choose a reason for hiding this comment

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

To your point, even if git assumes wrong for a file type, I think we should explicitly specify only the types it is getting wrong. This is a little more maintainable, as I feel confident the majority of file types will be handled correctly. So in your case we'd do something like:

* text=auto
*.png binary

The idea here is that the exclusive list will be much larger than the inclusive one. For the most part I trust Git, and as I've seen this work in many projects over many years with very few edge cases coming up, I plan to continue following this pattern in the .gitattributes I am contributing. I do appreciate your feedback though, however I think those cases should be handled explicitly.

On that note, does this repo even have PNG files?

Copy link
Author

@rcdailey rcdailey Sep 8, 2017

Choose a reason for hiding this comment

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

Also in your linked SO question, they state that the issue you're talking about (using PNG as an example) was fixed in 2.10.0 of Git, per this answer. However this bug may not be relevant since my .gitattributes is doing * text=auto not * text=auto eol=lf. The latter is what the OP is doing in the SO question you linked.

The configuration package is the ideal way to provide downstream targets
information about zlib. It puts the burden of intrinsic knowledge of zlib's
installation properties on the zlib project itself, rather than CMake which
maintains the `FindZLIB.cmake` package module.
@rcdailey rcdailey force-pushed the cmake-install-config branch from 1f41c26 to 6df13ec Compare September 8, 2017 14:15
@rcdailey rcdailey closed this Sep 8, 2017
@Neustradamus Neustradamus mentioned this pull request Jan 1, 2025
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.

3 participants