From 0b989abf809e92af786dd091ac97d6a903a5afa7 Mon Sep 17 00:00:00 2001
From: Edgar <Edgar@AnotherFoxGuy.com>
Date: Sun, 6 Apr 2025 12:36:00 +0200
Subject: [PATCH] Revert "Remove VCPKG OpenSSL hack."

This reverts commit 891c6babc8477f1a5a08c5a202f847252b4af7e7.
---
 cmake/macros/InstallBesideConsole.cmake       |  6 ++++
 .../macros/ManuallyInstallOpenSSLForQt.cmake  | 35 +++++++++++++++++++
 interface/CMakeLists.txt                      |  1 +
 3 files changed, 42 insertions(+)
 create mode 100644 cmake/macros/ManuallyInstallOpenSSLForQt.cmake

diff --git a/cmake/macros/InstallBesideConsole.cmake b/cmake/macros/InstallBesideConsole.cmake
index dfa55da294..e3186501f4 100644
--- a/cmake/macros/InstallBesideConsole.cmake
+++ b/cmake/macros/InstallBesideConsole.cmake
@@ -72,5 +72,11 @@ macro(install_beside_console)
         COMPONENT ${SERVER_COMPONENT}
       )
     endif()
+
+    # set variables used by manual ssleay library copy
+    set(TARGET_INSTALL_DIR ${COMPONENT_INSTALL_DIR})
+    set(TARGET_INSTALL_COMPONENT ${SERVER_COMPONENT})
+    manually_install_openssl_for_qt()
+
   endif ()
 endmacro()
diff --git a/cmake/macros/ManuallyInstallOpenSSLForQt.cmake b/cmake/macros/ManuallyInstallOpenSSLForQt.cmake
new file mode 100644
index 0000000000..3493e19616
--- /dev/null
+++ b/cmake/macros/ManuallyInstallOpenSSLForQt.cmake
@@ -0,0 +1,35 @@
+#
+#  ManuallyInstallOpenSSLforQt.cmake
+#
+#  Created by Stephen Birarda on 1/15/16.
+#  Copyright 2014 High Fidelity, Inc.
+#  Copyright 2020 Vircadia contributors.
+#
+#  Distributed under the Apache License, Version 2.0.
+#  See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
+#
+
+macro(manually_install_openssl_for_qt)
+
+  # Qt dynamically links OpenSSL if it can find it on the user's machine
+  # We want to avoid it being found somewhere random and have it not being a compatible version
+  # So even though we don't need the dynamic version of OpenSSL for our direct-use purposes
+  # we use this macro to include the two SSL DLLs with the targets using QtNetwork
+  if (WIN32)
+    # we have to call find_package(OpenSSL) here even though this target may not directly need it
+    find_package(OpenSSL REQUIRED)
+
+    install(
+      FILES "${VCPKG_INSTALL_ROOT}/bin/libcrypto-3-x64.dll"
+      DESTINATION ${TARGET_INSTALL_DIR}
+      COMPONENT ${TARGET_INSTALL_COMPONENT}
+    )
+
+    install(
+      FILES "${VCPKG_INSTALL_ROOT}/bin/libssl-3-x64.dll"
+      DESTINATION ${TARGET_INSTALL_DIR}
+      COMPONENT ${TARGET_INSTALL_COMPONENT}
+    )
+  endif()
+
+endmacro()
diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt
index 17b23ddff2..863d0554ce 100644
--- a/interface/CMakeLists.txt
+++ b/interface/CMakeLists.txt
@@ -451,6 +451,7 @@ set(EXTRA_DEPLOY_OPTIONS "--qmldir  \"${PROJECT_SOURCE_DIR}/resources/qml\"")
 
 set(TARGET_INSTALL_DIR ${INTERFACE_INSTALL_DIR})
 set(TARGET_INSTALL_COMPONENT ${CLIENT_COMPONENT})
+manually_install_openssl_for_qt()
 package_libraries_for_deployment()
 
 find_package(GifCreator REQUIRED)