Re-apply "Use standard CMake constructs to export the targets. (#260)" (#739)
Additionally, I have attempted to clean up some CMake issues to make the
package's build interface cleaner, in particular, avoiding polluting the
parent directory's include path with our config.h file (if PCRE2 is being
included as a subdirectory).
This re-adds changes from Theodore's commit:
def175f4a908b477662c26a21e716038fd53675a
and partially reverts changes from Carlo's commit:
92d56a1f7c861d5bd4d5d7d34a6353af117a30e5
---------
Co-authored-by: Theodore Tsirpanis <teo@tsirpanis.gr>
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index c0bb142..e659066 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -121,6 +121,50 @@
../maint/RunManifestTest install-dir ../maint/manifest-cmakeinstall-macos
../maint/RunSymbolTest install-dir/lib/ ../maint/
+ - name: Test CMake install interface
+ run: |
+ INSTALL_PREFIX=`pwd`/build/install-dir
+ cd maint/cmake-tests/install-interface
+
+ for useStaticLibs in ON OFF; do
+ echo "== Testing CMake install interface with PCRE2_USE_STATIC_LIBS=$useStaticLibs =="
+ rm -rf build
+ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$INSTALL_PREFIX" -DPCRE2_USE_STATIC_LIBS=$useStaticLibs -B build
+ (cd build; make)
+ ./build/test_executable
+ otool -L ./build/test_executable
+ if [ $useStaticLibs = ON ]; then
+ (otool -L ./build/test_executable | grep -q "pcre2") && (echo "Error: PCRE2 found in otool output" && exit 1)
+ else
+ # Test that the shared library is actually linked in
+ (otool -L ./build/test_executable | grep -q "@rpath/libpcre2-8.0.dylib") || (echo "Error: Shared library not linked in" && exit 1)
+ fi
+ done
+
+ - name: Test CMake build interface
+ run: |
+ BUILD_DIR=`pwd`
+ cp -rp maint/cmake-tests/build-interface ../cmake-tests-build-interface
+ cd ../cmake-tests-build-interface
+ ln -s "$BUILD_DIR" pcre2
+
+ for buildLibs in "ON;OFF" "OFF;ON"; do
+ static=`echo $buildLibs | cut -d';' -f1`
+ shared=`echo $buildLibs | cut -d';' -f2`
+ echo "== Testing CMake build interface with BUILD_STATIC_LIBS=$static and BUILD_SHARED_LIBS=$shared =="
+ rm -rf build
+ cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_STATIC_LIBS=$static -DBUILD_SHARED_LIBS=$shared -B build
+ (cd build; make)
+ ./build/test_executable
+ otool -L ./build/test_executable
+ if [ $static = ON ]; then
+ (otool -L ./build/test_executable | grep -q "pcre2") && (echo "Error: PCRE2 found in ldd output" && exit 1)
+ else
+ # Test that the shared library is actually linked in
+ (otool -L ./build/test_executable | grep -q "@rpath/libpcre2-8.0.dylib") || (echo "Error: Shared library not linked in" && exit 1)
+ fi
+ done
+
windows:
name: Windows
runs-on: windows-latest
@@ -165,6 +209,66 @@
../maint/RunManifestTest.ps1 install-dir ../maint/manifest-cmakeinstall-windows
../maint/RunSymbolTest.ps1 install-dir/bin ../maint/
+ - name: Test CMake install interface
+ run: |
+ $INSTALL_PREFIX = (pwd).Path + "\build\install-dir"
+ cd maint/cmake-tests/install-interface
+
+ $vswhere = "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe"
+ $dumpbin = & $vswhere -latest -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -find VC\Tools\MSVC\*\bin\Hostx64\x64\dumpbin.exe | Select-Object -First 1
+
+ foreach ($useStaticLibs in @("ON", "OFF")) {
+ echo "== Testing CMake install interface with PCRE2_USE_STATIC_LIBS=$useStaticLibs =="
+ if (Test-Path build) { rm -Recurse -Force build }
+ cmake "-DCMAKE_PREFIX_PATH=$INSTALL_PREFIX" "-DPCRE2_USE_STATIC_LIBS=$useStaticLibs" -B build -A ${{ matrix.arch }}
+ cmake --build build --config Release
+ ./build/Release/test_executable.exe
+ & $dumpbin /dependents ./build/Release/test_executable.exe
+ if ($useStaticLibs -eq "ON") {
+ if ((& $dumpbin /dependents ./build/Release/test_executable.exe | Out-String).Contains("pcre2")) {
+ Write-Error "Error: PCRE2 found in dumpbin output"
+ exit 1
+ }
+ } else {
+ # Test that the shared library is actually linked in
+ if (-not ((& $dumpbin /dependents ./build/Release/test_executable.exe | Out-String).Contains("pcre2-8.dll"))) {
+ Write-Error "Error: Shared library not linked in"
+ exit 1
+ }
+ }
+ }
+
+ - name: Test CMake build interface
+ run: |
+ $BUILD_DIR = (pwd).Path
+ cp -Recurse -Path maint/cmake-tests/build-interface ../cmake-tests-build-interface
+ cd ../cmake-tests-build-interface
+ New-Item -ItemType SymbolicLink -Path "pcre2" -Target "$BUILD_DIR"
+
+ $vswhere = "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe"
+ $dumpbin = & $vswhere -latest -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -find VC\Tools\MSVC\*\bin\Hostx64\x64\dumpbin.exe | Select-Object -First 1
+
+ foreach ($buildLibs in @(@{static="ON"; shared="OFF"}, @{static="OFF"; shared="ON"})) {
+ echo "== Testing CMake build interface with BUILD_STATIC_LIBS=$($buildLibs.static) =="
+ if (Test-Path build) { rm -Recurse -Force build }
+ cmake "-DBUILD_STATIC_LIBS=$($buildLibs.static)" "-DBUILD_SHARED_LIBS=$($buildLibs.shared)" -B build -A ${{ matrix.arch }}
+ cmake --build build --config Debug
+ ./build/Debug/test_executable.exe
+ & $dumpbin /dependents ./build/Debug/test_executable.exe
+ if ($buildLibs.static -eq "ON") {
+ if ((& $dumpbin /dependents ./build/Debug/test_executable.exe | Out-String).Contains("pcre2")) {
+ Write-Error "Error: PCRE2 found in dumpbin output"
+ exit 1
+ }
+ } else {
+ # Test that the shared library is actually linked in
+ if (-not ((& $dumpbin /dependents ./build/Debug/test_executable.exe | Out-String).Contains("pcre2-8d.dll"))) {
+ Write-Error "Error: Shared library not linked in"
+ exit 1
+ }
+ }
+ }
+
freebsd:
name: FreeBSD
runs-on: ubuntu-latest
@@ -206,7 +310,7 @@
echo "== CMake =="
cd ../build-cmake
- cmake -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DPCRE2_DEBUG=ON -DCMAKE_C_FLAGS="$CFLAGS_GCC_STYLE" -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -B build
+ cmake -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DPCRE2_DEBUG=ON -DCMAKE_C_FLAGS="$CFLAGS_GCC_STYLE" -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_BUILD_TYPE=Release -B build
cd build
make -j3
ctest -j3 --output-on-failure
@@ -288,7 +392,7 @@
echo "== CMake, 64-bit =="
cd ../build-cmake-64
- CC="cc -m64" cmake -DNCURSES_LIBRARY=termcap -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DPCRE2_DEBUG=ON -DCMAKE_C_FLAGS="$CFLAGS_SOLARIS_CC" -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -B build
+ CC="cc -m64" cmake -DNCURSES_LIBRARY=termcap -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DPCRE2_DEBUG=ON -DCMAKE_C_FLAGS="$CFLAGS_SOLARIS_CC" -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_BUILD_TYPE=Release -B build
cd build
make
ctest -j3 --output-on-failure
diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml
index c2451bf..b241771 100644
--- a/.github/workflows/dev.yml
+++ b/.github/workflows/dev.yml
@@ -92,7 +92,7 @@
# Tests with: GCC, -O3, oldest supported Ubuntu (in non-extended support)
name: GCC -O3
runs-on: ubuntu-latest
- container: ubuntu:20.04
+ container: ubuntu:22.04
steps:
- name: Setup
run: |
@@ -121,11 +121,55 @@
../maint/RunManifestTest install-dir ../maint/manifest-cmakeinstall-linux
../maint/RunSymbolTest install-dir/lib/ ../maint/
+ - name: Test CMake install interface
+ run: |
+ INSTALL_PREFIX=`pwd`/build/install-dir
+ cd maint/cmake-tests/install-interface
+
+ for useStaticLibs in ON OFF; do
+ echo "== Testing CMake install interface with PCRE2_USE_STATIC_LIBS=$useStaticLibs =="
+ rm -rf build
+ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$INSTALL_PREFIX" -DPCRE2_USE_STATIC_LIBS=$useStaticLibs -B build
+ (cd build; make)
+ ./build/test_executable
+ ldd ./build/test_executable
+ if [ $useStaticLibs = ON ]; then
+ (ldd ./build/test_executable | grep -q "pcre2") && (echo "Error: PCRE2 found in ldd output" && exit 1)
+ else
+ # Test that the shared library is actually linked in
+ (ldd ./build/test_executable | grep -q "$INSTALL_PREFIX/lib/libpcre2-8.so.0") || (echo "Error: Shared library not linked in" && exit 1)
+ fi
+ done
+
+ - name: Test CMake build interface
+ run: |
+ BUILD_DIR=`pwd`
+ cp -rp maint/cmake-tests/build-interface ../cmake-tests-build-interface
+ cd ../cmake-tests-build-interface
+ ln -s "$BUILD_DIR" pcre2
+
+ for buildLibs in "ON;OFF" "OFF;ON"; do
+ static=`echo $buildLibs | cut -d';' -f1`
+ shared=`echo $buildLibs | cut -d';' -f2`
+ echo "== Testing CMake build interface with BUILD_STATIC_LIBS=$static and BUILD_SHARED_LIBS=$shared =="
+ rm -rf build
+ cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_STATIC_LIBS=$static -DBUILD_SHARED_LIBS=$shared -B build
+ (cd build; make)
+ ./build/test_executable
+ ldd ./build/test_executable
+ if [ $static = ON ]; then
+ (ldd ./build/test_executable | grep -q "pcre2") && (echo "Error: PCRE2 found in ldd output" && exit 1)
+ else
+ # Test that the shared library is actually linked in
+ (ldd ./build/test_executable | grep -q "`pwd`/build/pcre2/libpcre2-8.so.0") || (echo "Error: Shared library not linked in" && exit 1)
+ fi
+ done
+
dodo:
# Tests with: Autconf on oldest supported Ubuntu (in non-extended support)
name: GCC -Os, old Autotools
runs-on: ubuntu-latest
- container: ubuntu:20.04
+ container: ubuntu:22.04
steps:
- name: Setup
run: |
@@ -200,7 +244,7 @@
run: |
cd build
cmake --install . --prefix install-dir
- ../maint/RunManifestTest install-dir ../maint/manifest-cmakeinstall-linux
+ ../maint/RunManifestTest install-dir ../maint/manifest-cmakeinstall-linux minsizerel
../maint/RunSymbolTest install-dir/lib/ ../maint/
bat:
@@ -372,7 +416,7 @@
# Not used by anyone yet, really, but potentially the "next big thing".
- arch: "riscv64"
distro: "ubuntu_latest"
- runs-on: ubuntu-22.04
+ runs-on: ubuntu-latest
permissions:
contents: read
packages: write # Necessary for uraimo/run-on-arch-action to use GitHub's Docker repository as a cache
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2d2e854..194e671 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -102,6 +102,8 @@
# 2022-12-10 PH added support for pcre2posix_test
# 2023-01-15 Carlo added C99 as the minimum required
# 2023-08-06 PH added support for setting variable length lookbehind maximum
+# 2025-03-27 Theodore used standard CMake constructs to export the library's
+# targets.
################################################################################
# We have used `gersemi` for auto-formatting our CMake files.
@@ -139,13 +141,11 @@
# cmake_policy(SET CMP0026 OLD)
# cmake_policy(SET CMP0074 NEW)
-# For FindReadline.cmake. This was changed to allow setting CMAKE_MODULE_PATH
-# on the command line.
-# SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
-
+# For FindReadline.cmake. This uses list(APPEND) rather than set() to allow
+# setting CMAKE_MODULE_PATH on the command line.
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
-include_directories(${PROJECT_SOURCE_DIR}/src)
+include_directories(${PROJECT_BINARY_DIR}/src ${PROJECT_SOURCE_DIR}/src)
# external packages
find_package(BZip2)
@@ -160,6 +160,7 @@
include(CheckSymbolExists)
include(CheckIncludeFile)
include(CheckTypeSize)
+include(CMakePackageConfigHelpers)
include(GNUInstallDirs) # for CMAKE_INSTALL_LIBDIR
include(PCRE2CheckLinkerFlag)
@@ -229,10 +230,10 @@
# Detect support for linker scripts.
-file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test-map-file.sym "PCRE2_10.00 { global: main; };")
-file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test-map-file-broken.sym "PCRE2_10.00 { global: main; }; {")
-pcre2_check_linker_flag(C -Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/test-map-file.sym HAVE_VSCRIPT_GNU)
-pcre2_check_linker_flag(C -Wl,-M,${CMAKE_CURRENT_BINARY_DIR}/test-map-file.sym HAVE_VSCRIPT_SUN)
+file(WRITE ${PROJECT_BINARY_DIR}/test-map-file.sym "PCRE2_10.00 { global: main; };")
+file(WRITE ${PROJECT_BINARY_DIR}/test-map-file-broken.sym "PCRE2_10.00 { global: main; }; {")
+pcre2_check_linker_flag(C -Wl,--version-script,${PROJECT_BINARY_DIR}/test-map-file.sym HAVE_VSCRIPT_GNU)
+pcre2_check_linker_flag(C -Wl,-M,${PROJECT_BINARY_DIR}/test-map-file.sym HAVE_VSCRIPT_SUN)
if(HAVE_VSCRIPT_GNU)
set(VSCRIPT_FLAG --version-script)
set(HAVE_VSCRIPT TRUE)
@@ -243,17 +244,13 @@
if(HAVE_VSCRIPT)
# Perform the same logic as ax_check_vscript.m4, to test whether the linker
# silently ignores (and overwrites) linker scripts it doesn't understand.
- pcre2_check_linker_flag(
- C
- -Wl,${VSCRIPT_FLAG},${CMAKE_CURRENT_BINARY_DIR}/test-map-file-broken.sym
- HAVE_VSCRIPT_BROKEN
- )
+ pcre2_check_linker_flag(C -Wl,${VSCRIPT_FLAG},${PROJECT_BINARY_DIR}/test-map-file-broken.sym HAVE_VSCRIPT_BROKEN)
if(HAVE_VSCRIPT_BROKEN)
set(HAVE_VSCRIPT FALSE)
endif()
endif()
-file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test-map-file.sym)
-file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test-map-file-broken.sym)
+file(REMOVE ${PROJECT_BINARY_DIR}/test-map-file.sym)
+file(REMOVE ${PROJECT_BINARY_DIR}/test-map-file-broken.sym)
# Check whether Intel CET is enabled, and if so, adjust compiler flags. This
# code was written by PH, trying to imitate the logic from the autotools
@@ -664,7 +661,7 @@
# Output files
-configure_file(src/config-cmake.h.in ${PROJECT_BINARY_DIR}/config.h @ONLY)
+configure_file(src/config-cmake.h.in ${PROJECT_BINARY_DIR}/src/config.h @ONLY)
# Parse version numbers and date out of configure.ac
@@ -723,7 +720,8 @@
parse_lib_version(LIBPCRE2_16)
parse_lib_version(LIBPCRE2_32)
-configure_file(src/pcre2.h.in ${PROJECT_BINARY_DIR}/pcre2.h @ONLY)
+configure_file(src/pcre2.h.in ${PROJECT_BINARY_DIR}/interface/pcre2.h @ONLY)
+configure_file(src/pcre2posix.h ${PROJECT_BINARY_DIR}/interface/pcre2posix.h COPYONLY)
# Make sure to not link debug libs
# against release libs and vice versa
@@ -736,37 +734,41 @@
if(REBUILD_CHARTABLES)
add_executable(pcre2_dftables src/pcre2_dftables.c)
add_custom_command(
- OUTPUT ${PROJECT_BINARY_DIR}/pcre2_chartables.c
+ OUTPUT ${PROJECT_BINARY_DIR}/src/pcre2_chartables.c
COMMAND pcre2_dftables
- ARGS ${PROJECT_BINARY_DIR}/pcre2_chartables.c
+ ARGS ${PROJECT_BINARY_DIR}/src/pcre2_chartables.c
DEPENDS pcre2_dftables
COMMENT "Generating character tables (pcre2_chartables.c) for current locale"
VERBATIM
)
elseif(NOT PCRE2_EBCDIC)
- configure_file(${PROJECT_SOURCE_DIR}/src/pcre2_chartables.c.dist ${PROJECT_BINARY_DIR}/pcre2_chartables.c COPYONLY)
+ configure_file(
+ ${PROJECT_SOURCE_DIR}/src/pcre2_chartables.c.dist
+ ${PROJECT_BINARY_DIR}/src/pcre2_chartables.c
+ COPYONLY
+ )
elseif(PCRE2_EBCDIC_NL25)
configure_file(
${PROJECT_SOURCE_DIR}/src/pcre2_chartables.c.ebcdic-1047-nl25
- ${PROJECT_BINARY_DIR}/pcre2_chartables.c
+ ${PROJECT_BINARY_DIR}/src/pcre2_chartables.c
COPYONLY
)
else()
configure_file(
${PROJECT_SOURCE_DIR}/src/pcre2_chartables.c.ebcdic-1047-nl15
- ${PROJECT_BINARY_DIR}/pcre2_chartables.c
+ ${PROJECT_BINARY_DIR}/src/pcre2_chartables.c
COPYONLY
)
endif()
# Source code
-set(PCRE2_HEADERS ${PROJECT_BINARY_DIR}/pcre2.h)
+set(PCRE2_HEADERS ${PROJECT_BINARY_DIR}/interface/pcre2.h)
set(
PCRE2_SOURCES
src/pcre2_auto_possess.c
- ${PROJECT_BINARY_DIR}/pcre2_chartables.c
+ ${PROJECT_BINARY_DIR}/src/pcre2_chartables.c
src/pcre2_chkdint.c
src/pcre2_compile.c
src/pcre2_compile_cgroup.c
@@ -798,7 +800,7 @@
src/pcre2_xclass.c
)
-set(PCRE2POSIX_HEADERS src/pcre2posix.h)
+set(PCRE2POSIX_HEADERS ${PROJECT_BINARY_DIR}/interface/pcre2posix.h)
set(PCRE2POSIX_SOURCES src/pcre2posix.c)
if(MINGW AND BUILD_SHARED_LIBS)
@@ -866,15 +868,13 @@
add_compile_definitions(_CRT_SECURE_NO_DEPRECATE _CRT_SECURE_NO_WARNINGS)
endif()
-set(CMAKE_INCLUDE_CURRENT_DIR 1)
-
set(TARGETS)
# 8-bit library
if(PCRE2_BUILD_PCRE2_8)
if(BUILD_STATIC_LIBS)
- add_library(pcre2-8-static STATIC ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
+ add_library(pcre2-8-static STATIC ${PCRE2_HEADERS} ${PCRE2_SOURCES})
set_target_properties(
pcre2-8-static
PROPERTIES
@@ -885,7 +885,10 @@
SOVERSION ${LIBPCRE2_8_SOVERSION}
)
target_compile_definitions(pcre2-8-static PUBLIC PCRE2_STATIC)
- target_include_directories(pcre2-8-static PUBLIC ${PROJECT_BINARY_DIR})
+ target_include_directories(
+ pcre2-8-static
+ PUBLIC "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/interface>" "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
+ )
if(REQUIRE_PTHREAD)
target_link_libraries(pcre2-8-static Threads::Threads)
endif()
@@ -901,7 +904,10 @@
SOVERSION ${LIBPCRE2_POSIX_SOVERSION}
)
target_link_libraries(pcre2-posix-static pcre2-8-static)
- target_include_directories(pcre2-posix-static PUBLIC ${PROJECT_SOURCE_DIR}/src)
+ target_include_directories(
+ pcre2-posix-static
+ PUBLIC "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/interface>" "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
+ )
set(TARGETS ${TARGETS} pcre2-posix-static)
if(MSVC)
@@ -917,8 +923,11 @@
endif()
if(BUILD_SHARED_LIBS)
- add_library(pcre2-8-shared SHARED ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
- target_include_directories(pcre2-8-shared PUBLIC ${PROJECT_BINARY_DIR})
+ add_library(pcre2-8-shared SHARED ${PCRE2_HEADERS} ${PCRE2_SOURCES})
+ target_include_directories(
+ pcre2-8-shared
+ PUBLIC "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/interface>" "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
+ )
set_target_properties(
pcre2-8-shared
PROPERTIES
@@ -941,7 +950,10 @@
set(DLL_PDB_DEBUG_FILES $<TARGET_PDB_FILE_DIR:pcre2-8-shared>/pcre2-8d.pdb ${DLL_PDB_DEBUG_FILES})
add_library(pcre2-posix-shared SHARED ${PCRE2POSIX_HEADERS} ${PCRE2POSIX_SOURCES})
- target_include_directories(pcre2-posix-shared PUBLIC ${PROJECT_SOURCE_DIR}/src)
+ target_include_directories(
+ pcre2-posix-shared
+ PUBLIC "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/interface>" "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
+ )
set_target_properties(
pcre2-posix-shared
PROPERTIES
@@ -956,8 +968,7 @@
target_link_options(pcre2-posix-shared PRIVATE -Wl,${VSCRIPT_FLAG},${PROJECT_SOURCE_DIR}/src/libpcre2-posix.sym)
set_target_properties(pcre2-posix-shared PROPERTIES LINK_DEPENDS ${PROJECT_SOURCE_DIR}/src/libpcre2-posix.sym)
endif()
- set(PCRE2POSIX_CFLAG "-DPCRE2POSIX_SHARED")
- target_compile_definitions(pcre2-posix-shared PUBLIC ${PCRE2POSIX_CFLAG})
+ target_compile_definitions(pcre2-posix-shared PUBLIC PCRE2POSIX_SHARED)
target_link_libraries(pcre2-posix-shared pcre2-8-shared)
set(TARGETS ${TARGETS} pcre2-posix-shared)
set(DLL_PDB_FILES $<TARGET_PDB_FILE_DIR:pcre2-posix-shared>/pcre2-posix.pdb ${DLL_PDB_FILES})
@@ -986,8 +997,11 @@
if(PCRE2_BUILD_PCRE2_16)
if(BUILD_STATIC_LIBS)
- add_library(pcre2-16-static STATIC ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
- target_include_directories(pcre2-16-static PUBLIC ${PROJECT_BINARY_DIR})
+ add_library(pcre2-16-static STATIC ${PCRE2_HEADERS} ${PCRE2_SOURCES})
+ target_include_directories(
+ pcre2-16-static
+ PUBLIC "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/interface>" "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
+ )
set_target_properties(
pcre2-16-static
PROPERTIES
@@ -1014,8 +1028,11 @@
endif()
if(BUILD_SHARED_LIBS)
- add_library(pcre2-16-shared SHARED ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
- target_include_directories(pcre2-16-shared PUBLIC ${PROJECT_BINARY_DIR})
+ add_library(pcre2-16-shared SHARED ${PCRE2_HEADERS} ${PCRE2_SOURCES})
+ target_include_directories(
+ pcre2-16-shared
+ PUBLIC "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/interface>" "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
+ )
set_target_properties(
pcre2-16-shared
PROPERTIES
@@ -1058,8 +1075,11 @@
if(PCRE2_BUILD_PCRE2_32)
if(BUILD_STATIC_LIBS)
- add_library(pcre2-32-static STATIC ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
- target_include_directories(pcre2-32-static PUBLIC ${PROJECT_BINARY_DIR})
+ add_library(pcre2-32-static STATIC ${PCRE2_HEADERS} ${PCRE2_SOURCES})
+ target_include_directories(
+ pcre2-32-static
+ PUBLIC "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/interface>" "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
+ )
set_target_properties(
pcre2-32-static
PROPERTIES
@@ -1086,8 +1106,11 @@
endif()
if(BUILD_SHARED_LIBS)
- add_library(pcre2-32-shared SHARED ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
- target_include_directories(pcre2-32-shared PUBLIC ${PROJECT_BINARY_DIR})
+ add_library(pcre2-32-shared SHARED ${PCRE2_HEADERS} ${PCRE2_SOURCES})
+ target_include_directories(
+ pcre2-32-shared
+ PUBLIC "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/interface>" "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
+ )
set_target_properties(
pcre2-32-shared
PROPERTIES
@@ -1139,9 +1162,9 @@
if(PCRE2_BUILD_PCRE2_8)
configure_file(libpcre2-posix.pc.in libpcre2-posix.pc @ONLY)
- list(APPEND pkg_config_files "${CMAKE_CURRENT_BINARY_DIR}/libpcre2-posix.pc")
+ list(APPEND pkg_config_files "${PROJECT_BINARY_DIR}/libpcre2-posix.pc")
configure_file(libpcre2-8.pc.in libpcre2-8.pc @ONLY)
- list(APPEND pkg_config_files "${CMAKE_CURRENT_BINARY_DIR}/libpcre2-8.pc")
+ list(APPEND pkg_config_files "${PROJECT_BINARY_DIR}/libpcre2-8.pc")
set(enable_pcre2_8 "yes")
else()
set(enable_pcre2_8 "no")
@@ -1149,7 +1172,7 @@
if(PCRE2_BUILD_PCRE2_16)
configure_file(libpcre2-16.pc.in libpcre2-16.pc @ONLY)
- list(APPEND pkg_config_files "${CMAKE_CURRENT_BINARY_DIR}/libpcre2-16.pc")
+ list(APPEND pkg_config_files "${PROJECT_BINARY_DIR}/libpcre2-16.pc")
set(enable_pcre2_16 "yes")
else()
set(enable_pcre2_16 "no")
@@ -1157,7 +1180,7 @@
if(PCRE2_BUILD_PCRE2_32)
configure_file(libpcre2-32.pc.in libpcre2-32.pc @ONLY)
- list(APPEND pkg_config_files "${CMAKE_CURRENT_BINARY_DIR}/libpcre2-32.pc")
+ list(APPEND pkg_config_files "${PROJECT_BINARY_DIR}/libpcre2-32.pc")
set(enable_pcre2_32 "yes")
else()
set(enable_pcre2_32 "no")
@@ -1349,28 +1372,33 @@
install(
TARGETS ${TARGETS}
- RUNTIME DESTINATION bin
+ EXPORT pcre2-targets
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
+install(EXPORT pcre2-targets DESTINATION ${PCRE2_INSTALL_CMAKEDIR} NAMESPACE pcre2::)
install(FILES ${pkg_config_files} DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(
- FILES "${CMAKE_CURRENT_BINARY_DIR}/pcre2-config"
- DESTINATION bin
+ FILES "${PROJECT_BINARY_DIR}/pcre2-config"
+ DESTINATION ${CMAKE_INSTALL_BINDIR}
# Set 0755 permissions
PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
-install(FILES ${PCRE2_HEADERS} ${PCRE2POSIX_HEADERS} DESTINATION include)
+install(FILES ${PCRE2_HEADERS} ${PCRE2POSIX_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# CMake config files.
-set(PCRE2_CONFIG_IN ${CMAKE_CURRENT_SOURCE_DIR}/cmake/pcre2-config.cmake.in)
-set(PCRE2_CONFIG_OUT ${CMAKE_CURRENT_BINARY_DIR}/cmake/pcre2-config.cmake)
-configure_file(${PCRE2_CONFIG_IN} ${PCRE2_CONFIG_OUT} @ONLY)
-set(PCRE2_CONFIG_VERSION_IN ${CMAKE_CURRENT_SOURCE_DIR}/cmake/pcre2-config-version.cmake.in)
-set(PCRE2_CONFIG_VERSION_OUT ${CMAKE_CURRENT_BINARY_DIR}/cmake/pcre2-config-version.cmake)
-configure_file(${PCRE2_CONFIG_VERSION_IN} ${PCRE2_CONFIG_VERSION_OUT} @ONLY)
-install(FILES ${PCRE2_CONFIG_OUT} ${PCRE2_CONFIG_VERSION_OUT} DESTINATION "${PCRE2_INSTALL_CMAKEDIR}")
+set(PCRE2_CONFIG_IN ${PROJECT_SOURCE_DIR}/cmake/pcre2-config.cmake.in)
+set(PCRE2_CONFIG_OUT ${PROJECT_BINARY_DIR}/cmake/pcre2-config.cmake)
+configure_package_config_file(${PCRE2_CONFIG_IN} ${PCRE2_CONFIG_OUT} INSTALL_DESTINATION ${PCRE2_INSTALL_CMAKEDIR})
+set(PCRE2_CONFIG_VERSION_OUT ${PROJECT_BINARY_DIR}/cmake/pcre2-config-version.cmake)
+write_basic_package_version_file(
+ ${PCRE2_CONFIG_VERSION_OUT}
+ VERSION ${PCRE2_MAJOR}.${PCRE2_MINOR}.0
+ COMPATIBILITY SameMajorVersion
+)
+install(FILES ${PCRE2_CONFIG_OUT} ${PCRE2_CONFIG_VERSION_OUT} DESTINATION ${PCRE2_INSTALL_CMAKEDIR})
file(GLOB html ${PROJECT_SOURCE_DIR}/doc/html/*.html ${PROJECT_SOURCE_DIR}/doc/html/*.txt)
file(
@@ -1393,8 +1421,8 @@
install(FILES ${html} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/doc/pcre2/html)
if(MSVC AND INSTALL_MSVC_PDB)
- install(FILES ${DLL_PDB_FILES} DESTINATION bin CONFIGURATIONS RelWithDebInfo)
- install(FILES ${DLL_PDB_DEBUG_FILES} DESTINATION bin CONFIGURATIONS Debug)
+ install(FILES ${DLL_PDB_FILES} DESTINATION ${CMAKE_INSTALL_BINDIR} CONFIGURATIONS RelWithDebInfo)
+ install(FILES ${DLL_PDB_DEBUG_FILES} DESTINATION ${CMAKE_INSTALL_BINDIR} CONFIGURATIONS Debug)
endif()
# Help, only for nice output
diff --git a/Makefile.am b/Makefile.am
index 7cb4fa4..35b5ed2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1012,7 +1012,6 @@
cmake/COPYING-CMAKE-SCRIPTS \
cmake/FindEditline.cmake \
cmake/FindReadline.cmake \
- cmake/pcre2-config-version.cmake.in \
cmake/pcre2-config.cmake.in \
cmake/PCRE2CheckLinkerFlag.cmake \
src/config-cmake.h.in \
diff --git a/README b/README
index fc1cc4a..2d9ba2a 100644
--- a/README
+++ b/README
@@ -970,7 +970,6 @@
cmake/COPYING-CMAKE-SCRIPTS
cmake/FindEditline.cmake
cmake/FindReadline.cmake
- cmake/pcre2-config-version.cmake.in
cmake/pcre2-config.cmake.in
cmake/PCRE2CheckLinkerFlag.cmake
src/config-cmake.h.in
diff --git a/cmake/pcre2-config-version.cmake.in b/cmake/pcre2-config-version.cmake.in
deleted file mode 100644
index db006063..0000000
--- a/cmake/pcre2-config-version.cmake.in
+++ /dev/null
@@ -1,14 +0,0 @@
-set(PACKAGE_VERSION_MAJOR @PCRE2_MAJOR@)
-set(PACKAGE_VERSION_MINOR @PCRE2_MINOR@)
-set(PACKAGE_VERSION_PATCH 0)
-set(PACKAGE_VERSION @PCRE2_MAJOR@.@PCRE2_MINOR@.0)
-
-# Check whether the requested PACKAGE_FIND_VERSION is compatible
-if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION OR PACKAGE_VERSION_MAJOR GREATER PACKAGE_FIND_VERSION_MAJOR)
- set(PACKAGE_VERSION_COMPATIBLE FALSE)
-else()
- set(PACKAGE_VERSION_COMPATIBLE TRUE)
- if(PACKAGE_VERSION VERSION_EQUAL PACKAGE_FIND_VERSION)
- set(PACKAGE_VERSION_EXACT TRUE)
- endif()
-endif()
diff --git a/cmake/pcre2-config.cmake.in b/cmake/pcre2-config.cmake.in
index 082dc19..bda4841 100644
--- a/cmake/pcre2-config.cmake.in
+++ b/cmake/pcre2-config.cmake.in
@@ -5,11 +5,17 @@
#
# Static vs. shared
# -----------------
-# To make use of the static library instead of the shared one, one needs
+# To force using the static library instead of the shared one, one needs
# to set the variable PCRE2_USE_STATIC_LIBS to ON before calling find_package.
+# If the variable is not set, the static library will be used if only that has
+# been built, otherwise the shared library will be used.
+#
+# The following components are supported: 8BIT, 16BIT, 32BIT and POSIX.
+# They used to be required but not anymore; all available targets will
+# be defined regardless of the requested components.
# Example:
# set(PCRE2_USE_STATIC_LIBS ON)
-# find_package(PCRE2 CONFIG COMPONENTS 8BIT)
+# find_package(PCRE2 CONFIG)
#
# This will define the following variables:
#
@@ -23,88 +29,42 @@
# PCRE2::32BIT - The 32 bit PCRE2 library.
# PCRE2::POSIX - The POSIX PCRE2 library.
-set(PCRE2_NON_STANDARD_LIB_PREFIX @NON_STANDARD_LIB_PREFIX@)
-set(PCRE2_NON_STANDARD_LIB_SUFFIX @NON_STANDARD_LIB_SUFFIX@)
-set(PCRE2_8BIT_NAME pcre2-8)
-set(PCRE2_16BIT_NAME pcre2-16)
-set(PCRE2_32BIT_NAME pcre2-32)
-set(PCRE2_POSIX_NAME pcre2-posix)
-find_path(PCRE2_INCLUDE_DIR NAMES pcre2.h DOC "PCRE2 include directory")
-if(PCRE2_USE_STATIC_LIBS)
- if(MSVC)
- set(PCRE2_8BIT_NAME pcre2-8-static)
- set(PCRE2_16BIT_NAME pcre2-16-static)
- set(PCRE2_32BIT_NAME pcre2-32-static)
- set(PCRE2_POSIX_NAME pcre2-posix-static)
- endif()
+@PACKAGE_INIT@
- set(PCRE2_PREFIX ${CMAKE_STATIC_LIBRARY_PREFIX})
- set(PCRE2_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX})
-else()
- set(PCRE2_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX})
- if(MINGW AND PCRE2_NON_STANDARD_LIB_PREFIX)
- set(PCRE2_PREFIX "")
- endif()
-
- set(PCRE2_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
- if(MINGW AND PCRE2_NON_STANDARD_LIB_SUFFIX)
- set(PCRE2_SUFFIX "-0.dll")
- elseif(MSVC)
- set(PCRE2_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX})
- endif()
+include(CMakeFindDependencyMacro)
+if("@REQUIRE_PTHREAD@") # REQUIRE_PTHREAD
+ find_dependency(Threads)
endif()
-find_library(
- PCRE2_8BIT_LIBRARY
- NAMES ${PCRE2_PREFIX}${PCRE2_8BIT_NAME}${PCRE2_SUFFIX} ${PCRE2_PREFIX}${PCRE2_8BIT_NAME}d${PCRE2_SUFFIX}
- DOC "8 bit PCRE2 library"
-)
-find_library(
- PCRE2_16BIT_LIBRARY
- NAMES ${PCRE2_PREFIX}${PCRE2_16BIT_NAME}${PCRE2_SUFFIX} ${PCRE2_PREFIX}${PCRE2_16BIT_NAME}d${PCRE2_SUFFIX}
- DOC "16 bit PCRE2 library"
-)
-find_library(
- PCRE2_32BIT_LIBRARY
- NAMES ${PCRE2_PREFIX}${PCRE2_32BIT_NAME}${PCRE2_SUFFIX} ${PCRE2_PREFIX}${PCRE2_32BIT_NAME}d${PCRE2_SUFFIX}
- DOC "32 bit PCRE2 library"
-)
-find_library(
- PCRE2_POSIX_LIBRARY
- NAMES ${PCRE2_PREFIX}${PCRE2_POSIX_NAME}${PCRE2_SUFFIX} ${PCRE2_PREFIX}${PCRE2_POSIX_NAME}d${PCRE2_SUFFIX}
- DOC "8 bit POSIX PCRE2 library"
-)
-unset(PCRE2_NON_STANDARD_LIB_PREFIX)
-unset(PCRE2_NON_STANDARD_LIB_SUFFIX)
-unset(PCRE2_8BIT_NAME)
-unset(PCRE2_16BIT_NAME)
-unset(PCRE2_32BIT_NAME)
-unset(PCRE2_POSIX_NAME)
+
+include("${CMAKE_CURRENT_LIST_DIR}/pcre2-targets.cmake")
# Set version
-if(PCRE2_INCLUDE_DIR)
- set(PCRE2_VERSION "@PCRE2_MAJOR@.@PCRE2_MINOR@.0")
-endif()
+set(PCRE2_VERSION "@PCRE2_MAJOR@.@PCRE2_MINOR@.0")
-# Which components have been found.
-if(PCRE2_8BIT_LIBRARY)
- set(PCRE2_8BIT_FOUND TRUE)
-endif()
-if(PCRE2_16BIT_LIBRARY)
- set(PCRE2_16BIT_FOUND TRUE)
-endif()
-if(PCRE2_32BIT_LIBRARY)
- set(PCRE2_32BIT_FOUND TRUE)
-endif()
-if(PCRE2_POSIX_LIBRARY)
- set(PCRE2_POSIX_FOUND TRUE)
-endif()
-
-# Check if at least one component has been specified.
-list(LENGTH PCRE2_FIND_COMPONENTS PCRE2_NCOMPONENTS)
-if(PCRE2_NCOMPONENTS LESS 1)
- message(FATAL_ERROR "No components have been specified. This is not allowed. Please, specify at least one component.")
-endif()
-unset(PCRE2_NCOMPONENTS)
+# Chooses the linkage of the library to expose in the
+# unsuffixed edition of the target.
+macro(_pcre2_add_component_target component target)
+ # If the static library exists and either PCRE2_USE_STATIC_LIBS
+ # is defined, or the dynamic library does not exist, use the static library.
+ if(NOT TARGET PCRE2::${component})
+ if(TARGET pcre2::pcre2-${target}-static AND (PCRE2_USE_STATIC_LIBS OR NOT TARGET pcre2::pcre2-${target}-shared))
+ add_library(PCRE2::${component} ALIAS pcre2::pcre2-${target}-static)
+ set(PCRE2_${component}_FOUND TRUE)
+ # Otherwise use the dynamic library if it exists.
+ elseif(TARGET pcre2::pcre2-${target}-shared AND NOT PCRE2_USE_STATIC_LIBS)
+ add_library(PCRE2::${component} ALIAS pcre2::pcre2-${target}-shared)
+ set(PCRE2_${component}_FOUND TRUE)
+ endif()
+ if(PCRE2_${component}_FOUND)
+ get_target_property(PCRE2_${component}_LIBRARY PCRE2::${component} IMPORTED_LOCATION)
+ set(PCRE2_LIBRARIES ${PCRE2_LIBRARIES} ${PCRE2_${component}_LIBRARY})
+ endif()
+ endif()
+endmacro()
+_pcre2_add_component_target(8BIT 8)
+_pcre2_add_component_target(16BIT 16)
+_pcre2_add_component_target(32BIT 32)
+_pcre2_add_component_target(POSIX posix)
# When POSIX component has been specified make sure that also 8BIT component is specified.
set(PCRE2_8BIT_COMPONENT FALSE)
@@ -126,43 +86,5 @@
unset(PCRE2_8BIT_COMPONENT)
unset(PCRE2_POSIX_COMPONENT)
-include(FindPackageHandleStandardArgs)
-set(${CMAKE_FIND_PACKAGE_NAME}_CONFIG "${CMAKE_CURRENT_LIST_FILE}")
-find_package_handle_standard_args(
- PCRE2
- FOUND_VAR PCRE2_FOUND
- REQUIRED_VARS PCRE2_INCLUDE_DIR
- HANDLE_COMPONENTS
- VERSION_VAR PCRE2_VERSION
- CONFIG_MODE
-)
-
-set(PCRE2_LIBRARIES)
-if(PCRE2_FOUND)
- foreach(component ${PCRE2_FIND_COMPONENTS})
- if(PCRE2_USE_STATIC_LIBS)
- add_library(PCRE2::${component} STATIC IMPORTED)
- target_compile_definitions(PCRE2::${component} INTERFACE PCRE2_STATIC)
- else()
- add_library(PCRE2::${component} SHARED IMPORTED)
- endif()
- set_target_properties(
- PCRE2::${component}
- PROPERTIES
- IMPORTED_LOCATION "${PCRE2_${component}_LIBRARY}"
- IMPORTED_IMPLIB "${PCRE2_${component}_LIBRARY}"
- INTERFACE_INCLUDE_DIRECTORIES "${PCRE2_INCLUDE_DIR}"
- )
- if(component STREQUAL "POSIX")
- set_target_properties(
- PCRE2::${component}
- PROPERTIES INTERFACE_LINK_LIBRARIES "PCRE2::8BIT" LINK_LIBRARIES "PCRE2::8BIT"
- )
- endif()
-
- set(PCRE2_LIBRARIES ${PCRE2_LIBRARIES} ${PCRE2_${component}_LIBRARY})
- mark_as_advanced(PCRE2_${component}_LIBRARY)
- endforeach()
-endif()
-
-mark_as_advanced(PCRE2_INCLUDE_DIR)
+# Check for required components.
+check_required_components("PCRE2")
diff --git a/doc/html/README.txt b/doc/html/README.txt
index fc1cc4a..2d9ba2a 100644
--- a/doc/html/README.txt
+++ b/doc/html/README.txt
@@ -970,7 +970,6 @@
cmake/COPYING-CMAKE-SCRIPTS
cmake/FindEditline.cmake
cmake/FindReadline.cmake
- cmake/pcre2-config-version.cmake.in
cmake/pcre2-config.cmake.in
cmake/PCRE2CheckLinkerFlag.cmake
src/config-cmake.h.in
diff --git a/maint/.gitignore b/maint/.gitignore
index d9a9ef1..084f729 100644
--- a/maint/.gitignore
+++ b/maint/.gitignore
@@ -7,3 +7,5 @@
testinput
testoutput
+
+!build-interface
diff --git a/maint/RunManifestTest b/maint/RunManifestTest
index 26de3b5..03e8414 100755
--- a/maint/RunManifestTest
+++ b/maint/RunManifestTest
@@ -9,14 +9,16 @@
export LANG
if [ "$1" = "" -o "$2" = "" ] ; then
- echo "Usage: $0 <dir> <manifest name>" >&2
+ echo "Usage: $0 <dir> <manifest name> [<build type>]" >&2
exit 1
fi
input_dir="$1"
expected_manifest="$2"
+build_type="${3:-release}"
-base=`basename $expected_manifest`
+actual_file=`basename $expected_manifest`.actual
+expected_file=`basename $expected_manifest`.expected
sed=sed
# Helper for Solaris
@@ -29,17 +31,24 @@
xargs -n1 -- ls -l -d -n | \
$sed -E -e 's/ {2,}/ /g' | \
cut -d' ' -f '1,9-' \
- > "$base"
+ > "$actual_file"
-if ! diff -u "$expected_manifest" "$base"; then
+# The CMake install is a bit annoying now. Its installed files are actually
+# dependent on the build type. So, if the build type is not "release", we need
+# to modify the expected manifest to match the actual one.
+cat "$expected_manifest" | \
+ $sed -E -e "s/pcre2-targets-release.cmake/pcre2-targets-$build_type.cmake/" \
+ > "$expected_file"
+
+if ! diff -u "$expected_file" "$actual_file"; then
echo "Installed files differ from expected"
echo "===Actual==="
- cat "$base"
+ cat "$actual_file"
echo "===End==="
exit 1
fi
echo "Installed files match expected"
-rm -f "$base"
+rm -f "$actual_file" "$expected_file"
diff --git a/maint/RunSymbolTest b/maint/RunSymbolTest
index fa9dd69..dc8b0cf 100755
--- a/maint/RunSymbolTest
+++ b/maint/RunSymbolTest
@@ -52,7 +52,7 @@
so_ext=dylib
so_mangling()
{
- sed -E -e 's/_([_0-9a-zA-Z]+)$/\1/g'
+ $sed -E -e 's/_([_0-9a-zA-Z]+)$/\1/g'
}
fi
diff --git a/maint/cmake-tests/build-interface/CMakeLists.txt b/maint/cmake-tests/build-interface/CMakeLists.txt
new file mode 100644
index 0000000..6512434
--- /dev/null
+++ b/maint/cmake-tests/build-interface/CMakeLists.txt
@@ -0,0 +1,12 @@
+cmake_minimum_required(VERSION 3.15)
+project(TestBuildInterface C)
+set(CMAKE_C_STANDARD 99)
+set(CMAKE_C_STANDARD_REQUIRED TRUE)
+
+# To test the static vs dynamic interface, uncomment one of the following lines:
+# set(BUILD_STATIC_LIBS OFF)
+# set(BUILD_SHARED_LIBS ON)
+add_subdirectory(pcre2)
+
+add_executable(test_executable main.c)
+target_link_libraries(test_executable PRIVATE pcre2-8)
diff --git a/maint/cmake-tests/build-interface/main.c b/maint/cmake-tests/build-interface/main.c
new file mode 100644
index 0000000..ee82127
--- /dev/null
+++ b/maint/cmake-tests/build-interface/main.c
@@ -0,0 +1,11 @@
+#define PCRE2_CODE_UNIT_WIDTH 8
+#include <pcre2.h>
+#include <stdio.h>
+
+int main(void)
+{
+ char version_str[32];
+ pcre2_config(PCRE2_CONFIG_VERSION, version_str);
+ printf("Using PCRE2 version: %s\n", version_str);
+ return 0;
+}
diff --git a/maint/cmake-tests/install-interface/CMakeLists.txt b/maint/cmake-tests/install-interface/CMakeLists.txt
new file mode 100644
index 0000000..3cad845
--- /dev/null
+++ b/maint/cmake-tests/install-interface/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 3.15)
+project(TestInstallInterface C)
+set(CMAKE_C_STANDARD 99)
+set(CMAKE_C_STANDARD_REQUIRED TRUE)
+
+# To test the static interface, uncomment the following line:
+# set(PCRE2_USE_STATIC_LIBS ON)
+find_package(PCRE2 REQUIRED CONFIG)
+
+add_executable(test_executable main.c)
+target_link_libraries(test_executable PRIVATE PCRE2::8BIT)
+
+if(WIN32 AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.21 AND NOT PCRE2_USE_STATIC_LIBS)
+ # Ensure that the DLLs are available for the executable to run. Only needed
+ # on Windows.
+ add_custom_command(TARGET test_executable POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:test_executable> $<TARGET_FILE_DIR:test_executable>
+ COMMAND_EXPAND_LISTS
+ )
+endif()
diff --git a/maint/cmake-tests/install-interface/main.c b/maint/cmake-tests/install-interface/main.c
new file mode 100644
index 0000000..ee82127
--- /dev/null
+++ b/maint/cmake-tests/install-interface/main.c
@@ -0,0 +1,11 @@
+#define PCRE2_CODE_UNIT_WIDTH 8
+#include <pcre2.h>
+#include <stdio.h>
+
+int main(void)
+{
+ char version_str[32];
+ pcre2_config(PCRE2_CONFIG_VERSION, version_str);
+ printf("Using PCRE2 version: %s\n", version_str);
+ return 0;
+}
diff --git a/maint/manifest-cmakeinstall-freebsd b/maint/manifest-cmakeinstall-freebsd
index 194127b..2c8936b 100644
--- a/maint/manifest-cmakeinstall-freebsd
+++ b/maint/manifest-cmakeinstall-freebsd
@@ -11,6 +11,8 @@
drwxr-xr-x install-dir/lib/cmake/pcre2
-rw-r--r-- install-dir/lib/cmake/pcre2/pcre2-config-version.cmake
-rw-r--r-- install-dir/lib/cmake/pcre2/pcre2-config.cmake
+-rw-r--r-- install-dir/lib/cmake/pcre2/pcre2-targets-release.cmake
+-rw-r--r-- install-dir/lib/cmake/pcre2/pcre2-targets.cmake
-rw-r--r-- install-dir/lib/libpcre2-16.a
lrwxr-xr-x install-dir/lib/libpcre2-16.so -> libpcre2-16.so.0
lrwxr-xr-x install-dir/lib/libpcre2-16.so.0 -> libpcre2-16.so.0.14.0
diff --git a/maint/manifest-cmakeinstall-linux b/maint/manifest-cmakeinstall-linux
index 04e4645..315e90d 100644
--- a/maint/manifest-cmakeinstall-linux
+++ b/maint/manifest-cmakeinstall-linux
@@ -11,6 +11,8 @@
drwxr-xr-x install-dir/lib/cmake/pcre2
-rw-r--r-- install-dir/lib/cmake/pcre2/pcre2-config-version.cmake
-rw-r--r-- install-dir/lib/cmake/pcre2/pcre2-config.cmake
+-rw-r--r-- install-dir/lib/cmake/pcre2/pcre2-targets-release.cmake
+-rw-r--r-- install-dir/lib/cmake/pcre2/pcre2-targets.cmake
-rw-r--r-- install-dir/lib/libpcre2-16.a
lrwxrwxrwx install-dir/lib/libpcre2-16.so -> libpcre2-16.so.0
lrwxrwxrwx install-dir/lib/libpcre2-16.so.0 -> libpcre2-16.so.0.14.0
diff --git a/maint/manifest-cmakeinstall-macos b/maint/manifest-cmakeinstall-macos
index 73738e0..74adec0 100644
--- a/maint/manifest-cmakeinstall-macos
+++ b/maint/manifest-cmakeinstall-macos
@@ -11,6 +11,8 @@
drwxr-xr-x install-dir/lib/cmake/pcre2
-rw-r--r-- install-dir/lib/cmake/pcre2/pcre2-config-version.cmake
-rw-r--r-- install-dir/lib/cmake/pcre2/pcre2-config.cmake
+-rw-r--r-- install-dir/lib/cmake/pcre2/pcre2-targets-release.cmake
+-rw-r--r-- install-dir/lib/cmake/pcre2/pcre2-targets.cmake
-rwxr-xr-x install-dir/lib/libpcre2-16.0.14.0.dylib
lrwxr-xr-x install-dir/lib/libpcre2-16.0.dylib -> libpcre2-16.0.14.0.dylib
-rw-r--r-- install-dir/lib/libpcre2-16.a
diff --git a/maint/manifest-cmakeinstall-solaris b/maint/manifest-cmakeinstall-solaris
index f56c3e7..807f89e 100644
--- a/maint/manifest-cmakeinstall-solaris
+++ b/maint/manifest-cmakeinstall-solaris
@@ -11,6 +11,8 @@
drwxr-xr-x install-dir/lib/cmake/pcre2
-rw-r--r-- install-dir/lib/cmake/pcre2/pcre2-config-version.cmake
-rw-r--r-- install-dir/lib/cmake/pcre2/pcre2-config.cmake
+-rw-r--r-- install-dir/lib/cmake/pcre2/pcre2-targets-release.cmake
+-rw-r--r-- install-dir/lib/cmake/pcre2/pcre2-targets.cmake
-rw-r--r-- install-dir/lib/libpcre2-16.a
lrwxrwxrwx install-dir/lib/libpcre2-16.so -> libpcre2-16.so.0
lrwxrwxrwx install-dir/lib/libpcre2-16.so.0 -> libpcre2-16.so.0.14.0
diff --git a/maint/manifest-cmakeinstall-windows b/maint/manifest-cmakeinstall-windows
index 4c35e0a..faaf8a8 100644
--- a/maint/manifest-cmakeinstall-windows
+++ b/maint/manifest-cmakeinstall-windows
@@ -14,6 +14,8 @@
d---- .\install-dir\lib\cmake\pcre2
-a--- .\install-dir\lib\cmake\pcre2\pcre2-config-version.cmake
-a--- .\install-dir\lib\cmake\pcre2\pcre2-config.cmake
+-a--- .\install-dir\lib\cmake\pcre2\pcre2-targets-release.cmake
+-a--- .\install-dir\lib\cmake\pcre2\pcre2-targets.cmake
-a--- .\install-dir\lib\pcre2-16-static.lib
-a--- .\install-dir\lib\pcre2-16.lib
-a--- .\install-dir\lib\pcre2-32-static.lib
diff --git a/maint/manifest-tarball b/maint/manifest-tarball
index eae3fec..5ee3b23 100644
--- a/maint/manifest-tarball
+++ b/maint/manifest-tarball
@@ -27,7 +27,6 @@
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/cmake/FindEditline.cmake
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/cmake/FindReadline.cmake
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/cmake/PCRE2CheckLinkerFlag.cmake
--rw-r--r-- tarball-dir/pcre2-SNAPSHOT/cmake/pcre2-config-version.cmake.in
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/cmake/pcre2-config.cmake.in
-rwxr-xr-x tarball-dir/pcre2-SNAPSHOT/compile
-rwxr-xr-x tarball-dir/pcre2-SNAPSHOT/config.guess