tukaani-project / xz

XZ Utils
https://tukaani.org/xz/
Other
532 stars 95 forks source link

protect against double find_package #51

Closed bebuch closed 1 year ago

bebuch commented 1 year ago

Boost iostream uses find_package in quiet mode and then again uses find_package with required. This second call triggers a add_library cannot create imported target "ZLIB::ZLIB" because another target with the same name already exists.

This can simply be fixed by skipping the alias part on secondary find_package runs.

Pull request checklist

Please check if your PR fulfills the following requirements:

Pull request type

Please check the type of change your PR introduces: - [x] Bugfix - [ ] Feature - [ ] Code style update (formatting, renaming, typo fix) - [ ] Refactoring (no functional changes, no api changes) - [ ] Build related changes - [ ] Documentation content changes - [ ] Other (please describe): ## What is the current behavior? From Boost iostream compilation which finds XZ via config file: ``` CMake Error at C:/Temp/lib/win_x86_64_debug/lib/cmake/zlib/ZLIBConfig.cmake:13 (add_library): add_library cannot create imported target "ZLIB::ZLIB" because another target with the same name already exists. Call Stack (most recent call first): libs/iostreams/CMakeLists.txt:30 (find_package) libs/iostreams/CMakeLists.txt:38 (boost_iostreams_option) ``` ## What is the new behavior? `find_package` works on the first and all folloring runs. ## Does this introduce a breaking change? - [ ] Yes - [x] No
JiaT75 commented 1 year ago

Thanks the for PR! This is a great addition. It seems like the FindLibLZMA module has something similar to protect against multiple find_package() calls, so it seems like a common protection to include.

Can you wrap your commit message with newlines around 73 character width? The first sentence in your commit message is a bit long. The reason we care is because in our releases the Changelog is generated from the commit messages. In order to keep this and the commit log itself looking nice, we have a few standards we try to enforce.

bebuch commented 1 year ago

@JiaT75 Unfortunately I don't know if this can be done online on GitHub and I'm too stressed right now to make an offline change using Git.

I have given you access to my fork. Would be nice if you could do that.

JiaT75 commented 1 year ago

@bebuch I was able to make the commit message change during the Squash and Merge. The commit is in your name and I only made stylistic edits to the message (I did not change the meaning).

Thanks for your contribution!