-- On FreeBSD, backtrace() and backtrace_symbols() are in libexecinfo (not libc).
-- Add -lexecinfo to all linker flags so targets linking against libcommon (which
-- calls backtrace in enforce.cc) resolve these symbols at link time.
--- CMakeLists.txt.orig	2026-06-19 19:12:26 UTC
+++ CMakeLists.txt
@@ -278,6 +278,12 @@ else()
   set(CMAKE_CXX_FLAGS
       "${CMAKE_CXX_FLAGS} -Wno-error=deprecated-declarations -Wno-deprecated-declarations"
   )
+  if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
+    # backtrace/backtrace_symbols are in libexecinfo on FreeBSD (not in libc)
+    foreach(flag_var CMAKE_SHARED_LINKER_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS)
+      set(${flag_var} "${${flag_var}} -lexecinfo")
+    endforeach()
+  endif()
 endif()
 
 find_package(Threads REQUIRED)
