From efa987d7ada94e605a5e9625dc95c78d3d376dbf Mon Sep 17 00:00:00 2001 From: Clownacy Date: Sat, 14 Mar 2020 19:36:47 +0000 Subject: [PATCH] Make the static MSVC runtime linkage optional I'd tell people to use CMAKE_MSVC_RUNTIME_LIBRARY instead, but, eh, it's too recent. --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a2fe5095..49a18199 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ option(DEBUG_SAVE "Re-enable the ability to drag-and-drop save files onto the wi 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 @@ if(COMPILER_IS_CLANG OR COMPILER_IS_GCC OR COMPILER_IS_ICC) 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")