Skip to content

Commit 47856c6

Browse files
committed
add option STATIC_VS_CRT to set vs runtime in cmake file
1 parent 1a68515 commit 47856c6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@ option(FPIC "build with -fPIC" OFF)
3636
# build all projects (libco, gen, test, unitest)
3737
option(BUILD_ALL "Build all projects" OFF)
3838

39+
# vs runtime, use MT
40+
if(MSVC)
41+
option(STATIC_VS_CRT "use /MT or /MTd" ON)
42+
43+
if(STATIC_VS_CRT)
44+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
45+
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
46+
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
47+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
48+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
49+
endif()
50+
endif()
51+
52+
3953
include_directories(include)
4054
add_subdirectory(src)
4155

0 commit comments

Comments
 (0)