dmlc / dmlc-core

A common bricks library for building scalable and portable distributed machine learning.
Apache License 2.0
865 stars 519 forks source link

Use CMAKE_MSVC_RUNTIME_LIBRARY to consistently handle linking mode for MSVC runtime #687

Closed hcho3 closed 4 months ago

hcho3 commented 4 months ago

On the Windows platform, the MSVC (Microsoft Visual C++) runtime can be linked either statically or dynamically. Currently, DMLC-Core makes this choice by manually editing raw build flags:

https://github.com/dmlc/dmlc-core/blob/1ef66490be31c5c6d76eb3ec7593b010f25fc7f5/CMakeLists.txt#L200-L211

This approach is brittle and prone to errors.

A more robust method is to use the built-in flag CMAKE_MSVC_RUNTIME_LIBRARY to control the linking mode for the MSVC runtime.