From ed489f99ae59b7ca39e99b08fb70eaecb791bbd4 Mon Sep 17 00:00:00 2001 From: "Philip.Hazel" Date: Mon, 22 Jun 2020 15:51:19 +0000 Subject: [PATCH] Fix Windows debug builds (Bugzilla #2600) using CMake. --- CMakeLists.txt | 14 +++++++++----- ChangeLog | 4 ++++ configure.ac | 5 +++++ libpcre2-16.pc.in | 2 +- libpcre2-32.pc.in | 2 +- libpcre2-8.pc.in | 2 +- libpcre2-posix.pc.in | 2 +- pcre2-config.in | 8 ++++---- 8 files changed, 26 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 07652e9..ac80566 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -495,6 +495,12 @@ CONFIGURE_FILE(src/pcre2.h.in ${PROJECT_BINARY_DIR}/pcre2.h @ONLY) +# Make sure to not link debug libs +# against release libs and vice versa +IF(WIN32) + SET(CMAKE_DEBUG_POSTFIX "d") +ENDIF(WIN32) + # Generate pkg-config files SET(PACKAGE_VERSION "${PCRE2_MAJOR}.${PCRE2_MINOR}") @@ -503,6 +509,9 @@ SET(prefix ${CMAKE_INSTALL_PREFIX}) SET(exec_prefix "\${prefix}") SET(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") SET(includedir "\${prefix}/include") +IF(WIN32 AND (CMAKE_BUILD_TYPE MATCHES Debug)) + SET(LIB_POSTFIX ${CMAKE_DEBUG_POSTFIX}) +ENDIF() CONFIGURE_FILE(libpcre2-posix.pc.in libpcre2-posix.pc @ONLY) SET(pkg_config_files ${pkg_config_files} "${CMAKE_CURRENT_BINARY_DIR}/libpcre2-posix.pc") @@ -642,11 +651,6 @@ IF(MSVC) ENDIF(MSVC) SET(CMAKE_INCLUDE_CURRENT_DIR 1) -# needed to make sure to not link debug libs -# against release libs and vice versa -IF(WIN32) - SET(CMAKE_DEBUG_POSTFIX "d") -ENDIF(WIN32) SET(targets) diff --git a/ChangeLog b/ChangeLog index eb24858..03522a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -40,6 +40,10 @@ platforms.) 6. Added a (uint32_t) cast to prevent a compiler warning in pcre2_compile.c. +7. Applied a patch from Wolfgang Stöggl (Bugzilla #2600) to fix postfix for +debug Windows builds using CMake. This also updated configure so that it +generates *.pc files and pcre2-config with the same content, as in the past. + Version 10.35 09-May-2020 --------------------------- diff --git a/configure.ac b/configure.ac index 288446a..74abf26 100644 --- a/configure.ac +++ b/configure.ac @@ -1021,7 +1021,12 @@ if test "$pcre2_cc_cv_intel_cet_enabled" = yes; then fi AC_LANG_POP([C]) +# LIB_POSTFIX is used by CMakeLists.txt for Windows debug builds. +# Pass empty LIB_POSTFIX to *.pc files and pcre2-config here. +AC_SUBST(LIB_POSTFIX) + # Produce these files, in addition to config.h. + AC_CONFIG_FILES( Makefile libpcre2-8.pc diff --git a/libpcre2-16.pc.in b/libpcre2-16.pc.in index 978040d..bacb466 100644 --- a/libpcre2-16.pc.in +++ b/libpcre2-16.pc.in @@ -8,6 +8,6 @@ includedir=@includedir@ Name: libpcre2-16 Description: PCRE2 - Perl compatible regular expressions C library (2nd API) with 16 bit character support Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -lpcre2-16 +Libs: -L${libdir} -lpcre2-16@LIB_POSTFIX@ Libs.private: @PTHREAD_CFLAGS@ @PTHREAD_LIBS@ Cflags: -I${includedir} @PCRE2_STATIC_CFLAG@ diff --git a/libpcre2-32.pc.in b/libpcre2-32.pc.in index d8fb187..06241f0 100644 --- a/libpcre2-32.pc.in +++ b/libpcre2-32.pc.in @@ -8,6 +8,6 @@ includedir=@includedir@ Name: libpcre2-32 Description: PCRE2 - Perl compatible regular expressions C library (2nd API) with 32 bit character support Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -lpcre2-32 +Libs: -L${libdir} -lpcre2-32@LIB_POSTFIX@ Libs.private: @PTHREAD_CFLAGS@ @PTHREAD_LIBS@ Cflags: -I${includedir} @PCRE2_STATIC_CFLAG@ diff --git a/libpcre2-8.pc.in b/libpcre2-8.pc.in index 5c872d0..246bb9e 100644 --- a/libpcre2-8.pc.in +++ b/libpcre2-8.pc.in @@ -8,6 +8,6 @@ includedir=@includedir@ Name: libpcre2-8 Description: PCRE2 - Perl compatible regular expressions C library (2nd API) with 8 bit character support Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -lpcre2-8 +Libs: -L${libdir} -lpcre2-8@LIB_POSTFIX@ Libs.private: @PTHREAD_CFLAGS@ @PTHREAD_LIBS@ Cflags: -I${includedir} @PCRE2_STATIC_CFLAG@ diff --git a/libpcre2-posix.pc.in b/libpcre2-posix.pc.in index 9641555..758c306 100644 --- a/libpcre2-posix.pc.in +++ b/libpcre2-posix.pc.in @@ -8,6 +8,6 @@ includedir=@includedir@ Name: libpcre2-posix Description: Posix compatible interface to libpcre2-8 Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -lpcre2-posix +Libs: -L${libdir} -lpcre2-posix@LIB_POSTFIX@ Cflags: -I${includedir} @PCRE2_STATIC_CFLAG@ Requires.private: libpcre2-8 diff --git a/pcre2-config.in b/pcre2-config.in index 74271c0..bacea87 100644 --- a/pcre2-config.in +++ b/pcre2-config.in @@ -86,28 +86,28 @@ while test $# -gt 0; do ;; --libs-posix) if test @enable_pcre2_8@ = yes ; then - echo $libS$libR -lpcre2-posix -lpcre2-8 + echo $libS$libR -lpcre2-posix@LIB_POSTFIX@ -lpcre2-8@LIB_POSTFIX@ else echo "${usage}" 1>&2 fi ;; --libs8) if test @enable_pcre2_8@ = yes ; then - echo $libS$libR -lpcre2-8 + echo $libS$libR -lpcre2-8@LIB_POSTFIX@ else echo "${usage}" 1>&2 fi ;; --libs16) if test @enable_pcre2_16@ = yes ; then - echo $libS$libR -lpcre2-16 + echo $libS$libR -lpcre2-16@LIB_POSTFIX@ else echo "${usage}" 1>&2 fi ;; --libs32) if test @enable_pcre2_32@ = yes ; then - echo $libS$libR -lpcre2-32 + echo $libS$libR -lpcre2-32@LIB_POSTFIX@ else echo "${usage}" 1>&2 fi