Merge pull request #5714 from daverodgman/k-stachowiak_static-runtime-option-msvc
Enable static linking of the common runtime in MSVC
This commit is contained in:
commit
a636d1f192
2 changed files with 15 additions and 0 deletions
3
ChangeLog.d/static_link_common_runtime_msvc.txt
Normal file
3
ChangeLog.d/static_link_common_runtime_msvc.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
Changes
|
||||
* Add a CMake option that enables static linking of the runtime library
|
||||
in Microsoft Visual C++ compiler. Contributed by Microplankton.
|
|
@ -187,6 +187,18 @@ if(CMAKE_COMPILER_IS_CLANG)
|
|||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-declarations -Wmissing-prototypes -Wdocumentation -Wno-documentation-deprecated-sync -Wunreachable-code")
|
||||
endif(CMAKE_COMPILER_IS_CLANG)
|
||||
|
||||
if(CMAKE_COMPILER_IS_MSVC)
|
||||
option(MSVC_STATIC_RUNTIME "Build the libraries with /MT compiler flag" OFF)
|
||||
if(MSVC_STATIC_RUNTIME)
|
||||
foreach(flag_var
|
||||
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_C_FLAGS_CHECK)
|
||||
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
||||
endforeach(flag_var)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(libs ${libs} ws2_32)
|
||||
endif(WIN32)
|
||||
|
|
Loading…
Reference in a new issue