summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2016-03-01 12:13:27 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2016-03-01 12:13:27 +0000
commitb3f4b35cf395495108873028c496e0e7400b246c (patch)
treeb3e69849a28e351eabff9b09d18ac9fff333225f
parent1300abbadd9b5f33c8b94f3b38715e5e80232c7f (diff)
downloadpcre-b3f4b35cf395495108873028c496e0e7400b246c.tar.gz
Patch to allow MSVC static build via CMake.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1641 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r--CMakeLists.txt19
-rw-r--r--ChangeLog3
2 files changed, 21 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 846241d..ce6b167 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -65,12 +65,15 @@
# so it has been removed.
# 2013-10-08 PH got rid of the "source" command, which is a bash-ism (use ".")
# 2013-11-05 PH added support for PARENS_NEST_LIMIT
+# 2016-03-01 PH applied Chris Wilson's patch for MSVC static build
PROJECT(PCRE C CXX)
-# Increased minimum to 2.8.0 to support newer add_test features
+# Increased minimum to 2.8.0 to support newer add_test features. Set policy
+# CMP0026 to avoid warnings for the use of LOCATION in GET_TARGET_PROPERTY.
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0)
+CMAKE_POLICY(SET CMP0026 OLD)
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) # for FindReadline.cmake
@@ -567,6 +570,20 @@ SET(PCREPOSIX_SOURCES
ENDIF (EXISTS ${PROJECT_SOURCE_DIR}/pcreposix.rc)
ENDIF(MSVC AND NOT PCRE_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 PCRE_STATIC)
+ MESSAGE(STATUS "** MSVC and PCRE_STATIC: 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
+ CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
+ CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+ string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
+ endforeach()
+ENDIF(MSVC AND PCRE_STATIC)
+
SET(PCRECPP_HEADERS
pcrecpp.h
pcre_scanner.h
diff --git a/ChangeLog b/ChangeLog
index f978020..454551f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -71,6 +71,9 @@ Version 8.39 xx-xxxxxx-201x
17. Fixed typo ("&&" for "&") in pcre_study(). Fortunately, this could not
actually affect anything, by sheer luck.
+
+18. Applied Chris Wilson's patch (Bugzilla #1681) to CMakeLists.txt for MSVC
+ static compilation.
Version 8.38 23-November-2015