[Pcre-svn] [1641] code/trunk: Patch to allow MSVC static bui…

Inizio della pagina
Delete this message
Autore: Subversion repository
Data:  
To: pcre-svn
Oggetto: [Pcre-svn] [1641] code/trunk: Patch to allow MSVC static build via CMake.
Revision: 1641
          http://vcs.pcre.org/viewvc?view=rev&revision=1641
Author:   ph10
Date:     2016-03-01 12:13:27 +0000 (Tue, 01 Mar 2016)
Log Message:
-----------
Patch to allow MSVC static build via CMake.


Modified Paths:
--------------
    code/trunk/CMakeLists.txt
    code/trunk/ChangeLog


Modified: code/trunk/CMakeLists.txt
===================================================================
--- code/trunk/CMakeLists.txt    2016-02-29 09:21:21 UTC (rev 1640)
+++ code/trunk/CMakeLists.txt    2016-03-01 12:13:27 UTC (rev 1641)
@@ -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 @@
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


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2016-02-29 09:21:21 UTC (rev 1640)
+++ code/trunk/ChangeLog    2016-03-01 12:13:27 UTC (rev 1641)
@@ -71,6 +71,9 @@


 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