From 79fb34a90bfc318ba73445e4db32f5693042493b Mon Sep 17 00:00:00 2001 From: OJ <oj@buffered.io> Date: Wed, 15 Apr 2020 13:12:31 +1000 Subject: 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. --- CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e198f7c..a577d29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.0) +cmake_minimum_required (VERSION 3.15) include(CheckFunctionExists) include(CheckSymbolExists) include(CheckLibraryExists) @@ -9,6 +9,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" ${CMAKE_MODULE_PATH}) include(cmake_export_symbol) include(GNUInstallDirs) +cmake_policy(SET CMP0091 NEW) project (LibreSSL C ASM) 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) 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) set( ENABLE_LIBRESSL_INSTALL ON ) endif(NOT LIBRESSL_SKIP_INSTALL) -- cgit v1.2.3-55-g6feb