Unverified Commit 00d6edd2 authored by Philip Hyunsu Cho's avatar Philip Hyunsu Cho Committed by GitHub
Browse files

[CMake] Use CMAKE_MSVC_RUNTIME_LIBRARY to apply /MT (#6484)

parent a8b70784
......@@ -207,6 +207,11 @@ if(__INTEGRATE_OPENCL)
endif()
endif()
if(BUILD_CPP_TEST AND MSVC)
# Use /MT flag to statically link the C runtime
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
if(USE_CUDA)
find_package(CUDAToolkit 11.0 REQUIRED)
include_directories(${CUDAToolkit_INCLUDE_DIRS})
......@@ -685,18 +690,6 @@ if(BUILD_CPP_TEST)
file(GLOB CPP_TEST_SOURCES tests/cpp_tests/*.cpp)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive-")
set(
CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
endif()
add_executable(testlightgbm ${CPP_TEST_SOURCES})
target_link_libraries(testlightgbm PRIVATE lightgbm_objs lightgbm_capi_objs GTest::GTest)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment