Skip to content
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
11 changes: 6 additions & 5 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ jobs:
run: |
echo "set man-db/auto-update false" | sudo debconf-communicate && sudo dpkg-reconfigure man-db
sudo apt-get -qq update
sudo apt-get -qq install -y git build-essential cmake zlib1g-dev libbz2-dev libedit-dev
sudo apt-get -qq install -y git build-essential cmake zlib1g-dev libbz2-dev libedit-dev ninja-build


- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
Expand Down Expand Up @@ -166,8 +167,8 @@ jobs:
for useStaticLibs in ON OFF; do
echo "== Testing CMake install interface with PCRE2_USE_STATIC_LIBS=$useStaticLibs =="
rm -rf build
cmake $CMAKE_FLAGS -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$INSTALL_PREFIX" -DPCRE2_USE_STATIC_LIBS=$useStaticLibs -B build
(cd build; make)
cmake -GNinja $CMAKE_FLAGS -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$INSTALL_PREFIX" -DPCRE2_USE_STATIC_LIBS=$useStaticLibs -B build
(cd build; ninja)
./build/test_executable
ldd ./build/test_executable
if [ $useStaticLibs = ON ]; then
Expand All @@ -190,8 +191,8 @@ jobs:
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 $CMAKE_FLAGS -DCMAKE_BUILD_TYPE=Debug -DBUILD_STATIC_LIBS=$static -DBUILD_SHARED_LIBS=$shared -B build
(cd build; make)
cmake -GNinja $CMAKE_FLAGS -DCMAKE_BUILD_TYPE=Debug -DBUILD_STATIC_LIBS=$static -DBUILD_SHARED_LIBS=$shared -B build
(cd build; ninja)
./build/test_executable
ldd ./build/test_executable
if [ $static = ON ]; then
Expand Down
15 changes: 10 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,19 @@ check_include_file(windows.h HAVE_WINDOWS_H)
pcre2_use_system_extensions()

cmake_push_check_state(RESET)
# Somewhat awkward code to propagate the _GNU_SOURCE definition (added to
# COMPILE_DEFINITIONS by pcre2_use_system_extensions()).
# Propagate the _GNU_SOURCE definition (added to COMPILE_DEFINITIONS by
# pcre2_use_system_extensions()) so that these check_symbol_exists() calls
# can find symbols only exposed with _GNU_SOURCE.
# We only pass through known plain-text definitions (like _GNU_SOURCE) and
# skip anything else (e.g. generator expressions inherited from a parent
# project), because try_compile() cannot handle generator expressions.
get_directory_property(_pcre2_compile_definitions COMPILE_DEFINITIONS)
if(DEFINED _pcre2_compile_definitions)
set(CMAKE_REQUIRED_DEFINITIONS "")
foreach(_def IN LISTS _pcre2_compile_definitions)
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D${_def}")
endforeach()
list(FIND _pcre2_compile_definitions "_GNU_SOURCE" _idx)
if(_idx GREATER -1)
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
endif()
endif()

check_symbol_exists(mkostemp stdlib.h HAVE_MKOSTEMP) # glibc 2.7
Expand Down
6 changes: 6 additions & 0 deletions maint/cmake-tests/build-interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ project(TestBuildInterface C)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED TRUE)

# We had a regression where a parent project compile definition containing
# generator expressions was incorrectly propagated to CMAKE_REQUIRED_DEFINITIONS
# (which doesn't support generator expressions). This dummy macro here prevents
# that happening again.
add_compile_definitions($<$<CONFIG:Debug>:PARENT_PROJECT_MACRO>)

# To test the static vs dynamic interface, uncomment one of the following lines:
# set(BUILD_STATIC_LIBS OFF)
# set(BUILD_SHARED_LIBS ON)
Expand Down