]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Provide better check for when libpcreposix is to be used for regex support.
authorAndres Mejia <amejia004@gmail.com>
Tue, 5 Feb 2013 22:51:15 +0000 (17:51 -0500)
committerAndres Mejia <amejia004@gmail.com>
Tue, 5 Feb 2013 22:51:15 +0000 (17:51 -0500)
On Windows, if the static libraries for PCRE are to be used and the PCRE static libs were built
using the mingw toolchain, libgcc must also be linked for resolving the symbol ___chkstk_ms.

CMakeLists.txt
build/cmake/FindPCREPOSIX.cmake

index 055992ccfb4dfd4d671eeaa9bcf8f008f38805fc..af77e139219ace566a89d5ad6d2f8d02096cc971 100644 (file)
@@ -989,13 +989,11 @@ IF(NOT FOUND_POSIX_REGEX_LIB AND POSIX_REGEX_LIB MATCHES "^(AUTO|LIBPCREPOSIX)$"
       "WITHOUT_PCRE_STATIC;PCRE_STATIC")
     IF(NOT WITHOUT_PCRE_STATIC AND PCRE_STATIC)
       ADD_DEFINITIONS(-DPCRE_STATIC)
-       ELSEIF(MSVC AND NOT WITHOUT_PCRE_STATIC AND NOT PCRE_STATIC AND LIBGCC_FOUND)
-      # When doing a Visual Studio build using pcre static libraries
-         # built using the mingw toolchain, -lgcc is needed to resolve
-         # ___chkstk_ms.
-         MESSAGE(STATUS "Visual Studio build detected, trying again with -lgcc")
-         LIST(APPEND ADDITIONAL_LIBS ${LIBGCC_LIBRARIES})
-      SET(TMP_LIBRARIES ${PCREPOSIX_LIBRARIES} ${LIBGCC_LIBRARIES})
+       ELSEIF(NOT WITHOUT_PCRE_STATIC AND NOT PCRE_STATIC AND PCRE_FOUND)
+         # Determine if pcre static libraries are to be used.
+      LIST(APPEND ADDITIONAL_LIBS ${PCRE_LIBRARIES})
+      SET(TMP_LIBRARIES ${PCREPOSIX_LIBRARIES} ${PCRE_LIBRARIES})
+      MESSAGE(STATUS "trying again with -lpcre included")
       TRY_MACRO_FOR_LIBRARY(
         "${PCRE_INCLUDE_DIR}" "${TMP_LIBRARIES}"
         COMPILES
@@ -1003,11 +1001,27 @@ IF(NOT FOUND_POSIX_REGEX_LIB AND POSIX_REGEX_LIB MATCHES "^(AUTO|LIBPCREPOSIX)$"
         "WITHOUT_PCRE_STATIC;PCRE_STATIC")
       IF(NOT WITHOUT_PCRE_STATIC AND PCRE_STATIC)
         ADD_DEFINITIONS(-DPCRE_STATIC)
+      ELSEIF(NOT WITHOUT_PCRE_STATIC AND NOT PCRE_STATIC AND MSVC AND LIBGCC_FOUND)
+        # When doing a Visual Studio build using pcre static libraries
+        # built using the mingw toolchain, -lgcc is needed to resolve
+        # ___chkstk_ms.
+        MESSAGE(STATUS "Visual Studio build detected, trying again with -lgcc included")
+        LIST(APPEND ADDITIONAL_LIBS ${LIBGCC_LIBRARIES})
+        SET(TMP_LIBRARIES ${PCREPOSIX_LIBRARIES} ${PCRE_LIBRARIES} ${LIBGCC_LIBRARIES})
+          TRY_MACRO_FOR_LIBRARY(
+            "${PCRE_INCLUDE_DIR}" "${TMP_LIBRARIES}"
+            COMPILES
+            "#include <pcreposix.h>\nint main() {regex_t r;return regcomp(&r, \"\", 0);}"
+            "WITHOUT_PCRE_STATIC;PCRE_STATIC")
+          IF(NOT WITHOUT_PCRE_STATIC AND PCRE_STATIC)
+            ADD_DEFINITIONS(-DPCRE_STATIC)
+          ENDIF(NOT WITHOUT_PCRE_STATIC AND PCRE_STATIC)
       ENDIF(NOT WITHOUT_PCRE_STATIC AND PCRE_STATIC)
     ENDIF(NOT WITHOUT_PCRE_STATIC AND PCRE_STATIC)
   ENDIF(PCREPOSIX_FOUND)
   MARK_AS_ADVANCED(CLEAR PCRE_INCLUDE_DIR)
   MARK_AS_ADVANCED(CLEAR PCREPOSIX_LIBRARIES)
+  MARK_AS_ADVANCED(CLEAR PCRE_LIBRARIES)
   MARK_AS_ADVANCED(CLEAR LIBGCC_LIBRARIES)
 ENDIF(NOT FOUND_POSIX_REGEX_LIB AND POSIX_REGEX_LIB MATCHES "^(AUTO|LIBPCREPOSIX)$")
 
index cfcf5bce92d4c9a65bc40fb64079c8570673d60f..56cc17eacb47c691f98342a9a1fab6336d752fb7 100644 (file)
@@ -1,8 +1,9 @@
 # - Find pcreposix\r
-# Find the native PCREPOSIX include and library\r
+# Find the native PCRE and PCREPOSIX include and libraries\r
 #\r
 #  PCRE_INCLUDE_DIR    - where to find pcreposix.h, etc.\r
 #  PCREPOSIX_LIBRARIES - List of libraries when using libpcreposix.\r
+#  PCRE_LIBRARIES      - List of libraries when using libpcre.\r
 #  PCREPOSIX_FOUND     - True if libpcreposix found.\r
 #  PCRE_FOUND          - True if libpcre found.\r
 \r
@@ -28,6 +29,6 @@ IF(PCREPOSIX_FOUND)
 ENDIF(PCREPOSIX_FOUND)\r
 \r
 IF(PCRE_FOUND)\r
-  SET(PCREPOSIX_LIBRARIES ${PCREPOSIX_LIBRARIES} ${PCRE_LIBRARY})\r
+  SET(PCRE_LIBRARIES ${PCRE_LIBRARY})\r
   SET(HAVE_LIBPCRE 1)\r
 ENDIF(PCRE_FOUND)\r