Backported from: https://github.com/apngasm/apngasm/pull/111
Manually fixed up for differences in lib/CMakeLists.txt due to
our dynamic linking patch.

From: Michael Cho <michael@michaelcho.dev>
Date: Sun, 10 Aug 2025 19:23:29 -0400
Subject: [PATCH] Fix build with Boost 1.89.0

--- a/cli/CMakeLists.txt
+++ b/cli/CMakeLists.txt
@@ -34,7 +34,7 @@ endif ()
 if (APPLE OR WIN32)
   set(Boost_USE_STATIC_LIBS ON)
 endif ()
-find_package(Boost REQUIRED COMPONENTS program_options regex system)
+find_package(Boost REQUIRED COMPONENTS program_options regex OPTIONAL_COMPONENTS system)
 include_directories(${Boost_INCLUDE_DIRS})
 
 # Generate executable
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -71,9 +71,9 @@ target_link_libraries(${APNGASM_STATIC_LIB_TARGET} ${ZLIB_LIBRARIES})
 #endif ()
 #set(Boost_USE_STATIC_LIBS OFF)
 #SET(CMAKE_FIND_LIBRARY_SUFFIXES .dll.a .a .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
-find_package(Boost REQUIRED COMPONENTS program_options regex system)
+find_package(Boost REQUIRED COMPONENTS program_options regex OPTIONAL_COMPONENTS system)
 include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
-target_link_libraries(${APNGASM_DYNAMIC_LIB_TARGET} Boost::program_options Boost::regex Boost::system)
+target_link_libraries(${APNGASM_DYNAMIC_LIB_TARGET} ${Boost_LIBRARIES})
 
 get_target_property(APNGASM_DYNAMIC_LIB_TARGET_NAME ${APNGASM_DYNAMIC_LIB_TARGET} OUTPUT_NAME)
 set(APNGASM_LIBRARIES
