summaryrefslogtreecommitdiff
path: root/cmake/os
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2017-03-30 13:11:34 +0000
committerVladislav Vaintroub <wlad@mariadb.com>2017-04-02 17:29:04 +0000
commit0cca5bdf0b6d9b1562e7a92ae51d983d2a63a1f0 (patch)
treeff5dc1a0723ec9e9d986ff5b96153321729a9632 /cmake/os
parent099ba3465e5f93351a5d265e0ef59ab0f3dcb260 (diff)
downloadmariadb-git-0cca5bdf0b6d9b1562e7a92ae51d983d2a63a1f0.tar.gz
Allow to specify C runtime library used for compilation.
Default to static release (previously static debug was used in debug builds, but not is appears to be too slow)
Diffstat (limited to 'cmake/os')
-rw-r--r--cmake/os/Windows.cmake29
1 files changed, 21 insertions, 8 deletions
diff --git a/cmake/os/Windows.cmake b/cmake/os/Windows.cmake
index 67108132d8a..38f440d251d 100644
--- a/cmake/os/Windows.cmake
+++ b/cmake/os/Windows.cmake
@@ -63,6 +63,26 @@ IF(MINGW AND CMAKE_SIZEOF_VOID_P EQUAL 4)
ENDIF()
IF(MSVC)
+ SET(MSVC_CRT_TYPE /MT CACHE STRING
+ "Runtime library - specify runtime library for linking (/MT,/MTd,/MD,/MDd)"
+ )
+ SET(VALID_CRT_TYPES /MTd /MDd /MD /MT)
+ IF (NOT ";${VALID_CRT_TYPES};" MATCHES ";${MSVC_CRT_TYPE};")
+ MESSAGE(FATAL_ERROR "Invalid value ${MSVC_CRT_TYPE} for MSVC_CRT_TYPE, choose one of /MT,/MTd,/MD,/MDd ")
+ ENDIF()
+
+ 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)
+ ENDIF()
+ INCLUDE(InstallRequiredSystemLibraries)
+ ENDIF()
+
# Enable debug info also in Release build,
# and create PDB to be able to analyze crashes.
FOREACH(type EXE SHARED MODULE)
@@ -85,7 +105,7 @@ IF(MSVC)
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)
- STRING(REPLACE "/MD" "/MT" "${flag}" "${${flag}}")
+ STRING(REGEX REPLACE "/M[TD][d]?" "${MSVC_CRT_TYPE}" "${flag}" "${${flag}}" )
STRING(REPLACE "/Zi" "/Z7" "${flag}" "${${flag}}")
ENDFOREACH()
@@ -117,13 +137,6 @@ IF(MSVC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4800 /wd4805 /wd4996")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800 /wd4805 /wd4996 /wd4291 /wd4577 /we4099")
- IF(CMAKE_SIZEOF_VOID_P MATCHES 8)
- # _WIN64 is defined by the compiler itself.
- # Yet, we define it here again to work around a bug with Intellisense
- # described here: http://tinyurl.com/2cb428.
- # Syntax highlighting is important for proper debugger functionality.
- ADD_DEFINITIONS("-D_WIN64")
- ENDIF()
ENDIF()
# Always link with socket library