From 7b6d5477b70e36b0ea90531fdc94ddfd9097a294 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Sat, 17 Apr 2021 13:45:58 -0400
Subject: [PATCH] Build system fixes for new zlib dependency chain rebuild

---
 indra/cmake/00-Common.cmake        |  9 ++--
 indra/cmake/Boost.cmake            | 81 ++++++++++--------------------
 indra/cmake/CURL.cmake             |  2 +-
 indra/cmake/Copy3rdPartyLibs.cmake | 18 -------
 indra/cmake/LLPrimitive.cmake      | 25 ++++++---
 indra/cmake/ZLIB.cmake             |  9 ++--
 indra/newview/CMakeLists.txt       |  7 ---
 indra/newview/viewer_manifest.py   | 22 --------
 8 files changed, 55 insertions(+), 118 deletions(-)

diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake
index dc77b7270ba..84255e93e2d 100644
--- a/indra/cmake/00-Common.cmake
+++ b/indra/cmake/00-Common.cmake
@@ -191,12 +191,9 @@ if (WINDOWS)
 
   # library linkage defines
   add_definitions(
-      /DBOOST_ALL_DYN_LINK
-      /DDLL_IMPORT
-      /DDOM_DYNAMIC
-      /DPNG_USE_DLL
-      /DWEBP_DLL
-      /DZLIB_DLL
+      /DCURL_STATICLIB=1
+      /DURI_STATIC_BUILD=1
+      /DWEBP_DLL=1
   )
 
   # configure win32 API for 7 and above compatibility
diff --git a/indra/cmake/Boost.cmake b/indra/cmake/Boost.cmake
index fccbe437a17..ab2e6261742 100644
--- a/indra/cmake/Boost.cmake
+++ b/indra/cmake/Boost.cmake
@@ -24,60 +24,33 @@ else (USESYSTEMLIBS)
   set(addrsfx "-x${ADDRESS_SIZE}")
 
   if (WINDOWS)
-    if(MSVC80)
-      # This should be obsolete at this point
-      set(BOOST_VERSION "1.74")
-      set(BOOST_CONTEXT_LIBRARY 
-          optimized libboost_context-vc80-mt-${BOOST_VERSION}
-          debug libboost_context-vc80-mt-gd-${BOOST_VERSION})
-      set(BOOST_FILESYSTEM_LIBRARY 
-          optimized libboost_filesystem-vc80-mt-${BOOST_VERSION}
-          debug libboost_filesystem-vc80-mt-gd-${BOOST_VERSION})
-      set(BOOST_PROGRAM_OPTIONS_LIBRARY 
-          optimized libboost_program_options-vc80-mt-${BOOST_VERSION}
-          debug libboost_program_options-vc80-mt-gd-${BOOST_VERSION})
-      set(BOOST_REGEX_LIBRARY
-          optimized libboost_regex-vc80-mt-${BOOST_VERSION}
-          debug libboost_regex-vc80-mt-gd-${BOOST_VERSION})
-      set(BOOST_SIGNALS_LIBRARY 
-          optimized libboost_signals-vc80-mt-${BOOST_VERSION}
-          debug libboost_signals-vc80-mt-gd-${BOOST_VERSION})
-      set(BOOST_SYSTEM_LIBRARY 
-          optimized libboost_system-vc80-mt-${BOOST_VERSION}
-          debug libboost_system-vc80-mt-gd-${BOOST_VERSION})
-      set(BOOST_THREAD_LIBRARY 
-          optimized libboost_thread-vc80-mt-${BOOST_VERSION}
-          debug libboost_thread-vc80-mt-gd-${BOOST_VERSION})
-    else(MSVC80)
-      # MSVC 10.0 config
-      set(BOOST_CONTEXT_LIBRARY 
-          optimized boost_context-mt${addrsfx}
-          debug boost_context-mt-gd${addrsfx})
-      set(BOOST_FIBER_LIBRARY 
-          optimized boost_fiber-mt${addrsfx}
-          debug boost_fiber-mt-gd${addrsfx})
-      set(BOOST_FILESYSTEM_LIBRARY 
-          optimized boost_filesystem-mt${addrsfx}
-          debug boost_filesystem-mt-gd${addrsfx})
-      set(BOOST_PROGRAM_OPTIONS_LIBRARY 
-          optimized boost_program_options-mt${addrsfx}
-          debug boost_program_options-mt-gd${addrsfx})
-      set(BOOST_REGEX_LIBRARY
-          optimized boost_regex-mt${addrsfx}
-          debug boost_regex-mt-gd${addrsfx})
-      set(BOOST_SIGNALS_LIBRARY 
-          optimized boost_signals-mt${addrsfx}
-          debug boost_signals-mt-gd${addrsfx})
-      set(BOOST_STACKTRACE_LIBRARY 
-          optimized boost_stacktrace_windbg-mt${addrsfx}
-          debug boost_stacktrace_windbg-mt-gd${addrsfx})
-      set(BOOST_SYSTEM_LIBRARY 
-          optimized boost_system-mt${addrsfx}
-          debug boost_system-mt-gd${addrsfx})
-      set(BOOST_THREAD_LIBRARY 
-          optimized boost_thread-mt${addrsfx}
-          debug boost_thread-mt-gd${addrsfx})
-    endif (MSVC80)
+    set(BOOST_CONTEXT_LIBRARY 
+        optimized libboost_context-mt${addrsfx}
+        debug libboost_context-mt-gd${addrsfx})
+    set(BOOST_FIBER_LIBRARY 
+        optimized libboost_fiber-mt${addrsfx}
+        debug libboost_fiber-mt-gd${addrsfx})
+    set(BOOST_FILESYSTEM_LIBRARY 
+        optimized libboost_filesystem-mt${addrsfx}
+        debug libboost_filesystem-mt-gd${addrsfx})
+    set(BOOST_PROGRAM_OPTIONS_LIBRARY 
+        optimized libboost_program_options-mt${addrsfx}
+        debug libboost_program_options-mt-gd${addrsfx})
+    set(BOOST_REGEX_LIBRARY
+        optimized libboost_regex-mt${addrsfx}
+        debug libboost_regex-mt-gd${addrsfx})
+    set(BOOST_SIGNALS_LIBRARY 
+        optimized libboost_signals-mt${addrsfx}
+        debug libboost_signals-mt-gd${addrsfx})
+    set(BOOST_STACKTRACE_LIBRARY 
+        optimized libboost_stacktrace_windbg-mt${addrsfx}
+        debug libboost_stacktrace_windbg-mt-gd${addrsfx})
+    set(BOOST_SYSTEM_LIBRARY 
+        optimized libboost_system-mt${addrsfx}
+        debug libboost_system-mt-gd${addrsfx})
+    set(BOOST_THREAD_LIBRARY 
+        optimized libboost_thread-mt${addrsfx}
+        debug libboost_thread-mt-gd${addrsfx})
   elseif (LINUX)
     set(BOOST_CONTEXT_LIBRARY
         optimized boost_context-mt${addrsfx}
diff --git a/indra/cmake/CURL.cmake b/indra/cmake/CURL.cmake
index 4da39735d84..04afae594dd 100644
--- a/indra/cmake/CURL.cmake
+++ b/indra/cmake/CURL.cmake
@@ -10,7 +10,7 @@ else (USESYSTEMLIBS)
   use_prebuilt_binary(curl)
   if (WINDOWS)
     set(CURL_LIBRARIES 
-    debug libcurl_debug.lib
+    debug libcurld.lib
     optimized libcurl.lib)
   else (WINDOWS)
     set(CURL_LIBRARIES libcurl.a)
diff --git a/indra/cmake/Copy3rdPartyLibs.cmake b/indra/cmake/Copy3rdPartyLibs.cmake
index 0dd49e1a31f..0a2d5ade0dd 100644
--- a/indra/cmake/Copy3rdPartyLibs.cmake
+++ b/indra/cmake/Copy3rdPartyLibs.cmake
@@ -54,38 +54,20 @@ if(WINDOWS)
 
     set(release_src_dir "${ARCH_PREBUILT_DIRS_RELEASE}")
     set(release_files
-        boost_context-mt${addrsfx}.dll
-        boost_fiber-mt${addrsfx}.dll
-        boost_filesystem-mt${addrsfx}.dll
-        boost_program_options-mt${addrsfx}.dll
-        boost_regex-mt${addrsfx}.dll
-        boost_stacktrace_windbg-mt${addrsfx}.dll
-        boost_thread-mt${addrsfx}.dll
         epoxy-0.dll
         ${EXPAT_COPY}
-        freetype.dll
         glod.dll
         jpeg8.dll
         libapr-1.dll
         libaprutil-1.dll
         libapriconv-1.dll
-        libcollada14dom23.dll
-        libcurl.dll
-        libeay32.dll
         libhunspell.dll
         libogg.dll
-        libpng16.dll
         libvorbis.dll
         libvorbisfile.dll
         libwebp.dll
-        libxml2.dll
-        minizip.dll
-        nghttp2.dll
         openjp2.dll
-        ssleay32.dll
-        uriparser.dll
         xmlrpc-epi.dll
-        zlib1.dll
         )
 
     # Filenames are different for 32/64 bit BugSplat file and we don't
diff --git a/indra/cmake/LLPrimitive.cmake b/indra/cmake/LLPrimitive.cmake
index 7096003658c..d4540c75c4b 100644
--- a/indra/cmake/LLPrimitive.cmake
+++ b/indra/cmake/LLPrimitive.cmake
@@ -4,9 +4,11 @@
 include(Prebuilt)
 include(Boost)
 include(URIPARSER)
+include(ZLIB)
 
 use_prebuilt_binary(colladadom)
 use_prebuilt_binary(libxml2)
+use_prebuilt_binary(minizip-ng)
 
 set(LLPRIMITIVE_INCLUDE_DIRS
     ${LIBS_OPEN_DIR}/llprimitive
@@ -15,30 +17,39 @@ if (WINDOWS)
     set(LLPRIMITIVE_LIBRARIES 
         debug llprimitive
         optimized llprimitive
-        debug libcollada14dom23-d
-        optimized libcollada14dom23
+        debug libcollada14dom23-sd
+        optimized libcollada14dom23-s
+        ${BOOST_FILESYSTEM_LIBRARY}
         ${BOOST_SYSTEM_LIBRARIES}
+        libxml2_a
+        ${URIPARSER_LIBRARIES}
+        ${MINIZIP_LIBRARIES}
+        ${ZLIB_LIBRARIES}
         )
 elseif (DARWIN)
-    use_prebuilt_binary(pcre)
     set(LLPRIMITIVE_LIBRARIES 
         llprimitive
         debug collada14dom-d
         optimized collada14dom
-        minizip
+        ${BOOST_FILESYSTEM_LIBRARY}
+        ${BOOST_SYSTEM_LIBRARIES}
         xml2
-        pcrecpp
-        pcre
         iconv           # Required by libxml2
+        ${URIPARSER_LIBRARIES}
+        ${MINIZIP_LIBRARIES}
+        ${ZLIB_LIBRARIES}
         )
 elseif (LINUX)
     set(LLPRIMITIVE_LIBRARIES 
         llprimitive
         debug collada14dom-d
         optimized collada14dom
-        minizip
+        ${BOOST_FILESYSTEM_LIBRARY}
+        ${BOOST_SYSTEM_LIBRARIES}
         xml2
         ${URIPARSER_LIBRARIES}
+        ${MINIZIP_LIBRARIES}
+        ${ZLIB_LIBRARIES}
         )
 endif (WINDOWS)
 
diff --git a/indra/cmake/ZLIB.cmake b/indra/cmake/ZLIB.cmake
index cf50b86a6f4..06cebf25d00 100644
--- a/indra/cmake/ZLIB.cmake
+++ b/indra/cmake/ZLIB.cmake
@@ -8,16 +8,18 @@ include(Prebuilt)
 if (USESYSTEMLIBS)
   include(FindZLIB)
 else (USESYSTEMLIBS)
-  use_prebuilt_binary(zlib)
+  use_prebuilt_binary(zlib-ng)
+  use_prebuilt_binary(minizip-ng)
   if (WINDOWS)
     set(MINIZIP_LIBRARIES 
-      debug minizipd
-      optimized minizip)
+      debug libminizip
+      optimized libminizip)
 
     set(ZLIB_LIBRARIES 
       debug zlibd
       optimized zlib)
   elseif (LINUX)
+    set(MINIZIP_LIBRARIES minizip)
     #
     # When we have updated static libraries in competition with older
     # shared libraries and we want the former to win, we need to do some
@@ -33,6 +35,7 @@ else (USESYSTEMLIBS)
     set(ZLIB_PRELOAD_ARCHIVES -Wl,--whole-archive z -Wl,--no-whole-archive)
     set(ZLIB_LIBRARIES z)
   elseif (DARWIN)
+    set(MINIZIP_LIBRARIES minizip)
     set(ZLIB_LIBRARIES z)
   endif (WINDOWS)
   set(ZLIB_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include/zlib)
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index c0d6eb5be5a..2bfcf7f920e 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -1889,9 +1889,6 @@ if (WINDOWS)
       ${SHARED_LIB_STAGING_DIR}/Release/glod.dll
       ${SHARED_LIB_STAGING_DIR}/RelWithDebInfo/glod.dll
       #${SHARED_LIB_STAGING_DIR}/Debug/glod.dll
-      ${SHARED_LIB_STAGING_DIR}/Release/libcollada14dom23.dll
-      ${SHARED_LIB_STAGING_DIR}/RelWithDebInfo/libcollada14dom23.dll
-      #${SHARED_LIB_STAGING_DIR}/Debug/libcollada14dom23-d.dll
       ${SHARED_LIB_STAGING_DIR}/Release/openjp2.dll
       ${SHARED_LIB_STAGING_DIR}/RelWithDebInfo/openjp2.dll
       #${SHARED_LIB_STAGING_DIR}/Debug/openjp2.dll
@@ -1905,10 +1902,6 @@ if (WINDOWS)
       ${GOOGLE_PERF_TOOLS_SOURCE}
       ${CMAKE_CURRENT_SOURCE_DIR}/licenses-win32.txt
       ${CMAKE_CURRENT_SOURCE_DIR}/featuretable.txt
-      ${ARCH_PREBUILT_DIRS_RELEASE}/libeay32.dll
-      ${ARCH_PREBUILT_DIRS_RELEASE}/ssleay32.dll
-      ${ARCH_PREBUILT_DIRS_DEBUG}/libeay32.dll
-      ${ARCH_PREBUILT_DIRS_DEBUG}/ssleay32.dll
       ${viewer_APPSETTINGS_FILES}
       SLPlugin
       media_plugin_cef
diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index 2878dc510a2..3f633c2c185 100755
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -514,35 +514,18 @@ def construct(self):
             self.path("libapriconv-1.dll")
             self.path("libaprutil-1.dll")
 
-            # Boost Libraries
-            self.path("boost_context-mt*.dll")
-            self.path("boost_fiber-mt*.dll")
-            self.path("boost_filesystem-mt*.dll")
-            self.path("boost_program_options-mt*.dll")
-            self.path("boost_regex-mt*.dll")
-            self.path("boost_stacktrace_windbg-mt*.dll")
-            self.path("boost_thread-mt*.dll")
-
             # Mesh 3rd party libs needed for auto LOD and collada reading
-            self.path("libcollada14dom23.dll")
             self.path("glod.dll")
 
             # For image support
             self.path("jpeg8.dll")
-            self.path("libpng16*.dll")
             self.path("libwebp.dll")
             self.path("openjp2.dll")
 
             # For OpenGL extensions
             self.path("epoxy-0.dll")
 
-            # Security
-            self.path("ssleay32.dll")
-            self.path("libeay32.dll")
-
             # HTTP and Network
-            self.path("libcurl*.dll")
-            self.path("nghttp2.dll")
             self.path("xmlrpc-epi.dll")
 
             # Hunspell
@@ -555,11 +538,6 @@ def construct(self):
 
             # Misc
             self.path("libexpat.dll")
-            self.path("libxml2.dll")
-            self.path("minizip*.dll")
-            self.path("freetype.dll")
-            self.path("uriparser.dll")
-            self.path("zlib*1.dll")
 
             # Get openal dll for audio engine, continue if missing
             if self.args['openal'] == 'ON' or self.args['openal'] == 'TRUE':
-- 
GitLab