actions: bump zlib to v1.3, set CMAKE_MSVC_RUNTIME_LIBRARY #725
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since v1.3, zlib advertises compatibility with CMake 3.15 which introduced policy CMP0091 1. The NEW behavior is to to leave the MSVC runtime library selection flags out of the default
CMAKE_<LANG>_FLAGS_<CONFIG>
values and instead offer a first-class abstraction:MSVC_RUNTIME_LIBRARY
2.CMP0091 is documented to default to the OLD behavior and not warn when unset. The zlib CMakeLists.txt does not set this policy. However, when building libfido2 as a static library targeting Win32, linking fails because our runtime selection flags for zlib have been replaced from under our feet (the
MSVC_RUNTIME_LIBRARY
property defaults to the dynamically linked runtime).Setting
-DCMAKE_POLICY_DEFAULT_CMP0091=OLD
3 on the command line has no effect and CMake instead warns that the variable has been ignored. Manually modifying zlib's CMakeLists.txt to set the policy to OLD issues a deprecation warning but fixes our linking issues.The only remaining possibility that does not modify external files, is to explicitly set
-DCMAKE_MSVC_RUNTIME_LIBRARY=...
4 on the command line. Setting it to an empty value does not work (Visual Studio generators may supposedly also override with another default). Setting it to one of the allowed values corresponding to the selected build type resolves our linking issues.Footnotes
https://cmake.org/cmake/help/latest/policy/CMP0091.html ↩
https://cmake.org/cmake/help/latest/prop_tgt/MSVC_RUNTIME_LIBRARY.html ↩
https://cmake.org/cmake/help/latest/variable/CMAKE_POLICY_DEFAULT_CMPNNNN.html ↩
https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html ↩