From 1bdb0aefab989f94fdf37152f267081c33e16723 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Mon, 14 Oct 2019 01:21:39 -0400
Subject: [PATCH] Swap two packages to cmake fetchcontent

---
 autobuild.xml                | 68 ------------------------------------
 indra/CMakeLists.txt         | 12 ++-----
 indra/cmake/Abseil-CPP.cmake |  8 -----
 indra/cmake/CMakeLists.txt   |  2 --
 indra/cmake/FmtLib.cmake     |  6 ----
 indra/cmake/Variables.cmake  |  1 +
 indra/deps/CMakeLists.txt    | 50 ++++++++++++++++++++++++++
 7 files changed, 53 insertions(+), 94 deletions(-)
 delete mode 100644 indra/cmake/Abseil-CPP.cmake
 delete mode 100644 indra/cmake/FmtLib.cmake
 create mode 100644 indra/deps/CMakeLists.txt

diff --git a/autobuild.xml b/autobuild.xml
index e68c920a49..9a234b8b64 100644
--- a/autobuild.xml
+++ b/autobuild.xml
@@ -93,40 +93,6 @@
         <key>version</key>
         <string>2.0.5</string>
       </map>
-      <key>abseil-cpp</key>
-      <map>
-        <key>canonical_repo</key>
-        <string>https://bitbucket.org/alchemyviewer/3p-abseil-src</string>
-        <key>copyright</key>
-        <string>Copyright 2018 The Abseil Authors.</string>
-        <key>description</key>
-        <string>Abseil Common Libraries</string>
-        <key>license</key>
-        <string>Apache 2.0</string>
-        <key>license_file</key>
-        <string>LICENSES/abseil-cpp.txt</string>
-        <key>name</key>
-        <string>abseil-cpp</string>
-        <key>platforms</key>
-        <map>
-          <key>common</key>
-          <map>
-            <key>archive</key>
-            <map>
-              <key>hash</key>
-              <string>1a593007e526383f15755ff6437f9fe0</string>
-              <key>hash_algorithm</key>
-              <string>md5</string>
-              <key>url</key>
-              <string>https://pkg.alchemyviewer.org/repository/autobuild-external/abseil-cpp/common/abseil_cpp-debac94.2-common-2.tar.bz2</string>
-            </map>
-            <key>name</key>
-            <string>common</string>
-          </map>
-        </map>
-        <key>version</key>
-        <string>debac94.2</string>
-      </map>
       <key>apr_suite</key>
       <map>
         <key>copyright</key>
@@ -869,40 +835,6 @@
         <key>version</key>
         <string>2.00.03.192211300</string>
       </map>
-      <key>fmtlib-src</key>
-      <map>
-        <key>canonical_repo</key>
-        <string>https://git.alchemyviewer.org/alchemy/thirdparty/3p-fmtlib-src</string>
-        <key>copyright</key>
-        <string>Copyright (c) 2012 - present, Victor Zverovich</string>
-        <key>description</key>
-        <string>A modern formatting library</string>
-        <key>license</key>
-        <string>MIT</string>
-        <key>license_file</key>
-        <string>LICENSES/fmtlib.txt</string>
-        <key>name</key>
-        <string>fmtlib-src</string>
-        <key>platforms</key>
-        <map>
-          <key>common</key>
-          <map>
-            <key>archive</key>
-            <map>
-              <key>hash</key>
-              <string>ba4c1e2ed2a1640823a932f2c4d88000</string>
-              <key>hash_algorithm</key>
-              <string>md5</string>
-              <key>url</key>
-              <string>https://pkg.alchemyviewer.org/repository/autobuild-external/fmtlib-src/common/fmtlib_src-6.0.0.1-common-1.tar.bz2</string>
-            </map>
-            <key>name</key>
-            <string>common</string>
-          </map>
-        </map>
-        <key>version</key>
-        <string>6.0.0.1</string>
-      </map>
       <key>fontconfig</key>
       <map>
         <key>copyright</key>
diff --git a/indra/CMakeLists.txt b/indra/CMakeLists.txt
index 21201d0a44..55c56759fb 100644
--- a/indra/CMakeLists.txt
+++ b/indra/CMakeLists.txt
@@ -19,19 +19,11 @@ endif (NOT CMAKE_BUILD_TYPE)
 include(Variables)
 include(00-Common)
 include(BuildVersion)
-include(Abseil-CPP)
-include(FmtLib)
+include(CTest)
 
-# Dependencies
-add_subdirectory(${ABSEIL_SRC_DIR} ${ABSEIL_BIN_DIR})
-target_compile_options(absl_strings PRIVATE /wd4018)
-target_compile_options(absl_str_format_internal PRIVATE /wd4018)
-target_compile_options(absl_flags_usage_internal PRIVATE /wd4018)
-
-add_subdirectory(${FMT_SRC_DIR} ${FMT_BIN_DIR})
+add_subdirectory(deps)
 
 add_subdirectory(cmake)
-
 add_subdirectory(${LIBS_OPEN_PREFIX}llaudio)
 add_subdirectory(${LIBS_OPEN_PREFIX}llappearance)
 add_subdirectory(${LIBS_OPEN_PREFIX}llcharacter)
diff --git a/indra/cmake/Abseil-CPP.cmake b/indra/cmake/Abseil-CPP.cmake
deleted file mode 100644
index c7bb0f7630..0000000000
--- a/indra/cmake/Abseil-CPP.cmake
+++ /dev/null
@@ -1,8 +0,0 @@
-# -*- cmake -*-
-include(Prebuilt)
-
-set(BUILD_TESTING OFF)
-use_prebuilt_binary(abseil-cpp)
-set(ABSEIL_SRC_DIR ${LIBS_PREBUILT_DIR}/abseil-cpp)
-set(ABSEIL_BIN_DIR ${CMAKE_BINARY_DIR}/abseil-cpp)
-
diff --git a/indra/cmake/CMakeLists.txt b/indra/cmake/CMakeLists.txt
index bc077f8362..0186e75f22 100644
--- a/indra/cmake/CMakeLists.txt
+++ b/indra/cmake/CMakeLists.txt
@@ -6,7 +6,6 @@ set(cmake_SOURCE_FILES
     CMakeLists.txt
 
     00-Common.cmake
-    Abseil-CPP.cmake
     APR.cmake
     Audio.cmake
     Boost.cmake
@@ -33,7 +32,6 @@ set(cmake_SOURCE_FILES
     FindXmlRpcEpi.cmake
     FindZLIB.cmake
     FMODSTUDIO.cmake
-    FmtLib.cmake
     FreeType.cmake
     GeneratePrecompiledHeader.cmake
     GLM.cmake
diff --git a/indra/cmake/FmtLib.cmake b/indra/cmake/FmtLib.cmake
deleted file mode 100644
index 39916c9316..0000000000
--- a/indra/cmake/FmtLib.cmake
+++ /dev/null
@@ -1,6 +0,0 @@
-# -*- cmake -*-
-include(Prebuilt)
-
-use_prebuilt_binary(fmtlib-src)
-set(FMT_SRC_DIR ${LIBS_PREBUILT_DIR}/fmt)
-set(FMT_BIN_DIR ${CMAKE_BINARY_DIR}/fmt)
diff --git a/indra/cmake/Variables.cmake b/indra/cmake/Variables.cmake
index 41e21a9714..d455d059e5 100644
--- a/indra/cmake/Variables.cmake
+++ b/indra/cmake/Variables.cmake
@@ -37,6 +37,7 @@ set(VIEWER_PREFIX)
 set(INTEGRATION_TESTS_PREFIX)
 
 option(LL_TESTS "Build and run unit and integration tests (disable for build timing runs to reduce variation" OFF)
+option(BUILD_TESTING "Build test suite" OFF)
 option(UNATTENDED "Disable use of uneeded tooling for automated builds" OFF)
 
 # Compiler and toolchain options
diff --git a/indra/deps/CMakeLists.txt b/indra/deps/CMakeLists.txt
new file mode 100644
index 0000000000..d5ea5bf9e7
--- /dev/null
+++ b/indra/deps/CMakeLists.txt
@@ -0,0 +1,50 @@
+project(deps)
+
+include(FetchContent)
+
+set(CMAKE_FOLDER "Third Party")
+
+FetchContent_Declare(
+  Catch2
+  GIT_REPOSITORY https://github.com/catchorg/Catch2.git
+  GIT_TAG        v2.10.0
+  GIT_SHALLOW    TRUE
+  GIT_PROGRESS   TRUE
+  )
+FetchContent_Declare(
+  fmt
+  GIT_REPOSITORY https://github.com/fmtlib/fmt.git
+  GIT_TAG        7512a55aa3ae309587ca89668ef9ec4074a51a1f
+  GIT_SHALLOW    TRUE
+  GIT_PROGRESS   TRUE
+  )
+FetchContent_Declare(
+  absl
+  GIT_REPOSITORY https://github.com/abseil/abseil-cpp.git
+  GIT_TAG        e9f9000c7c80993cb589d011616b7a8016e42f4a
+  GIT_SHALLOW    TRUE
+  GIT_PROGRESS   TRUE
+)
+
+# This is a hack because absl has dumb cmake
+set(OLD_BUILD_TEST ${BUILD_TESTING})
+set(BUILD_TESTING OFF)
+FetchContent_MakeAvailable(absl)
+set(BUILD_TESTING ${OLD_BUILD_TEST})
+
+# Supress warnings inside abseil under MSVC
+if(WINDOWS)
+  target_compile_options(absl_strings PRIVATE /wd4018)
+  target_compile_options(absl_str_format_internal PRIVATE /wd4018)
+  target_compile_options(absl_flags_usage_internal PRIVATE /wd4018)
+endif()
+
+
+if (BUILD_TESTING)
+  FetchContent_MakeAvailable(Catch2)
+endif()
+
+#Download the rest of the libraries
+FetchContent_MakeAvailable(fmt)
+
+set(CMAKE_FOLDER "")
-- 
GitLab