Skip to content

Commit

Permalink
Fix Windows debug builds (Bugzilla erlang#2600) using CMake.
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipHazel committed Jun 22, 2020
1 parent 3faff02 commit ed489f9
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 13 deletions.
14 changes: 9 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -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")

Expand Down Expand Up @@ -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)

Expand Down
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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
---------------------------
Expand Down
5 changes: 5 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libpcre2-16.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@
2 changes: 1 addition & 1 deletion libpcre2-32.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@
2 changes: 1 addition & 1 deletion libpcre2-8.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@
2 changes: 1 addition & 1 deletion libpcre2-posix.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions pcre2-config.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ed489f9

Please sign in to comment.