From 72b71a6ba3f843bdea27f5c1cf926a5e1b152e48 Mon Sep 17 00:00:00 2001 From: William A Rowe Jr Date: Sat, 14 Sep 2019 16:01:21 -0700 Subject: [PATCH] Add new flag ENABLE_STATIC_CRT for Windows This change adds the CMake option; ENABLE_STATIC_CRT Build libnghttp2 against the MS LIBCMT[d] This avoids linking to msvcrt.lib for binaries to compile (/MT[d]) and link against the static C Runtime libcrt.lib, and avoiding the msvcrt[d].dll dependency. Signed-off-by: William A Rowe Jr Signed-off-by: Yechiel Kalmenson --- CMakeLists.txt | 9 +++++++++ CMakeOptions.txt | 1 + 2 files changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 363c041f..86732baa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -387,6 +387,15 @@ else() ) endif() +if(ENABLE_STATIC_CRT) + foreach(lang C CXX) + foreach(suffix "" _DEBUG _MINSIZEREL _RELEASE _RELWITHDEBINFO) + set(var "CMAKE_${lang}_FLAGS${suffix}") + string(REPLACE "/MD" "/MT" ${var} "${${var}}") + endforeach() + endforeach() +endif() + if(ENABLE_DEBUG) set(DEBUGBUILD 1) endif() diff --git a/CMakeOptions.txt b/CMakeOptions.txt index c342f35d..a8332bf0 100644 --- a/CMakeOptions.txt +++ b/CMakeOptions.txt @@ -16,6 +16,7 @@ option(ENABLE_FAILMALLOC "Build failmalloc test program" ON) option(ENABLE_LIB_ONLY "Build libnghttp2 only. This is a short hand for -DENABLE_APP=0 -DENABLE_EXAMPLES=0 -DENABLE_HPACK_TOOLS=0 -DENABLE_PYTHON_BINDINGS=0") option(ENABLE_STATIC_LIB "Build libnghttp2 in static mode also") option(ENABLE_SHARED_LIB "Build libnghttp2 as a shared library" ON) +option(ENABLE_STATIC_CRT "Build libnghttp2 against the MS LIBCMT[d]") option(WITH_LIBXML2 "Use libxml2" ${WITH_LIBXML2_DEFAULT})