From d6bec3e2a52c6da80eb85df310fa2388be0fc65f Mon Sep 17 00:00:00 2001 From: "Philip.Hazel" Date: Fri, 24 Jun 2016 09:07:15 +0000 Subject: [PATCH] Update patch for MSVC static compilation (see Bugzilla #1681). --- CMakeLists.txt | 13 +++++++++---- ChangeLog | 6 ++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c84dad..ced3df2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,7 +71,9 @@ # 2015-07-16 PH updated for new pcre2_find_bracket source module # 2015-08-24 PH correct C_FLAGS setting (patch from Roy Ivy III) # 2015-10=16 PH added support for never-backslash-C -# 2016-03-01 PH appliced Chris Wilson's patch for MSVC static +# 2016-03-01 PH applied Chris Wilson's patch for MSVC static +# 2016-06-24 PH applied Chris Wilson's second patch, putting the first under +# a new option instead of being unconditional. PROJECT(PCRE2 C) @@ -188,6 +190,9 @@ IF (MINGW) ENDIF(MINGW) IF(MSVC) + OPTION(PCRE_STATIC_RUNTIME OFF CACHE BOOL + "ON=Compile against the static runtime (/MT)." + OFF) OPTION(INSTALL_MSVC_PDB "ON=Install .pdb files built by MSVC, if generated" OFF) @@ -467,14 +472,14 @@ ENDIF(MSVC AND NOT PCRE2_STATIC) # Fix static compilation with MSVC: https://bugs.exim.org/show_bug.cgi?id=1681 # This code was taken from the CMake wiki, not from WebM. -IF(MSVC AND PCRE2_STATIC) - MESSAGE(STATUS "** MSVC and PCRE2_STATIC: modifying compiler flags to use static runtime library") +IF(MSVC AND PCRE2_STATIC_RUNTIME) + MESSAGE(STATUS "** MSVC and PCRE2_STATIC_RUNTIME: modifying compiler flags to use static runtime library") foreach(flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO) string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") endforeach() -ENDIF(MSVC AND PCRE2_STATIC) +ENDIF(MSVC AND PCRE2_STATIC_RUNTIME) # Build setup diff --git a/ChangeLog b/ChangeLog index cd55168..cbff760 100644 --- a/ChangeLog +++ b/ChangeLog @@ -86,8 +86,10 @@ actually affect anything, by sheer luck. "const" qualifiers in pcre2test and (b) defining snprintf as _snprintf for older MSVC compilers. -19. Applied Chris Wilson's patch (Bugzilla #1681) to CMakeLists.txt for MSVC -static compilation. +19. Applied Chris Wilson's patch (Bugzilla #1681) to CMakeLists.txt for MSVC +static compilation. Subsequently applied Chris Wilson's second patch, putting +the first patch under a new option instead of being unconditional when +PCRE_STATIC is set. 20. Updated pcre2grep to set stdout as binary when run under Windows, so as not to convert \r\n at the ends of reflected lines into \r\r\n. This required