From: Andres Mejia Date: Tue, 5 Feb 2013 22:51:15 +0000 (-0500) Subject: Provide better check for when libpcreposix is to be used for regex support. X-Git-Tag: v3.1.2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81e2d6dbce231b3ade611a86f0eea8c995ae3705;p=thirdparty%2Flibarchive.git 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. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 055992ccf..af77e1392 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 \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 cfcf5bce9..56cc17eac 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)