Fix macOS build: drop Boost::system/find_package component, use std::filesystem

Homebrew's boost formula doesn't ship the boost_system CMake config file,
so find_package(Boost REQUIRED COMPONENTS system) failed on macOS.

- Replace boost::filesystem with std::filesystem (C++17, no Boost dep)
- Drop 'filesystem' from find_package — only headers needed (asio + system)
- Link libboost_system explicitly per-platform by library name, resolved
  via the platform's default search path (Homebrew toolchain on macOS,
  system libs on Linux, MSYS2 on Windows)

CI will rerun automatically on PR push.
This commit is contained in:
Krystie
2026-06-18 18:41:38 -07:00
parent 8aeb5133bf
commit 1d938d5770
2 changed files with 19 additions and 7 deletions
+17 -4
View File
@@ -258,14 +258,20 @@ if(BUILD_CLI)
add_executable(triangles-cli
triangles-cli.cpp
)
# Boost components used by the CLI
find_package(Boost REQUIRED COMPONENTS filesystem system)
# 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.
find_package(Boost REQUIRED)
target_link_libraries(triangles-cli
PRIVATE
json_compat
Boost::filesystem
Boost::system
)
if(UNIX AND NOT APPLE)
# Linux: explicit link to libboost_system (header-only Boost.System
# is rare; we explicitly link the small compiled library).
target_link_libraries(triangles-cli PRIVATE boost_system)
endif()
if(WIN32)
set_target_properties(triangles-cli PROPERTIES SUFFIX ".exe")
@@ -273,6 +279,13 @@ 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"
+2 -3
View File
@@ -41,8 +41,7 @@
#include <boost/asio.hpp>
#include <boost/asio/streambuf.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <filesystem>
#include <algorithm>
#include <cstdint>
@@ -62,7 +61,7 @@
using namespace std;
namespace asio = boost::asio;
using boost::asio::ip::tcp;
namespace fs = boost::filesystem;
namespace fs = std::filesystem;
using namespace json_spirit;
// ─────────────────────────────────────────────────────────────────────────────