Make MSVC static linkage optional

This commit is contained in:
Clownacy 2019-04-11 21:33:21 +01:00
parent 5002e68be7
commit 3e67b54d6f

View file

@ -279,7 +279,7 @@ endif()
if (MSVC) if (MSVC)
if (STATIC) 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() endif()
# Find dependencies # Find dependencies
@ -296,6 +296,7 @@ if (MSVC)
set(FREETYPE_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/msvc/freetype/win32/freetype.lib") set(FREETYPE_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/msvc/freetype/win32/freetype.lib")
endif() endif()
if(STATIC)
# Static-link the CRT, so we don't need to lug around 10 different DLLs # Static-link the CRT, so we don't need to lug around 10 different DLLs
foreach(FLAG_VAR foreach(FLAG_VAR
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
@ -304,6 +305,7 @@ if (MSVC)
string(REGEX REPLACE "/MD" "/MT" ${FLAG_VAR} "${${FLAG_VAR}}") string(REGEX REPLACE "/MD" "/MT" ${FLAG_VAR} "${${FLAG_VAR}}")
endif() endif()
endforeach() endforeach()
endif()
# Work around MSVC2003's lack of stdint.h # Work around MSVC2003's lack of stdint.h
include(CheckIncludeFiles) include(CheckIncludeFiles)