From 54bdd6a69c47d4015022ead33d98b21948273257 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcin=20P=C4=85czkowski?= <dyfeer@gmail.com>
Date: Wed, 27 Aug 2025 17:59:08 -0700
Subject: [PATCH] [build] Update Boost integration

---
 CMakeLists.txt                            | 49 +++++----------
 editors/sc-ide/CMakeLists.txt             |  3 -
 editors/sc-ide/core/sc_server.cpp         |  2 -
 editors/sc-ide/core/sc_server.hpp         |  1 -
 external_libraries/CMakeLists.txt         | 73 +++++++++++++++--------
 external_libraries/nova-tt                |  2 +-
 lang/CMakeLists.txt                       |  5 +-
 lang/LangSource/PyrInterpreter3.cpp       |  2 -
 server/CMakeLists.txt                     |  1 -
 server/plugins/CMakeLists.txt             | 31 +++++-----
 server/scsynth/CMakeLists.txt             |  5 +-
 server/supernova/CMakeLists.txt           |  7 +--
 testsuite/server/CMakeLists.txt           |  2 +-
 testsuite/server/supernova/CMakeLists.txt |  2 +-
 14 files changed, 87 insertions(+), 98 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1ac592a857f..ee251862cc4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -123,16 +123,8 @@ endif()

 if(WIN32)
     add_definitions(-DWIN32_LEAN_AND_MEAN -DNOMINMAX -D_WIN32_WINNT=0x0600)
-
-    #avoid unnecesary autolink
-    add_definitions(-DBOOST_DATE_TIME_NO_LIB -DBOOST_ALL_NO_LIB)
-
-    # use session manager to set shared memory location, see issue 2409
-    add_definitions(-DBOOST_INTERPROCESS_BOOTSTAMP_IS_SESSION_MANAGER_BASED)
 endif()

-add_definitions(-DBOOST_CHRONO_HEADER_ONLY -DBOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE)
-

 #############################################
 # Options
@@ -315,36 +307,25 @@ if (NOT WIN32)
 endif()

 if(SYSTEM_BOOST)
-    # https://github.com/supercollider/supercollider/issues/4576#issuecomment-531499017
-    # Boost >= 1.71 ships with its own Boost config file, we ignore it for now.
-    set(Boost_NO_BOOST_CMAKE ON)
+    if(POLICY CMP0167)
+        cmake_policy(SET CMP0167 NEW)
+    endif()
     set(Boost_USE_MULTITHREADED ON)
-    find_package( Boost 1.50.0 COMPONENTS  thread system filesystem program_options regex test_exec_monitor )
+    find_package(Boost 1.70.0 REQUIRED COMPONENTS thread program_options regex unit_test_framework)
     if (Boost_FOUND)
-        # we're specifically setting up the boost libraries here, so we can
-        # name them
-        add_library(boost_thread_lib SHARED IMPORTED)
-        set_property(TARGET boost_thread_lib PROPERTY IMPORTED_LOCATION
-          ${Boost_THREAD_LIBRARY})
-        add_library(boost_system_lib SHARED IMPORTED)
-        set_property(TARGET boost_system_lib PROPERTY IMPORTED_LOCATION
-          ${Boost_SYSTEM_LIBRARY})
-        add_library(boost_program_options_lib SHARED IMPORTED)
-        set_property(TARGET boost_program_options_lib PROPERTY
-          IMPORTED_LOCATION ${Boost_PROGRAM_OPTIONS_LIBRARY})
-        add_library(boost_regex_lib SHARED IMPORTED)
-        set_property(TARGET boost_regex_lib PROPERTY IMPORTED_LOCATION
-          ${Boost_REGEX_LIBRARY})
-        add_library(boost_test_exec_monitor_lib SHARED IMPORTED)
-        set_property(TARGET boost_test_exec_monitor_lib PROPERTY
-          IMPORTED_LOCATION ${Boost_TEST_EXEC_MONITOR_LIBRARY})
-        set(boost_include_dirs ${Boost_INCLUDE_DIRS})
-    else()
-        message(FATAL_ERROR "Not able to use system boost because none was found.")
+        message(STATUS "Found system Boost in ${Boost_INCLUDE_DIRS}")
     endif()
 else()
-    set(boost_include_dirs ${CMAKE_SOURCE_DIR}/external_libraries/boost)
-endif()
+	# bundled boost is set up in external_libraries/CMakeLists.txt
+	# here we just set some global definitions
+	if(WIN32)
+		#avoid unnecesary autolink
+		add_definitions(-DBOOST_DATE_TIME_NO_LIB -DBOOST_ALL_NO_LIB)
+		# use session manager to set shared memory location, see issue 2409
+		add_definitions(-DBOOST_INTERPROCESS_BOOTSTAMP_IS_SESSION_MANAGER_BASED)
+	endif()
+	add_definitions(-DBOOST_CHRONO_HEADER_ONLY -DBOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE)
+endif()

 if(SYSTEM_YAMLCPP)
   find_package(YamlCpp)
diff --git a/editors/sc-ide/CMakeLists.txt b/editors/sc-ide/CMakeLists.txt
index 1dfddcac2de..df40bce6e08 100644
--- a/editors/sc-ide/CMakeLists.txt
+++ b/editors/sc-ide/CMakeLists.txt
@@ -338,9 +338,6 @@ target_link_libraries( libscide PUBLIC

 target_link_libraries( SuperCollider libscide)

-target_link_libraries( libscide PUBLIC boost_system_lib)
-include_directories(${boost_include_dirs})
-
 # This makes sclang/scide work with a Qt installation at a fixed location.
 set_property(TARGET libscide SuperCollider PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)

diff --git a/editors/sc-ide/core/sc_server.cpp b/editors/sc-ide/core/sc_server.cpp
index 9f677f5134d..00297c604a6 100644
--- a/editors/sc-ide/core/sc_server.cpp
+++ b/editors/sc-ide/core/sc_server.cpp
@@ -30,12 +30,10 @@

 #include <sstream>
 #include <iomanip>
-#include <boost/chrono/chrono_io.hpp>
 #include <osc/OscReceivedElements.h>
 #include <osc/OscOutboundPacketStream.h>

 using namespace std;
-using namespace boost::chrono;

 namespace ScIDE {

diff --git a/editors/sc-ide/core/sc_server.hpp b/editors/sc-ide/core/sc_server.hpp
index 1dd666c67fd..661a460eb49 100644
--- a/editors/sc-ide/core/sc_server.hpp
+++ b/editors/sc-ide/core/sc_server.hpp
@@ -25,7 +25,6 @@
 #include <QAction>
 #include <QProcess>
 #include <QTimer>
-#include <boost/chrono/system_clocks.hpp>
 #include <osc/OscReceivedElements.h>

 namespace ScIDE {
diff --git a/external_libraries/CMakeLists.txt b/external_libraries/CMakeLists.txt
index de464976866..72525f0421c 100644
--- a/external_libraries/CMakeLists.txt
+++ b/external_libraries/CMakeLists.txt
@@ -13,44 +13,31 @@ endif()

 if(NOT SYSTEM_BOOST) # we compile boost ourselves
 	message(STATUS "Using bundled boost")
-	# boost thread
-	aux_source_directory(boost/libs/thread/src/ boost_thread_src )
+	set(BOOST_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/boost)
+
+	# thread
+	aux_source_directory(boost/libs/thread/src/ boost_thread_src)

 	if(WIN32)
-		aux_source_directory(boost/libs/thread/src/win32/ boost_thread_platform )
+		aux_source_directory(boost/libs/thread/src/win32/ boost_thread_platform)
 	elseif(PTHREADS_FOUND)
-		aux_source_directory(boost/libs/thread/src/pthread/ boost_thread_platform )
+		aux_source_directory(boost/libs/thread/src/pthread/ boost_thread_platform)
 	else()
 		message(SEND_ERROR "we need to implement boost_thread")
 	endif()

-	aux_source_directory(boost/libs/system/src/ boost_system_src )
-	add_library(boost_system_lib STATIC EXCLUDE_FROM_ALL ${boost_system_src})
-	target_include_directories(boost_system_lib PUBLIC boost)
-
-	aux_source_directory(boost/libs/program_options/src/ boost_program_options_src )
-	add_library(boost_program_options_lib STATIC EXCLUDE_FROM_ALL ${boost_program_options_src})
-	target_include_directories(boost_program_options_lib PUBLIC boost)
-
-
-	aux_source_directory(boost/libs/regex/src boost_regex_src)
-	add_library(boost_regex_lib STATIC EXCLUDE_FROM_ALL ${boost_regex_src})
-	target_include_directories(boost_regex_lib PUBLIC boost)
-
 	add_library(boost_thread_lib STATIC EXCLUDE_FROM_ALL ${boost_thread_src} ${boost_thread_platform})
-	target_link_libraries(boost_thread_lib boost_system_lib)
-#	target_compile_definitions(boost_thread PUBLIC BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS)
-	target_include_directories(boost_thread_lib PUBLIC boost)
-	target_compile_definitions(boost_thread_lib PUBLIC BOOST_THREAD_USE_LIB) # for win32
+	target_include_directories(boost_thread_lib PUBLIC ${BOOST_INCLUDE_DIR})

 	if(PTHREADS_FOUND)
 		target_include_directories(boost_thread_lib PUBLIC ${PTHREADS_INCLUDE_DIR})
 	endif()
+
 	if(WIN32)
-		target_compile_definitions( boost_thread_lib PRIVATE BOOST_THREAD_BUILD_LIB)
+		target_compile_definitions(boost_thread_lib PUBLIC BOOST_THREAD_USE_LIB)
+		target_compile_definitions(boost_thread_lib PRIVATE BOOST_THREAD_BUILD_LIB)
 	endif()

-
 	if(CMAKE_SYSTEM_NAME MATCHES "Linux")
 		target_compile_options(boost_thread_lib PRIVATE -fPIC)
 		target_link_libraries(boost_thread_lib rt)
@@ -64,15 +51,51 @@ if(NOT SYSTEM_BOOST) # we compile boost ourselves
 			APPEND PROPERTY LINK_FLAGS "-flto -flto-report")
 	endif()

+	# program_options
+	aux_source_directory(boost/libs/program_options/src/ boost_program_options_src )
+	add_library(boost_program_options_lib STATIC EXCLUDE_FROM_ALL ${boost_program_options_src})
+	target_include_directories(boost_program_options_lib PUBLIC ${BOOST_INCLUDE_DIR})
+
+	# regex
+	aux_source_directory(boost/libs/regex/src boost_regex_src)
+	add_library(boost_regex_lib STATIC EXCLUDE_FROM_ALL ${boost_regex_src})
+	target_include_directories(boost_regex_lib PUBLIC ${BOOST_INCLUDE_DIR})
+
+	# unit_test_framework
+	aux_source_directory(boost/libs/test/src boost_unit_test_framework_src)
+	add_library(boost_unit_test_framework_lib STATIC EXCLUDE_FROM_ALL ${boost_unit_test_framework_src})
+	target_include_directories(boost_unit_test_framework_lib PUBLIC ${BOOST_INCLUDE_DIR})
+
+	# headers
+	add_library(boost_headers INTERFACE)
+	target_include_directories(boost_headers INTERFACE ${BOOST_INCLUDE_DIR})
+
 	set_property( TARGET
         boost_regex_lib
         boost_thread_lib
         boost_program_options_lib
-        boost_system_lib
+        boost_unit_test_framework_lib
         PROPERTY FOLDER 3rdparty
     )
+
+    # add aliases for compliance with system boost
+    add_library(Boost::thread ALIAS boost_thread_lib)
+    add_library(Boost::program_options ALIAS boost_program_options_lib)
+    add_library(Boost::regex ALIAS boost_regex_lib)
+    add_library(Boost::unit_test_framework ALIAS boost_unit_test_framework_lib)
+    add_library(Boost::headers ALIAS boost_headers)
+
 endif()

+# add a custom target for boost_sync
+add_library(boost_sync INTERFACE)
+target_include_directories(boost_sync INTERFACE
+    ${CMAKE_CURRENT_SOURCE_DIR}/boost_sync/include
+)
+# Boost::headers comes from either system or bundled boost
+target_link_libraries(boost_sync INTERFACE Boost::headers)
+add_library(Boost::sync ALIAS boost_sync)
+
 # tlsf
 add_library(tlsf STATIC EXCLUDE_FROM_ALL "TLSF-2.4.6/src/tlsf.c")
 target_compile_definitions( tlsf PRIVATE TLSF_STATISTIC=1 )
@@ -81,7 +104,7 @@ set_property(TARGET tlsf PROPERTY POSITION_INDEPENDENT_CODE TRUE)

 #oscpack
 add_library(oscpack STATIC EXCLUDE_FROM_ALL "oscpack_build.cpp")
-target_include_directories(oscpack PRIVATE ${boost_include_dirs})
+target_link_libraries(oscpack PUBLIC Boost::headers)
 target_include_directories(oscpack INTERFACE oscpack_1_1_0 )

 if(LTO)
diff --git a/lang/CMakeLists.txt b/lang/CMakeLists.txt
index 561023da45f..444e894b0e8 100644
--- a/lang/CMakeLists.txt
+++ b/lang/CMakeLists.txt
@@ -5,8 +5,6 @@ include_directories(${CMAKE_SOURCE_DIR}/include/common
                     ${CMAKE_SOURCE_DIR}/include/server
                     ${CMAKE_SOURCE_DIR}/common

-                    ${CMAKE_SOURCE_DIR}/external_libraries/boost_sync/include
-
                     LangSource
                     LangPrimSource

@@ -244,8 +242,7 @@ if(SC_HIDAPI)
   endif()
 endif()

-target_link_libraries(libsclang boost_thread_lib boost_system_lib boost_regex_lib boost_program_options_lib)
-target_include_directories(libsclang PUBLIC ${boost_include_dirs})
+target_link_libraries(libsclang Boost::thread Boost::program_options Boost::regex Boost::sync)

 if (SCLANG_SERVER)
 	target_link_libraries(libsclang libscsynth)
diff --git a/lang/LangSource/PyrInterpreter3.cpp b/lang/LangSource/PyrInterpreter3.cpp
index 6393c5cb59c..b8483d24700 100644
--- a/lang/LangSource/PyrInterpreter3.cpp
+++ b/lang/LangSource/PyrInterpreter3.cpp
@@ -39,8 +39,6 @@
 #include <string.h>
 #include <signal.h>

-#include <boost/chrono.hpp>
-
 #include <float.h>
 #define kBigBigFloat DBL_MAX
 #define kSmallSmallFloat DBL_MIN
diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt
index 05b72d9228d..fb910c7fc38 100644
--- a/server/CMakeLists.txt
+++ b/server/CMakeLists.txt
@@ -13,7 +13,6 @@ include_directories(${CMAKE_SOURCE_DIR}/external_libraries
 					${CMAKE_SOURCE_DIR}/external_libraries/nova-tt
 					)

-include_directories(${boost_include_dirs})

 add_subdirectory(plugins)
 add_subdirectory(scsynth)
diff --git a/server/plugins/CMakeLists.txt b/server/plugins/CMakeLists.txt
index 171dfb68685..82d25080ed7 100644
--- a/server/plugins/CMakeLists.txt
+++ b/server/plugins/CMakeLists.txt
@@ -66,7 +66,8 @@ endif()

 foreach(plugin ${plugin_sources})
 	string(REPLACE .cpp "" plugin_name ${plugin} )
-		add_library(${plugin_name} MODULE ${plugin})
+	add_library(${plugin_name} MODULE ${plugin})
+	target_link_libraries(${plugin_name} PRIVATE Boost::headers)
 	list(APPEND plugins ${plugin_name})
 endforeach(plugin)

@@ -90,7 +91,7 @@ if(BELA_FOUND)
     )
     add_definitions("-DSC_BELA" ${XENOMAI_DEFINITIONS} ${BELA_DEFINITIONS})
     include_directories(${XENOMAI_INCLUDE_DIRS} ${BELA_INCLUDE_DIRS})
-    target_link_libraries(BelaUGens ${XENOMAI_LIBRARIES} ${BELA_LIBRARIES})
+    target_link_libraries(BelaUGens PRIVATE ${XENOMAI_LIBRARIES} ${BELA_LIBRARIES})

     list(APPEND plugins BelaUGens)
 endif()
@@ -100,7 +101,7 @@ if(NOT NO_X11)
 		add_library(UIUGens MODULE UIUGens.mm)
 	else()
 		add_library(UIUGens MODULE UIUGens.cpp)
-		target_link_libraries(UIUGens ${PTHREADS_LIBRARY})
+		target_link_libraries(UIUGens PRIVATE ${PTHREADS_LIBRARY})
 	endif()

 	set(uiugens UIUGens)
@@ -161,7 +162,7 @@ if(NOT NO_LIBSNDFILE)
 			target_compile_definitions(DiskIO_UGens PUBLIC SNDFILE_HAS_MPEG)
 		endif()
 		target_include_directories(DiskIO_UGens PUBLIC ${SNDFILE_INCLUDE_DIR})
-		target_link_libraries(DiskIO_UGens ${PTHREADS_LIBRARY} ${SNDFILE_LIBRARIES})
+		target_link_libraries(DiskIO_UGens PRIVATE ${PTHREADS_LIBRARY} ${SNDFILE_LIBRARIES})
 		list(APPEND plugins DiskIO_UGens)
 	else()
 		message(SEND_ERROR "Cannot find libsndfile")
@@ -179,6 +180,7 @@ if (SUPERNOVA)
 	foreach(plugin ${plugin_sources})
 		string(REPLACE .cpp "_supernova" plugin_name ${plugin} )
 		add_library(${plugin_name} MODULE ${plugin})
+		target_link_libraries(${plugin_name} PRIVATE Boost::headers)
 		list(APPEND supernova_plugins ${plugin_name})
 	endforeach(plugin)

@@ -221,7 +223,7 @@ if (SUPERNOVA)
 			add_library(UIUGens_supernova MODULE UIUGens.mm)
 		else()
 			add_library(UIUGens_supernova MODULE UIUGens.cpp)
-			target_link_libraries(UIUGens_supernova ${PTHREADS_LIBRARY})
+			target_link_libraries(UIUGens_supernova PRIVATE ${PTHREADS_LIBRARY})
 		endif()
 		list(APPEND uiugens UIUGens_supernova)
 	endif()
@@ -231,7 +233,7 @@ if (SUPERNOVA)

 		if(SNDFILE_FOUND)
 			target_include_directories(DiskIO_UGens_supernova PUBLIC ${SNDFILE_INCLUDE_DIR})
-      target_link_libraries(DiskIO_UGens_supernova ${SNDFILE_LIBRARIES} ${PTHREADS_LIBRARY} ${MATH_LIBRARY} boost_thread_lib)
+      target_link_libraries(DiskIO_UGens_supernova PRIVATE ${SNDFILE_LIBRARIES} ${PTHREADS_LIBRARY} ${MATH_LIBRARY} Boost::thread)
 			list(APPEND supernova_plugins DiskIO_UGens_supernova)
 		else()
 			message(SEND_ERROR "Cannot find libsndfile")
@@ -240,21 +242,22 @@ if (SUPERNOVA)
 endif(SUPERNOVA)

 foreach(ugen ${fft_ugens})
-	target_link_libraries(${ugen} ${PTHREADS_LIBRARY} ${MATH_LIBRARY})
+	target_link_libraries(${ugen} PRIVATE ${PTHREADS_LIBRARY} ${MATH_LIBRARY})

 	if(APPLE)
-		target_link_libraries(${ugen} "-framework Accelerate")
+		target_link_libraries(${ugen} PRIVATE "-framework Accelerate")
 	endif()
 endforeach()

 if(NOT NO_X11)
 	foreach(ugen ${uiugens})
-    target_link_libraries(${ugen} boost_thread_lib)
+    target_link_libraries(${ugen} PRIVATE Boost::thread)
 	endforeach()
 endif()

 foreach(plugin ${plugins})
+	target_link_libraries(${plugin} PRIVATE Boost::headers)
 	if(WIN32)
-		target_link_libraries(${plugin} wsock32 ws2_32)
+		target_link_libraries(${plugin} PRIVATE wsock32 ws2_32)
 	endif()
 endforeach()

@@ -271,7 +274,7 @@ foreach(plugin ${supernova_plugins})
 	target_compile_definitions(${plugin} PUBLIC SUPERNOVA)

 	if (WIN32)
-		target_link_libraries(${plugin} ws2_32)
+		target_link_libraries(${plugin} PRIVATE ws2_32)
 	endif()
 endforeach()

@@ -286,18 +289,18 @@ if(NOT NO_X11)
 		include_directories(${X11_Xt_INCLUDE_PATH})

 		foreach (ugen ${uiugens})
-			target_link_libraries(${ugen} ${X11_X11_LIB})
+			target_link_libraries(${ugen} PRIVATE ${X11_X11_LIB})
 		endforeach()
 	elseif (APPLE)
 		foreach (ugen ${uiugens})
-			target_link_libraries(${ugen} "-framework CoreServices -framework AppKit")
+			target_link_libraries(${ugen} PRIVATE "-framework CoreServices -framework AppKit")
 		endforeach()
 	endif()
 endif()

 if (APPLE)
 	if(NOT NO_LIBSNDFILE)
-		target_link_libraries(DiskIO_UGens "-framework CoreServices")
+		target_link_libraries(DiskIO_UGens PRIVATE "-framework CoreServices")
 	endif()
 endif()

diff --git a/server/scsynth/CMakeLists.txt b/server/scsynth/CMakeLists.txt
index 0edabde9db1..a176a502170 100644
--- a/server/scsynth/CMakeLists.txt
+++ b/server/scsynth/CMakeLists.txt
@@ -134,8 +134,6 @@ include_directories(${CMAKE_SOURCE_DIR}/include/common
                     .
 )

-include_directories (${CMAKE_SOURCE_DIR}/external_libraries/boost_sync/include)
-
 if (AUDIOAPI STREQUAL jack)
 	list(APPEND scsynth_sources SC_Jack.cpp)
 	add_definitions("-DSC_AUDIO_API=SC_AUDIO_API_JACK")
@@ -175,7 +173,7 @@ endif()

 target_compile_definitions(libscsynth PUBLIC  SC_MEMORY_ALIGNMENT=32)

-target_link_libraries(libscsynth tlsf)
+target_link_libraries(libscsynth tlsf Boost::sync)

 find_library(DL NAMES dl)
 if(DL)
@@ -235,7 +233,6 @@ elseif(AUDIOAPI STREQUAL coreaudio)
 	target_link_libraries(libscsynth "-framework CoreAudio")
 endif()

-target_include_directories(libscsynth PUBLIC ${boost_include_dirs})

 if (WIN32)
 	target_link_libraries(libscsynth wsock32 ws2_32 winmm)
diff --git a/server/supernova/CMakeLists.txt b/server/supernova/CMakeLists.txt
index 7fc9b0bbfa3..288bca8f463 100644
--- a/server/supernova/CMakeLists.txt
+++ b/server/supernova/CMakeLists.txt
@@ -93,7 +93,7 @@ if(NOT WIN32)
                PROPERTY OUTPUT_NAME supernova)
 endif()

-target_link_libraries(libsupernova oscpack tlsf ${PTHREADS_LIBRARIES} boost_thread_lib)
+target_link_libraries(libsupernova oscpack tlsf ${PTHREADS_LIBRARIES} Boost::thread Boost::sync)

 target_compile_definitions(libsupernova PUBLIC SUPERNOVA)
 target_include_directories(libsupernova PUBLIC
@@ -102,8 +102,6 @@ target_include_directories(libsupernova PUBLIC
                     ${CMAKE_SOURCE_DIR}/common
                     ${CMAKE_SOURCE_DIR}/include/server
                     ${CMAKE_SOURCE_DIR}/server/scsynth
-                    ${CMAKE_SOURCE_DIR}/external_libraries/boost_endian
-                    ${CMAKE_SOURCE_DIR}/external_libraries/boost_sync/include
                     ${CMAKE_SOURCE_DIR}/external_libraries/nova-tt
                     .
                     )
@@ -204,8 +202,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux")
     target_link_libraries(libsupernova rt)
 endif()

-target_link_libraries(libsupernova boost_system_lib boost_program_options_lib)
-target_include_directories(libsupernova PUBLIC ${boost_include_dirs})
+target_link_libraries(libsupernova Boost::program_options)

 if(CMAKE_COMPILER_IS_GNUCXX)
     if( ${_gcc_version} VERSION_GREATER 5 )
diff --git a/testsuite/server/CMakeLists.txt b/testsuite/server/CMakeLists.txt
index da19c2e5d62..853830b82da 100644
--- a/testsuite/server/CMakeLists.txt
+++ b/testsuite/server/CMakeLists.txt
@@ -1,5 +1,5 @@
 add_library(boost_test STATIC boost_test.cpp)
-target_include_directories(boost_test PUBLIC ${boost_include_dirs})
+target_link_libraries(boost_test PUBLIC Boost::unit_test_framework)

 add_subdirectory(scsynth)
 if (SUPERNOVA)
diff --git a/testsuite/server/supernova/CMakeLists.txt b/testsuite/server/supernova/CMakeLists.txt
index 89bbd29233d..4f2cf26a1d3 100644
--- a/testsuite/server/supernova/CMakeLists.txt
+++ b/testsuite/server/supernova/CMakeLists.txt
@@ -33,7 +33,7 @@ foreach(test ${simple_tests})
   string(REPLACE .cpp "" test_name ${test} )
   add_executable(${test_name} ${test})

-  target_link_libraries(${test_name} boost_test libsupernova boost_thread_lib)
+  target_link_libraries(${test_name} boost_test libsupernova Boost::thread)

   if(LINUX AND CMAKE_COMPILER_IS_CLANG)
     target_link_libraries(${test_name} atomic)

