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:
+9
-14
@@ -258,18 +258,20 @@ if(BUILD_CLI)
|
|||||||
add_executable(triangles-cli
|
add_executable(triangles-cli
|
||||||
triangles-cli.cpp
|
triangles-cli.cpp
|
||||||
)
|
)
|
||||||
# Boost: only need headers for asio + system. Boost::system gets resolved at
|
# Boost: header-only asio via Boost::boost target (sets include dirs;
|
||||||
# link time via the platform's default library search path (libboost_system
|
# available in Boost 1.83+). libboost_system is the small compiled
|
||||||
# on Linux, libboost_system.dylib on macOS Homebrew, libboost_system-mt-*.dll
|
# library that provides error_code/error_category symbols; link it
|
||||||
# on Windows MSYS2). Avoids needing a per-component CMake config file.
|
# 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)
|
find_package(Boost REQUIRED)
|
||||||
target_link_libraries(triangles-cli
|
target_link_libraries(triangles-cli
|
||||||
PRIVATE
|
PRIVATE
|
||||||
json_compat
|
json_compat
|
||||||
|
Boost::boost
|
||||||
)
|
)
|
||||||
if(UNIX AND NOT APPLE)
|
# Link libboost_system per-platform by library name
|
||||||
# Linux: explicit link to libboost_system (header-only Boost.System
|
if(UNIX OR WIN32)
|
||||||
# is rare; we explicitly link the small compiled library).
|
|
||||||
target_link_libraries(triangles-cli PRIVATE boost_system)
|
target_link_libraries(triangles-cli PRIVATE boost_system)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -279,13 +281,6 @@ if(BUILD_CLI)
|
|||||||
target_link_libraries(triangles-cli PRIVATE ws2_32)
|
target_link_libraries(triangles-cli PRIVATE ws2_32)
|
||||||
endif()
|
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)
|
if(MSVC)
|
||||||
set_target_properties(triangles-cli PROPERTIES
|
set_target_properties(triangles-cli PROPERTIES
|
||||||
VS_WINRT_COMPONENT "console"
|
VS_WINRT_COMPONENT "console"
|
||||||
|
|||||||
Reference in New Issue
Block a user