madler / zlib

A massively spiffy yet delicately unobtrusive compression library.
http://zlib.net/
Other
5.58k stars 2.43k forks source link

zlib 1.3 forces /MD although I build it with /MT on Windows #849

Open tawmoto opened 1 year ago

tawmoto commented 1 year ago

Hi, I compile my zlib as usual

 cmake -DSKIP_INSTALL_FILES=ON -DCMAKE_C_FLAGS_RELEASE=/MT -DCMAKE_STATIC_LINKER_FLAGS=/SUBSYSTEM:CONSOLE,6.01 -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=RELEASE

Starting with 1.3, the integration with my project fails and seems a MT/MD problem.

When compiling 1.3, I see in the log a lot of warnings about overriding my MT with MD.

image

Tried to diff between my old working 1.2.12 and 1.3 and I could not find yet the problem, thanks.

nmoinvaz commented 1 year ago

I think you must set it using this option https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html.

tawmoto commented 1 year ago

I think you must set it using this option https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html.

Thank you, I will try. I am using my option with all 3rdparties without problem, so it clearly setting the MT correctly, but then it's overridden by MD. Also it's a mistery why it works with an older version, but with 1.3 it does not work.

tbeu commented 9 months ago

Can reproduce with CMake 3.27.8. Bisect revealed that 9889e988689cd9fcc08e45010fff9548aae3dbff is the first bad commit. I created #878 to have MSVC runtime library linkage properly configurable.

Neustradamus commented 7 months ago

@tawmoto: The @tbeu PR has been merged. Can you try? It is solved for you?

tawmoto commented 7 months ago

@tawmoto: The @tbeu PR has been merged. Can you try? It is solved for you?

unfortunately I am unable to test these weeks, I am out of office but I trust that it works. thank you for the fix