Skip to content
Open
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
8 changes: 4 additions & 4 deletions .github/workflows/CI-unixish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
if: contains(matrix.image, 'ubuntu')
run: |
apt-get update
apt-get install -y cmake g++ make libxml2-utils libpcre3-dev
apt-get install -y cmake g++ make libxml2-utils libpcre2-dev

- name: Install missing software (gui) on latest ubuntu
if: contains(matrix.image, 'ubuntu')
Expand All @@ -61,7 +61,7 @@ jobs:
- name: Install missing software on Alpine
if: contains(matrix.image, 'alpine')
run: |
apk add cmake make g++ pcre-dev
apk add cmake make g++ pcre2-dev

# needs to be called after the package installation since
# - it doesn't call "apt-get update"
Expand Down Expand Up @@ -104,12 +104,12 @@ jobs:
if: contains(matrix.image, 'ubuntu')
run: |
apt-get update
apt-get install -y g++ make python3 libxml2-utils libpcre3-dev
apt-get install -y g++ make python3 libxml2-utils libpcre2-dev

- name: Install missing software on Alpine
if: contains(matrix.image, 'alpine')
run: |
apk add make g++ pcre-dev bash python3 libxml2-utils
apk add make g++ pcre2-dev bash python3 libxml2-utils

# needs to be called after the package installation since
# - it doesn't call "apt-get update"
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/CI-unixish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ jobs:
- name: Install missing software on macos
if: contains(matrix.os, 'macos')
run: |
# pcre was removed from runner images in November 2022
brew install coreutils qt@6 tinyxml2 pcre
brew install coreutils qt@6 tinyxml2 pcre2

- name: CMake build on ubuntu (with GUI / system tinyxml2)
if: contains(matrix.os, 'ubuntu')
Expand Down Expand Up @@ -121,8 +120,7 @@ jobs:
- name: Install missing software on macos
if: contains(matrix.os, 'macos')
run: |
# pcre was removed from runner images in November 2022
brew install coreutils qt@6 pcre
brew install coreutils qt@6 pcre2

- name: Run CMake on ubuntu (with GUI)
if: contains(matrix.os, 'ubuntu')
Expand Down Expand Up @@ -238,8 +236,7 @@ jobs:
- name: Install missing software on macos
if: contains(matrix.os, 'macos')
run: |
# pcre was removed from runner images in November 2022
brew install coreutils qt@6 pcre
brew install coreutils qt@6 pcre2

- name: Run CMake on ubuntu (with GUI)
if: contains(matrix.os, 'ubuntu')
Expand Down Expand Up @@ -486,8 +483,7 @@ jobs:
- name: Install missing software on macos
if: contains(matrix.os, 'macos')
run: |
# pcre was removed from runner images in November 2022
brew install coreutils pcre gnu-sed
brew install coreutils pcre2 gnu-sed

- name: Install missing Python packages on ubuntu
if: contains(matrix.os, 'ubuntu')
Expand Down
40 changes: 19 additions & 21 deletions .github/workflows/CI-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,8 @@ jobs:
runs-on: ${{ matrix.os }}

env:
# see https://www.pcre.org/original/changelog.txt
PCRE_VERSION: 8.45

# see https://github.com/PCRE2Project/pcre2/blob/master/ChangeLog
PCRE2_VERSION: 10.49
steps:
- uses: actions/checkout@v6
with:
Expand All @@ -170,32 +169,31 @@ jobs:
with:
arch: x64

- name: Cache PCRE
id: cache-pcre
- name: Cache PCRE2
id: cache-pcre2
uses: actions/cache@v5
with:
path: |
externals\pcre.h
externals\pcre.lib
externals\pcre64.lib
key: pcre-${{ env.PCRE_VERSION }}-x64-bin-win
externals\pcre2.h
externals\pcre2-8.lib
key: pcre2-${{ env.PCRE2_VERSION }}-x64-bin-win

- name: Download PCRE
if: steps.cache-pcre.outputs.cache-hit != 'true'
- name: Download PCRE2
if: steps.cache-pcre2.outputs.cache-hit != 'true'
run: |
curl -fsSL https://github.com/pfultz2/pcre/archive/refs/tags/%PCRE_VERSION%.zip -o pcre-%PCRE_VERSION%.zip || exit /b !errorlevel!
curl -fsSL https://github.com/PCRE2Project/pcre2/releases/download/pcre2-%PCRE2_VERSION%/pcre2-%PCRE2_VERSION%.zip -o pcre2-%PCRE2_VERSION%.zip || exit /b !errorlevel!

- name: Install PCRE
if: steps.cache-pcre.outputs.cache-hit != 'true'
- name: Install PCRE2
if: steps.cache-pcre2.outputs.cache-hit != 'true'
run: |
@echo on
7z x pcre-%PCRE_VERSION%.zip || exit /b !errorlevel!
cd pcre-%PCRE_VERSION% || exit /b !errorlevel!
git apply --ignore-space-change ..\externals\pcre.patch || exit /b !errorlevel!
cmake . -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DPCRE_BUILD_PCRECPP=Off -DPCRE_BUILD_TESTS=Off -DPCRE_BUILD_PCREGREP=Off -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_COMPILE_WARNING_AS_ERROR=On || exit /b !errorlevel!
nmake || exit /b !errorlevel!
copy pcre.h ..\externals || exit /b !errorlevel!
copy pcre.lib ..\externals\pcre64.lib || exit /b !errorlevel!
7z x pcre2-%PCRE2_VERSION%.zip || exit /b !errorlevel!
cd pcre2-%PCRE2_VERSION% || exit /b !errorlevel!
cmake -S . -B build -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=Off -DBUILD_STATIC_LIBS=On -DPCRE2_SUPPORT_JIT=On -DPCRE2_BUILD_PCRE2GREP=Off -DPCRE2_BUILD_TESTS=Off || exit /b !errorlevel!
cmake --build build || exit /b !errorlevel!
cmake --install build --prefix pcre2-dist || exit /b !errorlevel!
copy pcre2-dist\include\pcre2.h ..\externals || exit /b !errorlevel!
copy pcre2-dist\lib\pcre2-8-static.lib ..\externals\pcre2-8.lib || exit /b !errorlevel!
env:
CL: /MP

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y cmake make
sudo apt-get install -y libpcre3-dev
sudo apt-get install -y libpcre2-dev
sudo apt-get install -y libgl-dev # fixes missing dependency for Qt in CMake

- name: Install clang
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/iwyu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
if: contains(matrix.image, 'debian')
run: |
apt-get update
apt-get install -y cmake clang make libpcre3-dev
apt-get install -y cmake clang make libpcre2-dev
apt-get install -y libgl-dev # fixes missing dependency for Qt in CMake
apt-get install -y iwyu

Expand All @@ -56,7 +56,7 @@ jobs:
run: |
set -x
pacman -Sy
pacman -S cmake make clang pcre --noconfirm
pacman -S cmake make clang pcre2 --noconfirm
pacman -S libglvnd --noconfirm # fixes missing dependency for Qt in CMake
pacman-key --init
pacman-key --recv-key 3056513887B78AEB --keyserver keyserver.ubuntu.com
Expand Down Expand Up @@ -88,15 +88,15 @@ jobs:
- name: Install missing software on OpenSUSE
if: contains(matrix.image, 'opensuse')
run: |
zypper install -y cmake clang pcre-devel
zypper install -y cmake clang pcre2-devel
zypper install -y include-what-you-use-tools
ln -s iwyu_tool.py /usr/bin/iwyu_tool

# coreutils contains "nproc"
- name: Install missing software on macOS
if: contains(matrix.os, 'macos')
run: |
brew install include-what-you-use pcre coreutils
brew install include-what-you-use pcre2 coreutils
# on Apple Silicon files are symlinked under /opt/homebrew/bin
ln -s /opt/homebrew/bin/iwyu_tool.py /usr/local/bin/iwyu_tool

Expand Down Expand Up @@ -206,7 +206,7 @@ jobs:
- name: Install missing software
run: |
sudo apt-get update
sudo apt-get install -y cmake make libpcre3-dev
sudo apt-get install -y cmake make libpcre2-dev
sudo apt-get install -y libgl-dev # missing dependency for using Qt in CMake

- name: Install clang
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/release-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jobs:

env:
PYTHON_VERSION: 3.14
# see https://www.pcre.org/original/changelog.txt
PCRE_VERSION: 8.45
# see https://github.com/PCRE2Project/pcre2/blob/master/ChangeLog
PCRE2_VERSION: 10.49
QT_VERSION: 6.10.0
BOOST_MINOR_VERSION: 89

Expand All @@ -45,20 +45,20 @@ jobs:
- name: Set up Visual Studio environment
uses: ilammy/msvc-dev-cmd@v1

- name: Download PCRE
- name: Download PCRE2
run: |
curl -fsSL https://github.com/pfultz2/pcre/archive/refs/tags/%PCRE_VERSION%.zip -o pcre-%PCRE_VERSION%.zip || exit /b !errorlevel!
curl -fsSL https://github.com/PCRE2Project/pcre2/releases/download/pcre2-%PCRE2_VERSION%/pcre2-%PCRE2_VERSION%.zip -o pcre2-%PCRE2_VERSION%.zip || exit /b !errorlevel!

- name: Install PCRE
- name: Install PCRE2
run: |
@echo on
7z x pcre-%PCRE_VERSION%.zip || exit /b !errorlevel!
cd pcre-%PCRE_VERSION% || exit /b !errorlevel!
git apply --ignore-space-change ..\externals\pcre.patch || exit /b !errorlevel!
cmake . -A x64 -DPCRE_BUILD_PCRECPP=OFF -DPCRE_BUILD_PCREGREP=OFF -DPCRE_BUILD_TESTS=OFF -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_COMPILE_WARNING_AS_ERROR=On || exit /b !errorlevel!
msbuild -m PCRE.slnx -p:Configuration=Release -p:Platform=x64 || exit /b !errorlevel!
copy pcre.h ..\externals || exit /b !errorlevel!
copy Release\pcre.lib ..\externals\pcre64.lib || exit /b !errorlevel!
7z x pcre2-%PCRE2_VERSION%.zip || exit /b !errorlevel!
cd pcre2-%PCRE2_VERSION% || exit /b !errorlevel!
cmake -S . -B build -A x64 -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2GREP=OFF -DPCRE2_BUILD_TESTS=OFF || exit /b !errorlevel!
cmake --build build --config Release || exit /b !errorlevel!
cmake --install build --config Release --prefix pcre2-dist || exit /b !errorlevel!
copy pcre2-dist\include\pcre2.h ..\externals || exit /b !errorlevel!
copy pcre2-dist\lib\pcre2-8-static.lib ..\externals\pcre2-8.lib || exit /b !errorlevel!

- name: Download Boost
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sanitizers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
- name: Install missing software on ubuntu
run: |
sudo apt-get update
sudo apt-get install -y cmake make libpcre3-dev libboost-container-dev libxml2-utils
sudo apt-get install -y cmake make libpcre2-dev libboost-container-dev libxml2-utils
sudo apt-get install -y libcups2-dev # required for Qt6PrintSupport in CMake since Qt 6.7.3

- name: Install clang
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,6 @@ stage
# ccache folder in CI
/.ccache

# PCRE Windows files
/externals/pcre.h
/externals/pcre64.lib
# PCRE2 Windows files
/externals/pcre2.h
/externals/pcre2-8.lib
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,16 @@ ifeq (g++, $(findstring g++,$(CXX)))
endif
override CXXFLAGS += -std=c++11
ifeq ($(HAVE_RULES),yes)
PCRE_CONFIG = $(shell which pcre-config)
PCRE_CONFIG = $(shell which pcre2-config)
ifeq ($(PCRE_CONFIG),)
$(error Did not find pcre-config)
$(error Did not find pcre2-config)
endif
override CXXFLAGS += $(shell $(PCRE_CONFIG) --cflags)
override CPPFLAGS += -DHAVE_RULES
ifdef LIBS
LIBS += $(shell $(PCRE_CONFIG) --libs)
LIBS += $(shell $(PCRE_CONFIG) --libs8)
else
LIBS=$(shell $(PCRE_CONFIG) --libs)
LIBS=$(shell $(PCRE_CONFIG) --libs8)
endif
else ifneq ($(HAVE_RULES),)
$(error invalid HAVE_RULES value '$(HAVE_RULES)')
Expand Down
55 changes: 19 additions & 36 deletions build-pcre.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PCRE is a library that is used by the optional "rules" feature for the command
line version of cppcheck. It is readily available on Linux and Mac OS X, but
PCRE2 is a library that is used by the optional "rules" feature for the command
line version of cppcheck. It is readily available on Linux and macOS, but
must be obtained separately for Windows.

Build instructions
Expand All @@ -10,54 +10,37 @@ Windows

Visual Studio

To build PCRE, download the source code from www.pcre.org and
CMake (https://cmake.org/download/). We assume you use Visual Studio 2015 -
otherwise adapt the commands for your version.
Download the PCRE2 source code from https://github.com/PCRE2Project/pcre2/releases
and CMake (https://cmake.org/download/). Then build a static library from a
Visual Studio developer command prompt:

VS Solution file
cmake . -G "Visual Studio 14 2015"
Open PCRE.sln with VS IDE or via cmd:
call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" x86
MSBuild PCRE.sln /target:Build /property:Configuration="Release"
cmake -S . -B build -A x64 -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON -DPCRE2_SUPPORT_JIT=ON -DPCRE2_BUILD_PCRE2GREP=OFF -DPCRE2_BUILD_TESTS=OFF
cmake --build build --config Release
cmake --install build --config Release --prefix pcre2-dist

For 64-bit target: cmake . -G "Visual Studio 14 2015 Win64"

or using NMake
call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" x86
cmake . -G "NMake Makefiles"
nmake

or using MSYS
cmake . -G "MSYS Makefiles"
make
Copy pcre2-dist\include\pcre2.h and pcre2-dist\lib\pcre2-8-static.lib (renamed to
pcre2-8.lib) into the /externals directory and select the "Release-PCRE" or
"Debug-PCRE" configuration in cppcheck.sln.


Linux
-----

The normal Makefile should work.

Install PCRE on Ubuntu might be needed:
sudo apt-get install libpcre3 libpcre3-dev
Install PCRE2 on Debian/Ubuntu might be needed:
sudo apt-get install libpcre2-dev


Mac OSX
-------

Install PCRE:

homebre
brew install pcre

or macport
sudo port install pcre

Ensure /path/to/pcre.h is in CXXFLAGS, e.g:
Install PCRE2:

for homebrew
export CXXFLAGS=${CXXFLAGS}:/usr/local/include
homebrew
brew install pcre2

or macport
export CXXFLAGS=${CXXFLAGS}:/opt/local/include
or macports
sudo port install pcre2

Or for MSVC copy pcre.lib and pcre.h in /externals directory.
The Makefile uses pcre2-config to find the include and library paths.
2 changes: 1 addition & 1 deletion cli/cmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2132,7 +2132,7 @@ void CmdLineParser::printHelp() const
"Many thanks to the 3rd party libraries we use:\n"
" * tinyxml2 -- loading project/library/ctu files.\n"
" * picojson -- loading compile database.\n"
" * pcre -- rules.\n"
" * pcre2 -- rules.\n"
" * qt -- used in GUI\n";

mLogger.printRaw(oss.str());
Expand Down
6 changes: 3 additions & 3 deletions cmake/findDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ if(BUILD_GUI)
endif()

if(HAVE_RULES)
find_path(PCRE_INCLUDE pcre.h)
find_library(PCRE_LIBRARY NAMES pcre pcred)
find_path(PCRE_INCLUDE pcre2.h)
find_library(PCRE_LIBRARY NAMES pcre2-8 pcre2-8d pcre2-8-static pcre2-8-staticd)
if(NOT PCRE_LIBRARY OR NOT PCRE_INCLUDE)
message(FATAL_ERROR "pcre dependency for RULES has not been found")
message(FATAL_ERROR "pcre2 dependency for RULES has not been found")
endif()
else()
set(PCRE_LIBRARY "")
Expand Down
2 changes: 1 addition & 1 deletion cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ if(NOT BUILD_GUI)
endif()
endif()

option(HAVE_RULES "Usage of rules (needs PCRE library and headers)" OFF)
option(HAVE_RULES "Usage of rules (needs PCRE2 library and headers)" OFF)
option(USE_BUNDLED_TINYXML2 "Usage of bundled TinyXML2 library" ON)
if(BUILD_CORE_DLL AND NOT USE_BUNDLED_TINYXML2)
message(FATAL_ERROR "Cannot use external TinyXML2 library when building lib as DLL")
Expand Down
12 changes: 0 additions & 12 deletions externals/pcre.patch

This file was deleted.

Loading
Loading