Fix macOS build: add Boost::boost target for headers, link boost_system

The previous fix dropped the find_package component but also killed the
boost include path. Now use the modern Boost::boost header-only target
(available in Boost 1.83+) which sets up include directories without
requiring a per-component config file.

Link libboost_system explicitly by name on all platforms — the linker
finds it via the platform's default search path:
- Linux: /usr/lib (libboost_system.so)
- macOS Homebrew: /opt/homebrew/lib (libboost_system.dylib)
- Windows MSYS2: mingw64/bin (libboost_system-mt-X-XX.dll)
This commit is contained in:
Krystie
2026-06-18 18:45:04 -07:00
parent 1d938d5770
commit 600b1cf35f
+9 -14
View File
@@ -258,18 +258,20 @@ if(BUILD_CLI)
add_executable(triangles-cli
triangles-cli.cpp
)
# Boost: only need headers for asio + system. Boost::system gets resolved at
# link time via the platform's default library search path (libboost_system
# on Linux, libboost_system.dylib on macOS Homebrew, libboost_system-mt-*.dll
# on Windows MSYS2). Avoids needing a per-component CMake config file.
# Boost: header-only asio via Boost::boost target (sets include dirs;
# available in Boost 1.83+). libboost_system is the small compiled
# library that provides error_code/error_category symbols; link it
# explicitly by name to avoid needing the per-component CMake config
# file (which Homebrew's boost formula doesn't ship for the system
# component on macOS).
find_package(Boost REQUIRED)
target_link_libraries(triangles-cli
PRIVATE
json_compat
Boost::boost
)
if(UNIX AND NOT APPLE)
# Linux: explicit link to libboost_system (header-only Boost.System
# is rare; we explicitly link the small compiled library).
# Link libboost_system per-platform by library name
if(UNIX OR WIN32)
target_link_libraries(triangles-cli PRIVATE boost_system)
endif()
@@ -279,13 +281,6 @@ if(BUILD_CLI)
target_link_libraries(triangles-cli PRIVATE ws2_32)
endif()
if(APPLE)
# macOS Homebrew ships libboost_system.dylib without a CMake config
# file, so link by library name (resolved via Homebrew's compiler
# toolchain search paths).
target_link_libraries(triangles-cli PRIVATE boost_system)
endif()
if(MSVC)
set_target_properties(triangles-cli PROPERTIES
VS_WINRT_COMPONENT "console"