Skip to content

Commit

Permalink
Add CMake option to use /MD runtime (#7277)
Browse files Browse the repository at this point in the history
  • Loading branch information
hcho3 authored Sep 30, 2021
1 parent b2d8431 commit 2a0368b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ set_default_configuration_release()
option(BUILD_C_DOC "Build documentation for C APIs using Doxygen." OFF)
option(USE_OPENMP "Build with OpenMP support." ON)
option(BUILD_STATIC_LIB "Build static library" OFF)
option(FORCE_SHARED_CRT "Build with dynamic CRT on Windows (/MD)" OFF)
option(RABIT_BUILD_MPI "Build MPI" OFF)
## Bindings
option(JVM_BINDINGS "Build JVM bindings" OFF)
Expand Down Expand Up @@ -160,6 +161,9 @@ endif (USE_NCCL)

# dmlc-core
msvc_use_static_runtime()
if (FORCE_SHARED_CRT)
set(DMLC_FORCE_SHARED_CRT ON)
endif ()
add_subdirectory(${xgboost_SOURCE_DIR}/dmlc-core)

if (MSVC)
Expand Down
2 changes: 1 addition & 1 deletion cmake/Utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ endfunction(auto_source_group)

# Force static runtime for MSVC
function(msvc_use_static_runtime)
if(MSVC)
if(MSVC AND (NOT BUILD_SHARED_LIBS) AND (NOT FORCE_SHARED_CRT))
set(variables
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_MINSIZEREL
Expand Down

0 comments on commit 2a0368b

Please sign in to comment.