r3/CMakeLists.txt
Björn Svensson c105117b40
Use PCRE2 instead of PCRE (#153)
PCRE is now at end of life and is no longer actively maintained.
Lift the dependency to the next major version, i.e. PCRE2.

Implementation notes:
- Removed the pcre study option since:
  "The new API ... was simplified by abolishing the separate "study" optimizing
  function; in PCRE2, patterns are automatically optimized where possible."
- If asprintf() fails the content of the 'strp' variable is undefined.
  Lets check the return value and return NULL upon error.
- Pattern and subject can straightforwardly be cast to PCRE2_SPTR since we
  only work with 8-bit code units.
2023-10-23 12:38:24 +02:00

49 lines
1.2 KiB
CMake

cmake_minimum_required(VERSION 3.0)
project(r3 VERSION 2.0.0)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
set(CMAKE_C_STANDARD 99)
find_package(Check)
find_package(PCRE2 REQUIRED)
include(CheckSymbolExists)
include(CheckIncludeFile)
check_symbol_exists(strdup string.h HAVE_STRDUP)
check_symbol_exists(strndup string.h HAVE_STRNDUP)
check_include_file(stdbool.h HAVE_STDBOOL_H)
configure_file(config.h.cmake config.h)
add_subdirectory(src)
install(
FILES
include/memory.h
include/r3.h
include/r3_list.h
include/r3_slug.h
include/r3_gvc.h
include/r3_json.h
include/str_array.h
include/r3.hpp
DESTINATION include)
# Configure substitutions for r3.pc. The variables set here must match the
# @<values>@ in r3.pc.in.
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${prefix})
set(includedir ${prefix}/include)
set(libdir ${prefix}/lib)
set(PACKAGE_VERSION ${PROJECT_VERSION})
configure_file(r3.pc.in r3.pc @ONLY)
install(
FILES
${PROJECT_BINARY_DIR}/r3.pc
DESTINATION lib/pkgconfig)
if(CHECK_FOUND)
enable_testing()
add_subdirectory(tests)
else()
message(STATUS "Skipping unit tests, Check library not found!")
endif()