File use-system-libraries.patch of Package devilutionx

diff -Nur devilutionX-1.4.0/CMake/Dependencies.cmake new/CMake/Dependencies.cmake
--- devilutionX-1.4.0/CMake/Dependencies.cmake	2022-04-13 23:33:49.000000000 +0200
+++ new/CMake/Dependencies.cmake	2022-05-22 15:05:46.136463096 +0200
@@ -167,7 +167,11 @@
 add_subdirectory(3rdParty/PKWare)
 
 if(NOT NONET AND NOT DISABLE_TCP)
-  add_subdirectory(3rdParty/asio)
+  if (DEVILUTIONX_SYSTEM_ASIO)
+    find_package(asio REQUIRED)
+  else()
+    add_subdirectory(3rdParty/asio)
+  endif()
 endif()
 
 if(NOT NONET AND NOT DISABLE_ZERO_TIER)
diff -Nur devilutionX-1.4.0/CMake/Findasio.cmake new/CMake/Findasio.cmake
--- devilutionX-1.4.0/CMake/Findasio.cmake	1970-01-01 01:00:00.000000000 +0100
+++ new/CMake/Findasio.cmake	2022-05-22 15:03:41.727854893 +0200
@@ -0,0 +1,46 @@
+# To the extent possible under law, the author(s) have dedicated all
+# copyright and related and neighboring rights to this software to the
+# public domain worldwide. This software is distributed without any warranty.
+#
+# You should have received a copy of the CC0 Public Domain Dedication
+# along with this software. If not, see
+#
+#     https://creativecommons.org/publicdomain/zero/1.0/
+#
+########################################################################
+# Tries to find the local asio installation.
+#
+# Once done the following variables will be defined:
+#
+#   asio_FOUND
+#   asio_INCLUDE_DIR
+#
+# Furthermore an imported "asio" target is created.
+#
+
+if (CMAKE_C_COMPILER_ID STREQUAL "GNU"
+    OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+    set(_GCC_COMPATIBLE 1)
+endif()
+
+find_path(asio_INCLUDE_DIR asio.hpp
+    HINTS include
+)
+
+# communicate results
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(
+    asio
+    REQUIRED_VARS
+        asio_INCLUDE_DIR
+)
+
+# mark file paths as advanced
+mark_as_advanced(asio_INCLUDE_DIR)
+set(_LIB_TYPE SHARED)
+add_library(asio INTERFACE IMPORTED)
+
+set_target_properties(asio PROPERTIES
+    INTERFACE_INCLUDE_DIRECTORIES "${asio_INCLUDE_DIR}"
+    IMPORTED_LINK_INTERFACE_LANGUAGES "CPP"
+)
diff -Nur devilutionX-1.4.0/CMake/FindSDL_audiolib.cmake new/CMake/FindSDL_audiolib.cmake
--- devilutionX-1.4.0/CMake/FindSDL_audiolib.cmake	1970-01-01 01:00:00.000000000 +0100
+++ new/CMake/FindSDL_audiolib.cmake	2022-05-22 15:03:41.727854893 +0200
@@ -0,0 +1,64 @@
+# To the extent possible under law, the author(s) have dedicated all
+# copyright and related and neighboring rights to this software to the
+# public domain worldwide. This software is distributed without any warranty.
+#
+# You should have received a copy of the CC0 Public Domain Dedication
+# along with this software. If not, see
+#
+#     https://creativecommons.org/publicdomain/zero/1.0/
+#
+########################################################################
+# Tries to find the local SDL_audiolib installation.
+#
+# Once done the following variables will be defined:
+#
+#   SDL_audiolib_FOUND
+#   SDL_audiolib_INCLUDE_DIR
+#   SDL_audiolib_LIBRARY
+#
+# Furthermore an imported "SDL_audiolib" target is created.
+#
+
+find_package(PkgConfig QUIET)
+if (PKG_CONFIG_FOUND)
+  pkg_check_modules(SDL_audiolib_PKG QUIET SDL_audiolib)
+endif()
+
+if(SDL_audiolib_PKG STREQUAL "")
+  set(SDL_audiolib_PKG SDL_audiolib)
+endif()
+    
+# Feed pkgconfig results (if found) into standard find_* to populate
+# the right CMake cache variables
+find_path(SDL_audiolib_INCLUDE_DIR aulib.h
+    HINTS ${SDL_audiolib_PKG_INCLUDE_DIRS}
+)
+find_library(SDL_audiolib_LIBRARY NAMES ${SDL_audiolib_PKG_LIBRARIES}
+    HINTS ${SDL_audiolib_PKG_LIBRARY_DIRS}
+)
+
+
+########################################################################
+# communicate results
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(
+    SDL_audiolib # The name must be either uppercase or match the filename case.
+    REQUIRED_VARS
+        SDL_audiolib_LIBRARY
+        SDL_audiolib_INCLUDE_DIR
+    VERSION_VAR
+    	SDL_audiolib_PKG_VERSION
+)
+
+# mark file paths as advanced
+mark_as_advanced(SDL_audiolib_INCLUDE_DIR)
+mark_as_advanced(SDL_audiolib_LIBRARY_RELEASE)
+
+add_library(SDL_audiolib SHARED IMPORTED)
+set_target_properties(SDL_audiolib PROPERTIES
+    INTERFACE_INCLUDE_DIRECTORIES "${SDL_audiolib_INCLUDE_DIR}"
+    IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+)
+set_target_properties(SDL_audiolib PROPERTIES
+    IMPORTED_LOCATION "${SDL_audiolib_LIBRARY}"
+)
diff -Nur devilutionX-1.4.0/CMake/FindSDL_image.cmake new/CMake/FindSDL_image.cmake
--- devilutionX-1.4.0/CMake/FindSDL_image.cmake	1970-01-01 01:00:00.000000000 +0100
+++ new/CMake/FindSDL_image.cmake	2022-05-22 15:03:41.727854893 +0200
@@ -0,0 +1,83 @@
+# To the extent possible under law, the author(s) have dedicated all
+# copyright and related and neighboring rights to this software to the
+# public domain worldwide. This software is distributed without any warranty.
+#
+# You should have received a copy of the CC0 Public Domain Dedication
+# along with this software. If not, see
+#
+#     https://creativecommons.org/publicdomain/zero/1.0/
+#
+########################################################################
+# Tries to find the local SDL_image installation.
+#
+# Once done the following variables will be defined:
+#
+#   SDL_image_FOUND
+#   SDL_image_INCLUDE_DIR
+#   SDL_image_LIBRARY
+#
+# Furthermore an imported "SDL_image" target is created.
+#
+
+if(USE_SDL1)
+  set(XNAME "SDL")
+else()
+  set(XNAME "SDL2")
+endif()
+
+find_package(PkgConfig QUIET)
+if (PKG_CONFIG_FOUND)
+  pkg_check_modules(SDL_image_PKG QUIET ${XNAME}_image)
+endif()
+
+if(SDL_image_PKG STREQUAL "")
+  set(SDL_image_PKG ${XNMAE}_image)
+endif()
+    
+# Feed pkgconfig results (if found) into standard find_* to populate
+# the right CMake cache variables
+find_path(SDL_image_INCLUDE_DIR ${XNAME}/SDL_image.h
+    HINTS ${SDL_image_PKG_INCLUDE_DIRS}
+)
+find_library(SDL_image_LIBRARY NAMES ${SDL_image_PKG_LIBRARIES}
+    HINTS ${SDL_image_PKG_LIBRARY_DIRS}
+)
+
+
+########################################################################
+# common stuff
+
+if (SDL_image_INCLUDE_DIR)
+  set(_VERSION_HEADER "${SDL_image_INCLUDE_DIR}/${XNAME}/SDL_image.h")
+  if(EXISTS "${_VERSION_HEADER}")
+        file(READ "${_VERSION_HEADER}" _VERSION_HEADER_CONTENT)
+    string(REGEX REPLACE ".*define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+([0-9]+).*" "\\1" major "${_VERSION_HEADER_CONTENT}")
+    string(REGEX REPLACE ".*define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+([0-9]+).*" "\\1" minor "${_VERSION_HEADER_CONTENT}")
+    string(REGEX REPLACE ".*define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+([0-9]+).*" "\\1" patch "${_VERSION_HEADER_CONTENT}")
+    set(SDL_image_VERSION_STRING "${major}.${minor}.${patch}")
+    endif()
+endif()
+
+# communicate results
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(
+    SDL_image # The name must be either uppercase or match the filename case.
+    REQUIRED_VARS
+        SDL_image_LIBRARY
+        SDL_image_INCLUDE_DIR
+    VERSION_VAR
+    	SDL_image_VERSION_STRING
+)
+
+# mark file paths as advanced
+mark_as_advanced(SDL_image_INCLUDE_DIR)
+mark_as_advanced(SDL_image_LIBRARY_RELEASE)
+
+add_library(SDL_image SHARED IMPORTED)
+set_target_properties(SDL_image PROPERTIES
+    INTERFACE_INCLUDE_DIRECTORIES "${SDL_image_INCLUDE_DIR}"
+    IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+)
+set_target_properties(SDL_image PROPERTIES
+    IMPORTED_LOCATION "${SDL_image_LIBRARY}"
+)
diff -Nur devilutionX-1.4.0/CMakeLists.txt new/CMakeLists.txt
--- devilutionX-1.4.0/CMakeLists.txt	2022-04-13 23:33:49.000000000 +0200
+++ new/CMakeLists.txt	2022-05-22 15:04:49.476186098 +0200
@@ -154,6 +154,8 @@
   set(DISABLE_TCP ON)
   set(DISABLE_ZERO_TIER ON)
   set(PACKET_ENCRYPTION OFF)
+else()
+  option(DEVILUTIONX_SYSTEM_ASIO "Use system-provided asio" OFF)
 endif()
 
 find_program(CCACHE_PROGRAM ccache)
openSUSE Build Service is sponsored by