Windows_MT.cmake has no effect anymore #3984
Labels
Component - Build
CMake, Autotools
Priority - 2. Medium ⏹
It would be nice to have this in the next release
Type - Bug / Bugfix
Please report security issues to help@hdfgroup.org instead of creating an issue on GitHub
Hello,
I was building latest static hdf5 1.14.3 libs on Windows targeting static MSVCRT libs via cmake. I found out about Windows_MT.cmake from readme. So I disabled build of shared libs, enabled usage of static msvcrt libs and included mentioned Windows_MT.cmake to UserMacros.cmake. To be sure I added few message prints to mentioned cmake file to be super duper sure that the code gets executed during the configure step.
Windows_MT.cmake does simple replace of /MD to /MT for the compiler and /libs:dll to /libs:static for the linker. However, the code is not working properly, since there is nothing to be replaced in vanilla state (freshly generated cmake project). Following is the printout from inside of the cmake loops:
You see that there are not /MD or /libs flags to be replaced. So I just added the else branch in order to append the flags if there is nothing to replace. That also didn't work properly. I could now see proper flags being appended (/MT and /libs:static), but in my case generated Visual Studio solution was still showing me that MultiThreaded DLL library is used as Runtime library in project properties. After building many tests failed. I think the reason is the combination of (implicit) /MD and /NODEFAULTLIB:MSVCRT options. Only after adding
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
the generated Visual Studio solution was showing me that static runtime lib is used. Then all compiled and all tests passed. Strangely enough I compiled hdf5 1.12.3 earlier that day with exactly the same tools and there just including Windows_MT.cmake was enough.
Can someone please check what changed in hdf5 cmake tooling so this feature got broken? Also can you please consider adding option
BUILD_STATIC_CRT_LIBS
to be a regular hdf cmake option and include Windows_MT.cmake by default? I see no reason why this option should be removed by default 🤔I tested the same behaviour on two computers (home and at work):
The text was updated successfully, but these errors were encountered: