build(cmake): fix for boost 1.89

This commit is contained in:
ReenigneArcher 2025-09-13 11:32:38 -04:00
commit 546895a93a
No known key found for this signature in database
GPG key ID: EDADC7ED0375AAE9

View file

@ -41,8 +41,20 @@ if(USE_STANDALONE_ASIO)
target_include_directories(simple-web-server SYSTEM INTERFACE ${ASIO_PATH})
endif()
else()
find_package(Boost 1.53.0 COMPONENTS system REQUIRED)
target_link_libraries(simple-web-server INTERFACE Boost::boost Boost::system)
# In Boost 1.89.0+, system is header-only, so we try to find it but make it optional
find_package(Boost 1.53.0 COMPONENTS system)
if(NOT Boost_FOUND)
# Fallback: try without system component for newer Boost versions where it's header-only
find_package(Boost 1.53.0 REQUIRED)
endif()
target_link_libraries(simple-web-server INTERFACE Boost::boost)
# Only link Boost::system if the target exists (for older Boost < 1.89)
if(TARGET Boost::system)
target_link_libraries(simple-web-server INTERFACE Boost::system)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
target_compile_definitions(simple-web-server INTERFACE USE_BOOST_REGEX)
find_package(Boost 1.53.0 COMPONENTS regex REQUIRED)