Add support for use of static MSVC runtimes

In certain contexts LibreSSL needs to be built with `/MT` instead of `/MD` for inclusion in other projects. These changes allow for the command-line option `USE_STATIC_MSVC_RUNTIMES` to be set to `ON` if the use wishes to generate projects that will build with static runtimes.

This feature requires CMAKE version 3.15+, hence the minimum required version has changed as well.
This commit is contained in:
OJ 2020-04-15 13:12:31 +10:00
parent ceeb3bb4f4
commit 79fb34a90b
No known key found for this signature in database
GPG Key ID: D5DC61FB93260597

View File

@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.0) cmake_minimum_required (VERSION 3.15)
include(CheckFunctionExists) include(CheckFunctionExists)
include(CheckSymbolExists) include(CheckSymbolExists)
include(CheckLibraryExists) include(CheckLibraryExists)
@ -9,6 +9,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" ${CMAKE_MODULE_PATH})
include(cmake_export_symbol) include(cmake_export_symbol)
include(GNUInstallDirs) include(GNUInstallDirs)
cmake_policy(SET CMP0091 NEW)
project (LibreSSL C ASM) project (LibreSSL C ASM)
enable_testing() enable_testing()
@ -36,6 +37,11 @@ option(ENABLE_EXTRATESTS "Enable extra tests that may be unreliable on some plat
option(ENABLE_NC "Enable installing TLS-enabled nc(1)" OFF) option(ENABLE_NC "Enable installing TLS-enabled nc(1)" OFF)
set(OPENSSLDIR ${OPENSSLDIR} CACHE PATH "Set the default openssl directory" FORCE) set(OPENSSLDIR ${OPENSSLDIR} CACHE PATH "Set the default openssl directory" FORCE)
option(USE_STATIC_MSVC_RUNTIMES "Use /MT instead of /MD in MSVC" OFF)
if( USE_STATIC_MSVC_RUNTIMES )
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
if(NOT LIBRESSL_SKIP_INSTALL) if(NOT LIBRESSL_SKIP_INSTALL)
set( ENABLE_LIBRESSL_INSTALL ON ) set( ENABLE_LIBRESSL_INSTALL ON )
endif(NOT LIBRESSL_SKIP_INSTALL) endif(NOT LIBRESSL_SKIP_INSTALL)