Simplified building and using PCRE2 in a cmake context
- CMake 82.2%
- C++ 17.8%
| test | ||
| .clang-format | ||
| .gitignore | ||
| CMakeLists.txt | ||
| pcre2s-config.cmake.in | ||
| README.md | ||
PCRE2 for cmake users
This CMakeLists.txt file contains all you need to embed pcre2 into your own cmake based project.
The original code of pcre2 comes with cmake files, but they do not work as expected, at least not for me. I tried many options to work around this but in the end, this is what works for me.
Usage
The regular steps for installing cmake based libraries:
git clone https://forge.hekkelman.net/maarten/pcre2s
cd pcre2s
cmake -B build
cmake --build build
sudo cmake --install build
Then, use it like this
find_package(pcre2s REQUIRED)
add_executable(use-pcre2s ${CMAKE_CURRENT_SOURCE_DIR}/use-pcre2s.c)
target_link_libraries(use-pcre2s PRIVATE pcre2s::pcre2)
Of course, using CPM makes life even easier.