Skip to content

Re-apply "Use standard CMake constructs to export the targets. (#260)" #739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 106 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,50 @@ jobs:
../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
Expand Down Expand Up @@ -150,6 +194,66 @@ jobs:
../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
Expand Down Expand Up @@ -191,7 +295,7 @@ jobs:
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
Expand Down Expand Up @@ -273,7 +377,7 @@ jobs:
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
Expand Down
52 changes: 48 additions & 4 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
# 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: |
Expand Down Expand Up @@ -121,11 +121,55 @@ jobs:
../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: |
Expand Down Expand Up @@ -200,7 +244,7 @@ jobs:
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:
Expand Down Expand Up @@ -372,7 +416,7 @@ jobs:
# 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
Expand Down
Loading