ref: 3e67b54d6f2524d75480d009a3fdea451853c0fc
parent: 5002e68be7d5d4624219ca02ee3b9a8e9c2d8160
author: Clownacy <Clownacy@users.noreply.github.com>
date: Thu Apr 11 17:33:21 EDT 2019
Make MSVC static linkage optional
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -279,7 +279,7 @@
if (MSVC)
if (STATIC)
- message(WARNING "Static builds are not available for MSVC")
+ message(STATUS "MSVC static builds only embed the C runtime library: SDL2 and FreeType are still dynamically linked")
endif()
# Find dependencies
@@ -296,14 +296,16 @@
set(FREETYPE_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/msvc/freetype/win32/freetype.lib")
endif()
- # Static-link the CRT, so we don't need to lug around 10 different DLLs
- 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()
+ if(STATIC)
+ # Static-link the CRT, so we don't need to lug around 10 different DLLs
+ 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()
# Work around MSVC2003's lack of stdint.h
include(CheckIncludeFiles)