MSVC static runtime option /MT is overwritten by /MD

Hello, VTK developers

When building the latest version of VTK
(Commit: 318abc9fda820b3c1619a13008182c84d09ae5b6)
MSVC static runtime option /MT was overwritten by /MD.

This issue is not observed for VTK 9.0.1 released yesterday (2020/06/25).

I used the following build options:

cmake %SOURCE_DIR% -G "Visual Studio 15 2017" ^
 -A x64 ^
 -DBUILD_SHARED_LIBS:BOOL=OFF ^
 -DCMAKE_CXX_MP_FLAG:BOOL=ON ^
 -DCMAKE_CXX_MP_NUM_PROCESSORS:STRING=32 ^
 -DVTK_BUILD_TESTING:BOOL=OFF ^
 -DVTK_BUILD_EXAMPLES:BOOL=OFF ^
 -DCMAKE_CXX_FLAGS_DEBUG:STRING="/MTd /Zi /Ob0 /Od /RTC1" ^
 -DCMAKE_CXX_FLAGS_MINSIZEREL:STRING="/MT /O1 /Ob1 /DNDEBUG" ^
 -DCMAKE_CXX_FLAGS_RELEASE:STRING="/MT /O2 /Ob2 /DNDEBUG" ^
 -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING="/MT /Zi /O2 /Ob1 /DNDEBUG" ^
 -DCMAKE_C_FLAGS_DEBUG:STRING="/MTd /Zi /Ob0 /Od /RTC1" ^
 -DCMAKE_C_FLAGS_MINSIZEREL:STRING="/MT /O1 /Ob1 /DNDEBUG" ^
 -DCMAKE_C_FLAGS_RELEASE:STRING="/MT /O2 /Ob2 /DNDEBUG" ^
 -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING="/MT /Zi /O2 /Ob1 /DNDEBUG"

The basic environments are

CMake version: 3.18.0-rc2
OS: Windows 10.0.18363
Compiler:  MSVC 19.16.27041.0 (VS 2017, 15.9 update)

I want to build VTK with static linkage to MSVC runtime.
Is there any workaround for this issue?

Thanks in advance.

With newer CMake, you should use CMAKE_MSVC_RUNTIME_LIBRARY instead of manual flags.

1 Like

Hello, Ben

It works!
Thank you so much for your help.