summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Mejia <amejia004@gmail.com>2013-02-05 17:51:15 -0500
committerAndres Mejia <amejia004@gmail.com>2013-02-05 17:51:15 -0500
commit81e2d6dbce231b3ade611a86f0eea8c995ae3705 (patch)
treee7cde34028fc6a3d154b934bdd9ff6c4ce4c06ca
parent18532ae7128d2a9a8825a6574189b097ee2c0910 (diff)
downloadlibarchive-81e2d6dbce231b3ade611a86f0eea8c995ae3705.tar.gz
Provide better check for when libpcreposix is to be used for regex support.
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.
-rw-r--r--CMakeLists.txt28
-rw-r--r--build/cmake/FindPCREPOSIX.cmake5
2 files changed, 24 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 055992cc..af77e139 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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)$")
diff --git a/build/cmake/FindPCREPOSIX.cmake b/build/cmake/FindPCREPOSIX.cmake
index cfcf5bce..56cc17ea 100644
--- a/build/cmake/FindPCREPOSIX.cmake
+++ b/build/cmake/FindPCREPOSIX.cmake
@@ -1,8 +1,9 @@
# - Find pcreposix
-# Find the native PCREPOSIX include and library
+# Find the native PCRE and PCREPOSIX include and libraries
#
# PCRE_INCLUDE_DIR - where to find pcreposix.h, etc.
# PCREPOSIX_LIBRARIES - List of libraries when using libpcreposix.
+# PCRE_LIBRARIES - List of libraries when using libpcre.
# PCREPOSIX_FOUND - True if libpcreposix found.
# PCRE_FOUND - True if libpcre found.
@@ -28,6 +29,6 @@ IF(PCREPOSIX_FOUND)
ENDIF(PCREPOSIX_FOUND)
IF(PCRE_FOUND)
- SET(PCREPOSIX_LIBRARIES ${PCREPOSIX_LIBRARIES} ${PCRE_LIBRARY})
+ SET(PCRE_LIBRARIES ${PCRE_LIBRARY})
SET(HAVE_LIBPCRE 1)
ENDIF(PCRE_FOUND)