Skip to content

Commit dab8c9a

Browse files
committed
build: link to libpcre2 explicitly
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
1 parent 8c59ecc commit dab8c9a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ pkg_check_modules(LIBYANG REQUIRED libyang>=3.10.1 IMPORTED_TARGET)
3434
# FIXME from gcc 14.1 on we should be able to use the calendar/time from libstdc++ and thus remove the date dependency
3535
find_package(date)
3636

37+
# libyang::Regex::~Regex() bypasses libyang and calls out to libpcre directly
38+
pkg_check_modules(LIBPCRE2 REQUIRED libpcre2-8 IMPORTED_TARGET)
39+
3740
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
3841

3942
include(CheckIncludeFileCXX)
@@ -64,7 +67,7 @@ add_library(yang-cpp
6467
src/utils/newPath.cpp
6568
)
6669

67-
target_link_libraries(yang-cpp PRIVATE PkgConfig::LIBYANG)
70+
target_link_libraries(yang-cpp PRIVATE PkgConfig::LIBYANG PkgConfig::LIBPCRE2)
6871
# We do not offer any long-term API/ABI guarantees. To make stuff easier for downstream consumers,
6972
# we will be bumping both API and ABI versions very deliberately.
7073
# There will be no attempts at semver tracking, for example.

0 commit comments

Comments
 (0)