cmake: Fix NetBSD-specific workaround for Boost
What changed, and why it matters
This is a small build-system fix for Bitcoin Core on NetBSD. It narrows an existing workaround so it only applies when Boost is installed under /usr/pkg (the standard NetBSD pkgsrc location). Previously, the workaround could set incorrect include paths on NetBSD systems where Boost was installed elsewhere, potentially breaking compilation. There is no indication this affects runtime security or allows attacks.
No security action required. Treat as a normal build-system bugfix. If building on NetBSD with non-pkgsrc Boost, verify compilation succeeds after this change.
Security signals we found
No security-relevant code paths modified
Build-system-only change
No memory safety, cryptography, consensus, or networking changes
No disclosure of vulnerability or security issue in commit message
Evidence from the diff
The commit modifies cmake/module/AddBoostIfNeeded.cmake. The original NetBSD pkgsrc workaround unconditionally rewrote Boost::headers INTERFACE_INCLUDE_DIRECTORIES based on boost_headers_DIR. The patch adds a guard so the override only happens when the computed path starts with /usr/pkg/. This prevents the workaround from clobbering correct include directories on NetBSD systems using non-pkgsrc Boost installations. The change is purely a build-configuration correction.
Changed components
cmake/module/AddBoostIfNeeded.cmakeInspect captured patch +6 / −4
diff --git a/cmake/module/AddBoostIfNeeded.cmake b/cmake/module/AddBoostIfNeeded.cmake
index b3f24800..80a6d2e8 100644
--- a/cmake/module/AddBoostIfNeeded.cmake
+++ b/cmake/module/AddBoostIfNeeded.cmake
@@ -32,12 +32,14 @@ function(add_boost_if_needed)
find_package(Boost 1.74.0 REQUIRED CONFIG)
mark_as_advanced(Boost_INCLUDE_DIR boost_headers_DIR)
# Workaround for a bug in NetBSD pkgsrc.
- # See: https://github.com/NetBSD/pkgsrc/issues/167.
+ # See https://gnats.netbsd.org/59856.
if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
get_filename_component(_boost_include_dir "${boost_headers_DIR}/../../../include/" ABSOLUTE)
- set_target_properties(Boost::headers PROPERTIES
- INTERFACE_INCLUDE_DIRECTORIES ${_boost_include_dir}
- )
+ if(_boost_include_dir MATCHES "^/usr/pkg/")
+ set_target_properties(Boost::headers PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES ${_boost_include_dir}
+ )
+ endif()
unset(_boost_include_dir)
endif()
set_target_properties(Boost::headers PROPERTIES IMPORTED_GLOBAL TRUE)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.