-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
zlib: Fix shared library on Windows MSVC #25076
base: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
When option.shared = True and compiler is MSVC, the CMakeLists.txt creates an archive called zlib.lib, but the dll is called zdll.dll. This configuration is not standard and is not supported by cmakedeps_macro.cmake module when using find_package(ZLIB). The source patch now creates zlib.lib and zlib.dll.
4e17461
to
d4cc052
Compare
This comment has been minimized.
This comment has been minimized.
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.
Renaming the DLL on Windows will break compatibility with pre-existing binaries and cause widespread breakages so I'm afraid we cannot accept this change.
When we say the name is "not standard" why do we mean by that? There is no prerequisite whatsoever for the lib and DLL files to have the same "name", as far as I know, even if that's typically the expected.
The cmakedeps_macro.cmake generated by CMakeDeps, in the function |
Therefore it's a conan issue (not being able to specify DLL name in package_info() to help CMakeDeps finding DLL, or telling conan whether some lib is shared or not. It's usually not a big issue, unless you want to rely on CMake to do something with these files). |
Hi @alessiosacco - thanks for providing more details. I have opened this issue in the Conan repository: conan-io/conan#16926 - as this is general and indeed a limitation. Are you experiencing any errors or issues other than the warning? That said, I'm afraid we can't accept this PR as it would cause breakages across the board on Windows when using shared libraries. The Conan model takes into account that if the version hasn't changed and a library is depended on as a shared library, downstream dependees don't need to be rebuilt. If ABI or the shared library names change for the same version in a new recipe revision, existing binaries of dependees that rely on zlib shared would not be rebuilt BUT they would stop working at runtime as the new package does not provide the DLL name expected. A possible workaround would be to simply duplicate the DLLs in the new revision when making this sort of change (provide the old dll name and the new dll name). However we tend to be very conservative here: we should keep the exact names used upstream, unless there's as a very strong and compelling justification. Arguably the zlib recipe should have never renamed the DLL in the existing patch in the same place - would need to check the historical of the recipe to understand why this was done. |
Hi @jcar87, |
Hi @alessiosacco - thank you for providing additional information, this is very useful. Indeed this would be a limitation as a result of conan-io/conan#16926. For getting CMake to bring/copy the DLLs you depend on, you may have better luck with the following example, where we can try for CMake to recursively find the DLLs (and it should find them, as it relies on information external to the targets) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Conan v1 pipeline ❌Failure in build 7 (
Note: To save resources, CI tries to finish as soon as an error is found. For this reason you might find that not all the references have been launched or not all the configurations for a given reference. Also, take into account that we cannot guarantee the order of execution as it depends on CI workload and workers availability. Conan v2 pipeline ❌
The v2 pipeline failed. Please, review the errors and note this is required for pull requests to be merged. In case this recipe is still not ported to Conan 2.x, please, ping Failure in build 3 (
Note: To save resources, CI tries to finish as soon as an error is found. For this reason you might find that not all the references have been launched or not all the configurations for a given reference. Also, take into account that we cannot guarantee the order of execution as it depends on CI workload and workers availability. |
Summary
Changes to recipe: zlib/1.3.1
Motivation
When option.shared = True and compiler is MSVC, the CMakeLists.txt creates an archive called zlib.lib, but the dll is called zdll.dll.
This configuration is not standard and is not supported by cmakedeps_macro.cmake module when using find_package(ZLIB).
The source patch now creates zlib.lib and zlib.dll.
Details
Tested using Windows, MSVC v142 and v143, debug and release with option.shared both false and true, Debian Linux GCC 10.