shithub: cstory

Download patch

ref: 5c339ef686f0688af3be0c52311d63345d32e4f0
parent: 12b6fad9972d32f44c5077aa1e071865c8b8575b
author: Clownacy <Clownacy@users.noreply.github.com>
date: Mon Apr 29 19:21:52 EDT 2019

...Static-link MSVC CRT properly

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,6 +16,15 @@
 
 project(CSE2 LANGUAGES C CXX)
 
+if(MSVC)
+	# 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")
+			string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
+		endif()
+	endforeach()
+endif()
+
 ##
 # CSE2
 ##
@@ -249,13 +258,6 @@
 # Make some tweaks if we're using MSVC
 if(MSVC)
 	target_compile_definitions(CSE2 PRIVATE _CRT_SECURE_NO_WARNINGS)	# Shut up those stupid warnings
-
-	# Statically-link the CRT (vcpkg static libs do this)
-	foreach(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
-		if(${flag_var} MATCHES "/MD")
-			string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
-		endif()
-	endforeach()
 endif()
 
 # Magic to convert resources to header files