From dab8c9aac96063ccb8541d5d1795ee89b75faeee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Wed, 2 Apr 2025 11:50:24 -0700 Subject: [PATCH 17/18] build: link to libpcre2 explicitly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Organization: Wires This is apparently a problem on Mac OS X builds where the transitive dependency via libyang doesn't take effect: Undefined symbols for architecture arm64: "_pcre2_code_free_8", referenced from: libyang::Regex::~Regex() in Regex.cpp.o libyang::Regex::~Regex() in Regex.cpp.o ld: symbol(s) not found for architecture arm64 Let's fix this by linking with libpcre2-8 directly. We're using a different approach than libyang; they have their own CMake wrapper. I find it easier to work with pkg-config modules, so let's try it that way. Change-Id: I1a64407d852161595b7dca654433190002cc3600 Signed-off-by: Mattias Walström --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c5fec45..4e009aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,9 @@ pkg_check_modules(LIBYANG REQUIRED libyang>=3.10.1 IMPORTED_TARGET) # FIXME from gcc 14.1 on we should be able to use the calendar/time from libstdc++ and thus remove the date dependency find_package(date) +# libyang::Regex::~Regex() bypasses libyang and calls out to libpcre directly +pkg_check_modules(LIBPCRE2 REQUIRED libpcre2-8 IMPORTED_TARGET) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) include(CheckIncludeFileCXX) @@ -64,7 +67,7 @@ add_library(yang-cpp src/utils/newPath.cpp ) -target_link_libraries(yang-cpp PRIVATE PkgConfig::LIBYANG) +target_link_libraries(yang-cpp PRIVATE PkgConfig::LIBYANG PkgConfig::LIBPCRE2) # We do not offer any long-term API/ABI guarantees. To make stuff easier for downstream consumers, # we will be bumping both API and ABI versions very deliberately. # There will be no attempts at semver tracking, for example. -- 2.43.0