From 0e2119c63846d0d7a24c140db9aff3d89db80ba2 Mon Sep 17 00:00:00 2001
From: AnyOldName3 <krizdjali@gmail.com>
Date: Tue, 6 Aug 2024 22:51:19 +0100
Subject: [PATCH 1/3] Ditch old AppVeyor stuff

We've not used AppVeyor for years.
If we started again, it'd use a different version of Boost and that aspect would need redoing anyway.
Everything else that was AppVeyor-specific is something we've got away without in GitLab CI so can't have been especially important.
---
 CI/before_script.msvc.sh | 22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/CI/before_script.msvc.sh b/CI/before_script.msvc.sh
index 12d7bec3b1..3d116ca88e 100644
--- a/CI/before_script.msvc.sh
+++ b/CI/before_script.msvc.sh
@@ -44,7 +44,6 @@ function unixPathAsWindows {
 	fi
 }
 
-APPVEYOR=${APPVEYOR:-}
 CI=${CI:-}
 STEP=${STEP:-}
 
@@ -206,16 +205,8 @@ if [ -z $VERBOSE ]; then
 	STRIP="> /dev/null 2>&1"
 fi
 
-if [ -z $APPVEYOR ]; then
-	echo "Running prebuild outside of Appveyor."
-
-	DIR=$(windowsPathAsUnix "${BASH_SOURCE[0]}")
-	cd $(dirname "$DIR")/..
-else
-	echo "Running prebuild in Appveyor."
-
-	cd "$APPVEYOR_BUILD_FOLDER"
-fi
+DIR=$(windowsPathAsUnix "${BASH_SOURCE[0]}")
+cd $(dirname "$DIR")/..
 
 run_cmd() {
 	CMD="$1"
@@ -226,13 +217,7 @@ run_cmd() {
 		eval $CMD $@ > output.log 2>&1 || RET=$?
 
 		if [ $RET -ne 0 ]; then
-			if [ -z $APPVEYOR ]; then
-				echo "Command $CMD failed, output can be found in $(real_pwd)/output.log"
-			else
-				echo
-				echo "Command $CMD failed;"
-				cat output.log
-			fi
+			echo "Command $CMD failed, output can be found in $(real_pwd)/output.log"
 		else
 			rm output.log
 		fi
@@ -559,7 +544,6 @@ echo "Starting prebuild on MSVC${MSVC_DISPLAY_YEAR} WIN${BITS}"
 echo "==================================="
 echo
 
-# cd OpenMW/AppVeyor-test
 mkdir -p deps
 cd deps
 

From 26be98966fed9959d79835830d5da904b966aec3 Mon Sep 17 00:00:00 2001
From: AnyOldName3 <krizdjali@gmail.com>
Date: Tue, 6 Aug 2024 23:37:54 +0100
Subject: [PATCH 2/3] Modernise Boost CMake stuff

Resolves https://gitlab.com/OpenMW/openmw/-/issues/8100

Also removes some old crud.
Hopefully the old crud is all:
* Handled automatically by CMake now we're using the modern approach.
* A hack-fix for a problem caused by not using the modern approach.
* Massively outdated so no longer necessary.

If it turns out this makes CI fail, I'll tweak things as necessary.

Changes that might not be wanted include:
* Getting rid of our BOOST_STATIC CMake option. In cases where the CMake config doesn't make the one correct choice from the build environment (i.e. because there's a choice) the CMake config exposes the option already.
  However, we were forcing this on for Windows, so that might matter.
  It seems to default to static on my machine even though I thought I read something suggesting otherwise, so we'll see how things go with that.
  If we eventually put CMake in charge of installing dependency DLLs this will be a moot point as we won't need to care.
* Bumping the minimum version of Boost to 1.70.0, as that's the first with working CMake config.
  It's from 2019, so plausibly there are distros too scared to use a library from five years ago as it can't legally drink in the US (although it could in limited quantities with parental supervision in the UK, as long as it's just something inconsequential like a single sip of beer).
---
 CMakeLists.txt                       | 19 ++-----------------
 apps/bsatool/CMakeLists.txt          |  2 +-
 apps/bulletobjecttool/CMakeLists.txt |  2 +-
 apps/esmtool/CMakeLists.txt          |  2 +-
 apps/essimporter/CMakeLists.txt      |  2 +-
 apps/mwiniimporter/CMakeLists.txt    |  4 ++--
 apps/navmeshtool/CMakeLists.txt      |  2 +-
 apps/opencs/CMakeLists.txt           |  4 ++--
 apps/openmw/CMakeLists.txt           |  2 +-
 components/CMakeLists.txt            | 14 +++++---------
 10 files changed, 17 insertions(+), 36 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 51c0a81aa2..9770a05606 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -124,7 +124,6 @@ include(WholeArchive)
 
 configure_file ("${OpenMW_SOURCE_DIR}/docs/mainpage.hpp.cmake" "${OpenMW_BINARY_DIR}/docs/mainpage.hpp")
 
-option(BOOST_STATIC "Link static build of Boost into the binaries" FALSE)
 option(QT_STATIC "Link static build of Qt into the binaries" FALSE)
 
 option(OPENMW_USE_SYSTEM_BULLET "Use system provided bullet physics library" ON)
@@ -369,11 +368,6 @@ endif()
 
 # Platform specific
 if (WIN32)
-    if(NOT MINGW)
-    set(Boost_USE_STATIC_LIBS   ON)
-    add_definitions(-DBOOST_ALL_NO_LIB)
-    endif(NOT MINGW)
-
     # Suppress WinMain(), provided by SDL
     add_definitions(-DSDL_MAIN_HANDLED)
 
@@ -466,14 +460,7 @@ if(WIN32)
     endif(MSVC)
 endif(WIN32)
 
-IF(BOOST_STATIC)
-    set(Boost_USE_STATIC_LIBS   ON)
-endif()
-
-set(Boost_NO_BOOST_CMAKE ON)
-set(Boost_NO_WARN_NEW_VERSIONS ON)  # ignore warnings about new releases of boost
-
-find_package(Boost 1.6.2 REQUIRED COMPONENTS ${BOOST_COMPONENTS} OPTIONAL_COMPONENTS ${BOOST_OPTIONAL_COMPONENTS})
+find_package(Boost 1.70.0 CONFIG REQUIRED COMPONENTS ${BOOST_COMPONENTS} OPTIONAL_COMPONENTS ${BOOST_OPTIONAL_COMPONENTS})
 
 if(OPENMW_USE_SYSTEM_MYGUI)
     find_package(MyGUI 3.4.3 REQUIRED)
@@ -502,7 +489,6 @@ set(SOL_CONFIG_DIR ${OpenMW_SOURCE_DIR}/extern/sol_config)
 include_directories(
     BEFORE SYSTEM
     "."
-    ${Boost_INCLUDE_DIR}
     ${MyGUI_INCLUDE_DIRS}
     ${OPENAL_INCLUDE_DIR}
     ${OPENGL_INCLUDE_DIR}
@@ -513,7 +499,7 @@ include_directories(
     ${ICU_INCLUDE_DIRS}
 )
 
-link_directories(${Boost_LIBRARY_DIRS} ${COLLADA_DOM_LIBRARY_DIRS})
+link_directories(${COLLADA_DOM_LIBRARY_DIRS})
 
 if(MYGUI_STATIC)
     add_definitions(-DMYGUI_STATIC)
@@ -601,7 +587,6 @@ endif()
 
 if (CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
     set(OPENMW_CXX_FLAGS "-Wall -Wextra -Wundef -Wextra-semi -Wno-unused-parameter -pedantic -Wno-long-long -Wnon-virtual-dtor -Wunused ${OPENMW_CXX_FLAGS}")
-    add_definitions( -DBOOST_NO_CXX11_SCOPED_ENUMS=ON )
 
     if (APPLE)
         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
diff --git a/apps/bsatool/CMakeLists.txt b/apps/bsatool/CMakeLists.txt
index e893feb91a..b2ad8f16b2 100644
--- a/apps/bsatool/CMakeLists.txt
+++ b/apps/bsatool/CMakeLists.txt
@@ -9,7 +9,7 @@ openmw_add_executable(bsatool
 )
 
 target_link_libraries(bsatool
-    ${Boost_PROGRAM_OPTIONS_LIBRARY}
+    Boost::program_options
     components
 )
 
diff --git a/apps/bulletobjecttool/CMakeLists.txt b/apps/bulletobjecttool/CMakeLists.txt
index d9bba10195..c29915b139 100644
--- a/apps/bulletobjecttool/CMakeLists.txt
+++ b/apps/bulletobjecttool/CMakeLists.txt
@@ -6,7 +6,7 @@ source_group(apps\\bulletobjecttool FILES ${BULLETMESHTOOL})
 openmw_add_executable(openmw-bulletobjecttool ${BULLETMESHTOOL})
 
 target_link_libraries(openmw-bulletobjecttool
-    ${Boost_PROGRAM_OPTIONS_LIBRARY}
+    Boost::program_options
     components
 )
 
diff --git a/apps/esmtool/CMakeLists.txt b/apps/esmtool/CMakeLists.txt
index d26e2a2128..6dd592a4fe 100644
--- a/apps/esmtool/CMakeLists.txt
+++ b/apps/esmtool/CMakeLists.txt
@@ -16,7 +16,7 @@ openmw_add_executable(esmtool
 )
 
 target_link_libraries(esmtool
-    ${Boost_PROGRAM_OPTIONS_LIBRARY}
+    Boost::program_options
     components
 )
 
diff --git a/apps/essimporter/CMakeLists.txt b/apps/essimporter/CMakeLists.txt
index 5dfb747aee..217d3e7b50 100644
--- a/apps/essimporter/CMakeLists.txt
+++ b/apps/essimporter/CMakeLists.txt
@@ -34,7 +34,7 @@ openmw_add_executable(openmw-essimporter
 )
 
 target_link_libraries(openmw-essimporter
-    ${Boost_PROGRAM_OPTIONS_LIBRARY}
+    Boost::program_options
     components
 )
 
diff --git a/apps/mwiniimporter/CMakeLists.txt b/apps/mwiniimporter/CMakeLists.txt
index 49be8309ab..57a28bed9b 100644
--- a/apps/mwiniimporter/CMakeLists.txt
+++ b/apps/mwiniimporter/CMakeLists.txt
@@ -14,13 +14,13 @@ openmw_add_executable(openmw-iniimporter
 )
 
 target_link_libraries(openmw-iniimporter
-    ${Boost_PROGRAM_OPTIONS_LIBRARY}
+    Boost::program_options
     components
 )
 
 if (WIN32)
     target_link_libraries(openmw-iniimporter
-    ${Boost_LOCALE_LIBRARY})
+        Boost::locale)
     INSTALL(TARGETS openmw-iniimporter RUNTIME DESTINATION ".")
 endif(WIN32)
 
diff --git a/apps/navmeshtool/CMakeLists.txt b/apps/navmeshtool/CMakeLists.txt
index 13c8230abd..58648a2f0a 100644
--- a/apps/navmeshtool/CMakeLists.txt
+++ b/apps/navmeshtool/CMakeLists.txt
@@ -8,7 +8,7 @@ source_group(apps\\navmeshtool FILES ${NAVMESHTOOL})
 openmw_add_executable(openmw-navmeshtool ${NAVMESHTOOL})
 
 target_link_libraries(openmw-navmeshtool
-    ${Boost_PROGRAM_OPTIONS_LIBRARY}
+    Boost::program_options
     components
 )
 
diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt
index 7c18360a76..ce85b2fd19 100644
--- a/apps/opencs/CMakeLists.txt
+++ b/apps/opencs/CMakeLists.txt
@@ -244,7 +244,7 @@ target_link_libraries(openmw-cs-lib
     ${OSGTEXT_LIBRARIES}
     ${OSG_LIBRARIES}
     ${EXTERN_OSGQT_LIBRARY}
-    ${Boost_PROGRAM_OPTIONS_LIBRARY}
+    Boost::program_options
     components_qt
 )
 
@@ -255,7 +255,7 @@ else()
 endif()
 
 if (WIN32)
-    target_link_libraries(openmw-cs-lib ${Boost_LOCALE_LIBRARY})
+    target_link_libraries(openmw-cs-lib Boost::locale)
     target_sources(openmw-cs PRIVATE ${CMAKE_SOURCE_DIR}/files/windows/openmw-cs.exe.manifest)
 endif()
 
diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt
index 2b2470b3ef..a125761454 100644
--- a/apps/openmw/CMakeLists.txt
+++ b/apps/openmw/CMakeLists.txt
@@ -159,7 +159,7 @@ target_link_libraries(openmw-lib
     ${OSGDB_LIBRARIES}
     ${OSGUTIL_LIBRARIES}
     ${OSG_LIBRARIES}
-    ${Boost_PROGRAM_OPTIONS_LIBRARY}
+    Boost::program_options
     ${OPENAL_LIBRARY}
     ${FFmpeg_LIBRARIES}
     ${MyGUI_LIBRARIES}
diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt
index 67cb881ee5..70b1eb90a2 100644
--- a/components/CMakeLists.txt
+++ b/components/CMakeLists.txt
@@ -586,9 +586,9 @@ target_link_libraries(components
     ${OSG_LIBRARIES}
     ${OPENTHREADS_LIBRARIES}
 
-    ${Boost_SYSTEM_LIBRARY}
-    ${Boost_PROGRAM_OPTIONS_LIBRARY}
-    ${Boost_IOSTREAMS_LIBRARY}
+    Boost::system
+    Boost::program_options
+    Boost::iostreams
 
     SDL2::SDL2
     ${OPENGL_gl_LIBRARY}
@@ -612,16 +612,12 @@ else()
     target_link_libraries(components yaml-cpp)
 endif()
 
-if(Boost_VERSION_STRING VERSION_GREATER_EQUAL 1.77.0)
-    target_link_libraries(components ${Boost_ATOMIC_LIBRARY})
-endif()
-
 target_link_libraries(components ${BULLET_LIBRARIES})
 
 if (WIN32)
     target_link_libraries(components
-    ${Boost_LOCALE_LIBRARY}
-    ${Boost_ZLIB_LIBRARY})
+    Boost::locale
+    Boost::zlib)
 endif()
 
 if (USE_QT)

From 387b63909bd5dabc125cbe092eb33a29cb26c2db Mon Sep 17 00:00:00 2001
From: AnyOldName3 <krizdjali@gmail.com>
Date: Thu, 22 Aug 2024 23:59:27 +0100
Subject: [PATCH 3/3] Remove vestigial Boost libraries

Boost::zlib is basically part of Boost::iostreams, and depending on how you configure Boost, it can either be a separate library or get embedded into iostreams.
With the third-party-but-linked-on-Boost's-website package we've been using for years, it's a separate library.
Before https://gitlab.com/OpenMW/openmw/-/merge_requests/4307, we needed to explicitly link with it as CMake wasn't handling transitive dependencies for us.
With vcpkg, it's embedded, and doesn't have its own CMake config, so we couldn't explicitly link with it even if we wanted to.

Now CMake *is* handling transitive dependencies for us, we don't even need to think about this library.
It's all automatic.

Boost::locale, on the other hand, used to be something we used directly (I think for doing UTF-16/UTF-8 conversions when dealing with Windows paths).
However, it isn't anymore, and we just didn't purge it from our CMake when we should have.
It can go.
---
 CMakeLists.txt                     | 8 --------
 apps/mwiniimporter/CMakeLists.txt  | 2 --
 apps/opencs/CMakeLists.txt         | 1 -
 components/CMakeLists.txt          | 6 ------
 components/platform/file.win32.cpp | 1 -
 5 files changed, 18 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9770a05606..75b9642c5d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -451,14 +451,6 @@ if(HAVE_MULTIVIEW)
 endif(HAVE_MULTIVIEW)
 
 set(BOOST_COMPONENTS iostreams program_options system)
-if(WIN32)
-    set(BOOST_COMPONENTS ${BOOST_COMPONENTS} locale)
-    if(MSVC)
-        # boost-zlib is not present (nor needed) in vcpkg version of boost.
-        # there, it is part of boost-iostreams instead.
-        set(BOOST_OPTIONAL_COMPONENTS zlib)
-    endif(MSVC)
-endif(WIN32)
 
 find_package(Boost 1.70.0 CONFIG REQUIRED COMPONENTS ${BOOST_COMPONENTS} OPTIONAL_COMPONENTS ${BOOST_OPTIONAL_COMPONENTS})
 
diff --git a/apps/mwiniimporter/CMakeLists.txt b/apps/mwiniimporter/CMakeLists.txt
index 57a28bed9b..ed88ac0bc4 100644
--- a/apps/mwiniimporter/CMakeLists.txt
+++ b/apps/mwiniimporter/CMakeLists.txt
@@ -19,8 +19,6 @@ target_link_libraries(openmw-iniimporter
 )
 
 if (WIN32)
-    target_link_libraries(openmw-iniimporter
-        Boost::locale)
     INSTALL(TARGETS openmw-iniimporter RUNTIME DESTINATION ".")
 endif(WIN32)
 
diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt
index ce85b2fd19..87b1821cba 100644
--- a/apps/opencs/CMakeLists.txt
+++ b/apps/opencs/CMakeLists.txt
@@ -255,7 +255,6 @@ else()
 endif()
 
 if (WIN32)
-    target_link_libraries(openmw-cs-lib Boost::locale)
     target_sources(openmw-cs PRIVATE ${CMAKE_SOURCE_DIR}/files/windows/openmw-cs.exe.manifest)
 endif()
 
diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt
index 70b1eb90a2..0b0dd7760b 100644
--- a/components/CMakeLists.txt
+++ b/components/CMakeLists.txt
@@ -614,12 +614,6 @@ endif()
 
 target_link_libraries(components ${BULLET_LIBRARIES})
 
-if (WIN32)
-    target_link_libraries(components
-    Boost::locale
-    Boost::zlib)
-endif()
-
 if (USE_QT)
     add_library(components_qt STATIC ${COMPONENT_QT_FILES} ${ESM_UI_HDR})
     target_link_libraries(components_qt components Qt::Widgets Qt::Core)
diff --git a/components/platform/file.win32.cpp b/components/platform/file.win32.cpp
index f5ef60478b..3df99e8a8f 100644
--- a/components/platform/file.win32.cpp
+++ b/components/platform/file.win32.cpp
@@ -1,6 +1,5 @@
 #include "file.hpp"
 
-#include <boost/locale.hpp>
 #include <cassert>
 #include <components/misc/windows.hpp>
 #include <stdexcept>