shithub: cstory

Download patch

ref: efa987d7ada94e605a5e9625dc95c78d3d376dbf
parent: de1740b61c62afbf30500200a550512e4bcb9b97
author: Clownacy <Clownacy@users.noreply.github.com>
date: Sat Mar 14 15:36:47 EDT 2020

Make the static MSVC runtime linkage optional

I'd tell people to use CMAKE_MSVC_RUNTIME_LIBRARY instead, but, eh,
it's too recent.

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,6 +8,7 @@
 
 option(LTO "Enable link-time optimisation" OFF)
 option(NATIVE_OPTIMIZATIONS "Enable processor-specific optimisations (executable might not work on other architectures) (GCC-compatible compilers only)" OFF)
+option(MSVC_LINK_STATIC_RUNTIME "Link the static MSVC runtime library" OFF)
 
 option(WARNINGS "Enable common compiler warnings (for GCC-compatible compilers and MSVC only)" OFF)
 option(WARNINGS_ALL "Enable ALL compiler warnings (for Clang and MSVC only)" OFF)
@@ -41,7 +42,7 @@
 	message(STATUS "Compiling with a GCC-compatible compiler")
 endif()
 
-if(MSVC)
+if(MSVC AND MSVC_LINK_STATIC_RUNTIME)
 	# Statically-link the CRT (vcpkg static libs do this)
 	foreach(flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
 		if(${flag_var} MATCHES "/MD")