summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2018-10-08 22:48:58 +0100
committerVladislav Vaintroub <wlad@mariadb.com>2018-10-09 08:42:48 +0100
commitf4cdf90d73aeffae37b400fa060bece5917cf4c2 (patch)
treed2b7d5f45dbc8d5a447ef1fab4122b69d7512034 /cmake
parentc57bbb259684069e87cbae12c7c04a4284af15c3 (diff)
downloadmariadb-git-f4cdf90d73aeffae37b400fa060bece5917cf4c2.tar.gz
MDEV-17279 Windows : link C runtime dynamically
Changed the build to use /MD flag so that DDL version of C runtime is used. To make sure MariaDB is always runnable on target system, include redistributable CRT libraries into installer. For MSI package, use Microsoft's merge modules. For ZIP use "applocal" approach,i.e place redistributable dlls into the bin directory of the package(via InstallRequiredSystemLibraries cmake module) The space overhead of libraries in negligible, ~ 3MB unpacked. There are 2 cases, where we still link C runtime statically - Upgrade wizard, it uses MFC, and we link statically to avoid redistribute also whole MFC (for this single application, does not make much sense). - MSI installer's custom action dll wixca.dll.Here, we need static link so that MSI won't fail on a target system that does not have VC++2015 runtime already installed.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/os/Windows.cmake19
1 files changed, 16 insertions, 3 deletions
diff --git a/cmake/os/Windows.cmake b/cmake/os/Windows.cmake
index 0caa67b20ab..1aa959fc002 100644
--- a/cmake/os/Windows.cmake
+++ b/cmake/os/Windows.cmake
@@ -96,7 +96,8 @@ IF(MSVC)
# Disable mingw based pkg-config found in Strawberry perl
SET(PKG_CONFIG_EXECUTABLE 0 CACHE INTERNAL "")
- SET(MSVC_CRT_TYPE /MT CACHE STRING
+
+ SET(MSVC_CRT_TYPE /MD CACHE STRING
"Runtime library - specify runtime library for linking (/MT,/MTd,/MD,/MDd)"
)
SET(VALID_CRT_TYPES /MTd /MDd /MD /MT)
@@ -106,9 +107,7 @@ IF(MSVC)
IF(MSVC_CRT_TYPE MATCHES "/MD")
# Dynamic runtime (DLLs), need to install CRT libraries.
- SET(CMAKE_INSTALL_MFC_LIBRARIES TRUE)# upgrade wizard
SET(CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT VCCRT)
- SET(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS TRUE)
SET(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
IF(MSVC_CRT_TYPE STREQUAL "/MDd")
SET (CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY TRUE)
@@ -278,3 +277,17 @@ ENDIF()
SET(FN_NO_CASE_SENSE 1)
SET(USE_SYMDIR 1)
+
+# Force static C runtime for targets in current directory
+# (useful to get rid of MFC dll's dependency, or in installer)
+MACRO(FORCE_STATIC_CRT)
+ FOREACH(flag
+ CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO
+ CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG_INIT
+ CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO
+ CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG_INIT
+ CMAKE_C_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_MINSIZEREL
+ )
+ STRING(REGEX REPLACE "/MD[d]?" "/MT" "${flag}" "${${flag}}" )
+ ENDFOREACH()
+ENDMACRO()