Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.

Commit 39604c7

Browse files
kellycouchgldiviney
authored andcommitted
Add support for linking MS VCRedist statically
Signed-off-by: Kelly J Couch <kelly.j.couch@intel.com> (cherry picked from commit 7dcb3f92a19b285f4cf4ef7878ee37e24728f509)
1 parent fe00d87 commit 39604c7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

CMakeLists.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,28 @@ if(LNX_BUILD)
165165
endif()
166166
endif()
167167

168+
if(MSVC)
169+
if(VCREDIST_STATIC)
170+
# Force vcredist to be linked static
171+
# Keep this after all other compiler flag setup
172+
set(CompilerFlags
173+
CMAKE_CXX_FLAGS
174+
CMAKE_CXX_FLAGS_DEBUG
175+
CMAKE_CXX_FLAGS_RELEASE
176+
CMAKE_CXX_FLAGS_RELWITHDEBINFO
177+
CMAKE_C_FLAGS
178+
CMAKE_C_FLAGS_DEBUG
179+
CMAKE_C_FLAGS_RELEASE
180+
CMAKE_C_FLAGS_RELWITHDEBINFO
181+
)
182+
foreach(CompilerFlag ${CompilerFlags})
183+
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
184+
endforeach()
185+
message("VCREDIST: STATIC")
186+
else()
187+
message("VCREDIST: SHARED")
188+
endif()
189+
endif()
168190
#----------------------------------------------------------------------------------------------------
169191
# OS driver interface library
170192
#----------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)