From 43d754bd1d95406997095dd7b1b5207a9ae921f2 Mon Sep 17 00:00:00 2001
From: patrick96
Date: Sun, 28 Feb 2021 13:05:40 +0100
Subject: [PATCH] cmake: Add modules for curl and alsa
Older versions of cmake (e.g. in Ubuntu 18.04) did not provide cmake
modules for these libraries that also created a target.
Fixes #2393
---
cmake/libpoly.cmake | 2 --
cmake/modules/FindALSA.cmake | 14 ++++++++++++++
cmake/modules/FindCURL.cmake | 14 ++++++++++++++
3 files changed, 28 insertions(+), 2 deletions(-)
create mode 100644 cmake/modules/FindALSA.cmake
create mode 100644 cmake/modules/FindCURL.cmake
diff --git a/cmake/libpoly.cmake b/cmake/libpoly.cmake
index 83343892..b465919b 100644
--- a/cmake/libpoly.cmake
+++ b/cmake/libpoly.cmake
@@ -50,12 +50,10 @@ find_package(CairoFC REQUIRED)
if (ENABLE_ALSA)
find_package(ALSA REQUIRED)
- set(ALSA_VERSION ${ALSA_VERSION_STRING})
endif()
if (ENABLE_CURL)
find_package(CURL REQUIRED)
- set(CURL_VERSION ${CURL_VERSION_STRING})
endif()
if (ENABLE_MPD)
diff --git a/cmake/modules/FindALSA.cmake b/cmake/modules/FindALSA.cmake
new file mode 100644
index 00000000..742f8ea6
--- /dev/null
+++ b/cmake/modules/FindALSA.cmake
@@ -0,0 +1,14 @@
+# This module defines an imported target `ALSA::ALSA` if alsa is found
+#
+# Defines the following Variables (see find_package_impl for more info):
+# ALSA_FOUND
+# ALSA_INCLUDE_DIR
+# ALSA_INCLUDE_DIRS
+# ALSA_LIBRARY
+# ALSA_LIBRARIES
+# ALSA_VERSION
+find_package_impl("alsa" "ALSA" "alsa/asoundlib.h")
+
+if(ALSA_FOUND AND NOT TARGET ALSA::ALSA)
+ create_imported_target("ALSA::ALSA" "${ALSA_INCLUDE_DIR}" "${ALSA_LIBRARY}")
+endif()
diff --git a/cmake/modules/FindCURL.cmake b/cmake/modules/FindCURL.cmake
new file mode 100644
index 00000000..2d13b380
--- /dev/null
+++ b/cmake/modules/FindCURL.cmake
@@ -0,0 +1,14 @@
+# This module defines an imported target `CURL::libcurl` if libcurl is found
+#
+# Defines the following Variables (see find_package_impl for more info):
+# CURL_FOUND
+# CURL_INCLUDE_DIR
+# CURL_INCLUDE_DIRS
+# CURL_LIBRARY
+# CURL_LIBRARIES
+# CURL_VERSION
+find_package_impl("libcurl" "CURL" "curl/curl.h")
+
+if(CURL_FOUND AND NOT TARGET CURL::libcurl)
+ create_imported_target("CURL::libcurl" "${CURL_INCLUDE_DIR}" "${CURL_LIBRARY}")
+endif()