From: Xiangzhe <xiangzhedev@gmail.com>
Subject: [PATCH] build: use system copies of packaged dependencies

Gentoo provides compatible CMake packages for Catch2, cpp-httplib,
cxxopts, nlohmann_json, and SimpleIni. Use their imported targets in the
DISABLE_VCPKG build instead of compiling the bundled snapshots.

SimpleIni is header-only, so link its imported target through CORE_LIBRARIES
instead of relying on a global include directory.

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -155,30 +155,13 @@
   find_package(Unwind)
 endif()
 
-if(DISABLE_VCPKG)
-  if(BUILD_TESTING)
-    add_subdirectory(${EXTERNAL_DIR}/Catch2)
-  endif()
-  add_subdirectory(${EXTERNAL_DIR}/cxxopts)
-  add_subdirectory(${EXTERNAL_DIR}/cpp-httplib)
-  add_subdirectory(${EXTERNAL_DIR}/json)
-  include_directories(
-    SYSTEM ${EXTERNAL_DIR}/cpp-httplib
-  )
-  include_directories(
-    ${EXTERNAL_DIR}/simpleini
-    ${EXTERNAL_DIR}/json/include
-    ${EXTERNAL_DIR}/cxxopts/include
-  )
-else()
-  if(BUILD_TESTING)
-    find_package(Catch2 CONFIG REQUIRED)
-  endif()
-  find_package(httplib CONFIG REQUIRED)
-  find_package(cxxopts CONFIG REQUIRED)
-  find_package(nlohmann_json CONFIG REQUIRED)
-  find_path(SIMPLEINI_INCLUDE_DIRS "SimpleIni.h")
+if(BUILD_TESTING)
+  find_package(Catch2 3 CONFIG REQUIRED)
 endif()
+find_package(httplib CONFIG REQUIRED)
+find_package(cxxopts CONFIG REQUIRED)
+find_package(nlohmann_json CONFIG REQUIRED)
+find_package(SimpleIni CONFIG REQUIRED)
 
 # Optional packages
 find_package(UTempter)
@@ -371,6 +354,7 @@
     httplib::httplib
     cxxopts::cxxopts
     nlohmann_json::nlohmann_json
+    SimpleIni::SimpleIni
     OpenSSL::SSL
     OpenSSL::Crypto
     ZLIB::ZLIB
@@ -445,7 +429,6 @@
   ${UTEMPTER_INCLUDE_DIR}
   ${Boost_INCLUDE_DIR}
   ${OPENSSL_INCLUDE_DIR}
-  ${SIMPLEINI_INCLUDE_DIRS}
 )
 include_directories(
   src/base
